mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
feat trace: set status of a span based on exception.message
This commit is contained in:
parent
60a0b843e6
commit
461811a2cb
1 changed files with 7 additions and 1 deletions
|
|
@ -144,6 +144,12 @@ module Internal = struct
|
|||
let end_time = Timestamp_ns.now_unix_ns () in
|
||||
let kind, attrs = otel_attrs_of_otrace_data scope.attrs in
|
||||
|
||||
let status : Span.status =
|
||||
match List.assoc_opt "exception.message" scope.attrs with
|
||||
| Some (`String message) -> { message; code = Span.Status_code_error }
|
||||
| _ -> { message = ""; code = Span.Status_code_ok }
|
||||
in
|
||||
|
||||
let attrs =
|
||||
match __FUNCTION__ with
|
||||
| None ->
|
||||
|
|
@ -166,7 +172,7 @@ module Internal = struct
|
|||
in
|
||||
|
||||
let parent_id = Option.map Otel.Span_ctx.parent_id parent in
|
||||
Span.create ~kind ~trace_id:scope.trace_id ?parent:parent_id
|
||||
Span.create ~kind ~trace_id:scope.trace_id ?parent:parent_id ~status
|
||||
~id:scope.span_id ~start_time ~end_time ~attrs ~events:scope.events name
|
||||
|> fst
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue