mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-09 12:23:32 -04:00
feat(cohttp): pass attrs
This commit is contained in:
parent
2d62671d07
commit
75f1612ab0
1 changed files with 3 additions and 2 deletions
|
|
@ -16,6 +16,7 @@ module Server : sig
|
||||||
*)
|
*)
|
||||||
val trace :
|
val trace :
|
||||||
service_name:string ->
|
service_name:string ->
|
||||||
|
?attrs:Otel.Span.key_value list ->
|
||||||
('conn -> Request.t -> 'body -> (Response.t * 'body) Lwt.t) ->
|
('conn -> Request.t -> 'body -> (Response.t * 'body) Lwt.t) ->
|
||||||
'conn -> Request.t -> 'body -> (Response.t * 'body) Lwt.t
|
'conn -> Request.t -> 'body -> (Response.t * 'body) Lwt.t
|
||||||
end = struct
|
end = struct
|
||||||
|
|
@ -50,7 +51,7 @@ end = struct
|
||||||
| Ok (trace_id, parent_id) -> (Some trace_id, Some parent_id)
|
| Ok (trace_id, parent_id) -> (Some trace_id, Some parent_id)
|
||||||
| Error _ -> None, None)
|
| Error _ -> None, None)
|
||||||
|
|
||||||
let trace ~service_name callback =
|
let trace ~service_name ?(attrs=[]) callback =
|
||||||
fun conn req body ->
|
fun conn req body ->
|
||||||
let trace_id, parent_id = trace_context_of_headers req in
|
let trace_id, parent_id = trace_context_of_headers req in
|
||||||
let open Lwt.Syntax in
|
let open Lwt.Syntax in
|
||||||
|
|
@ -58,7 +59,7 @@ end = struct
|
||||||
~service_name
|
~service_name
|
||||||
"request"
|
"request"
|
||||||
~kind:Span_kind_server
|
~kind:Span_kind_server
|
||||||
~attrs:(span_attrs req)
|
~attrs:(attrs @ span_attrs req)
|
||||||
?parent:parent_id
|
?parent:parent_id
|
||||||
?trace_id
|
?trace_id
|
||||||
(fun scope ->
|
(fun scope ->
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue