feat(cohttp): pass attrs

This commit is contained in:
Matt Bray 2022-03-24 17:56:29 +00:00
parent 2d62671d07
commit 75f1612ab0

View file

@ -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 ->