mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
feat trace: add set_span_status
This commit is contained in:
parent
a2a7a6cf1e
commit
30175db1ed
2 changed files with 14 additions and 1 deletions
|
|
@ -14,6 +14,7 @@ module Extensions = struct
|
|||
bt: Printexc.raw_backtrace;
|
||||
}
|
||||
| Ev_set_span_kind of Otrace.explicit_span * OTEL.Span_kind.t
|
||||
| Ev_set_span_status of Otrace.explicit_span * OTEL.Span_status.t
|
||||
end
|
||||
|
||||
open Extensions
|
||||
|
|
@ -243,6 +244,10 @@ module Make_collector (A : COLLECTOR_ARG) = struct
|
|||
(match get_span_ sp with
|
||||
| None -> !on_internal_error "could not find scope for OTEL span"
|
||||
| Some sc -> OTEL.Span.set_kind sc k)
|
||||
| Ev_set_span_status (sp, st) ->
|
||||
(match get_span_ sp with
|
||||
| None -> !on_internal_error "could not find scope for OTEL span"
|
||||
| Some sc -> OTEL.Span.set_status sc st)
|
||||
| Ev_record_exn { sp; exn; bt } ->
|
||||
(match get_span_ sp with
|
||||
| None -> !on_internal_error "could not find scope for OTEL span"
|
||||
|
|
@ -266,9 +271,13 @@ let link_spans (sp1 : Otrace.explicit_span) (sp2 : Otrace.explicit_span) : unit
|
|||
if Otrace.enabled () then Otrace.extension_event @@ Ev_link_span (sp1, sp2)
|
||||
*)
|
||||
|
||||
let set_span_kind sp k : unit =
|
||||
let[@inline] set_span_kind sp k : unit =
|
||||
if Otrace.enabled () then Otrace.extension_event @@ Ev_set_span_kind (sp, k)
|
||||
|
||||
let[@inline] set_span_status sp status : unit =
|
||||
if Otrace.enabled () then
|
||||
Otrace.extension_event @@ Ev_set_span_status (sp, status)
|
||||
|
||||
let record_exception sp exn bt : unit =
|
||||
if Otrace.enabled () then
|
||||
Otrace.extension_event @@ Ev_record_exn { sp; exn; bt }
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ module Extensions : sig
|
|||
}
|
||||
(** Record exception and potentially turn span to an error *)
|
||||
| Ev_set_span_kind of Otrace.explicit_span * OTEL.Span_kind.t
|
||||
| Ev_set_span_status of Otrace.explicit_span * OTEL.Span_status.t
|
||||
end
|
||||
|
||||
val on_internal_error : (string -> unit) ref
|
||||
|
|
@ -92,6 +93,9 @@ val set_span_kind : Otrace.explicit_span -> OTEL.Span.kind -> unit
|
|||
(** [set_span_kind sp k] sets the span's kind.
|
||||
@since 0.11 *)
|
||||
|
||||
val set_span_status : Otrace.explicit_span -> OTEL.Span_status.t -> unit
|
||||
(** @since NEXT_RELEASE *)
|
||||
|
||||
val record_exception :
|
||||
Otrace.explicit_span -> exn -> Printexc.raw_backtrace -> unit
|
||||
(** Record exception in the current span.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue