mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-09 12:23:32 -04:00
chore(cohttp): optional service_name
This commit is contained in:
parent
32fec9b2f5
commit
82bcebbb89
1 changed files with 3 additions and 3 deletions
|
|
@ -19,7 +19,7 @@ module Server : sig
|
||||||
(Server.make () ~callback:callback_traced)
|
(Server.make () ~callback:callback_traced)
|
||||||
*)
|
*)
|
||||||
val trace :
|
val trace :
|
||||||
service_name:string ->
|
?service_name:string ->
|
||||||
?attrs:Otel.Span.key_value list ->
|
?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
|
||||||
|
|
@ -112,11 +112,11 @@ end = struct
|
||||||
let headers = Header.remove (Request.headers req) header_x_ocaml_otel_traceparent in
|
let headers = Header.remove (Request.headers req) header_x_ocaml_otel_traceparent in
|
||||||
{ req with headers }
|
{ req with headers }
|
||||||
|
|
||||||
let trace ~service_name ?(attrs=[]) callback =
|
let trace ?service_name ?(attrs=[]) callback =
|
||||||
fun conn req body ->
|
fun conn req body ->
|
||||||
let scope = get_trace_context ~from:`External req in
|
let scope = get_trace_context ~from:`External req in
|
||||||
Otel_lwt.Trace.with_
|
Otel_lwt.Trace.with_
|
||||||
~service_name
|
?service_name
|
||||||
"request"
|
"request"
|
||||||
~kind:Span_kind_server
|
~kind:Span_kind_server
|
||||||
?trace_id:(Option.map (fun scope -> scope.Otel.Trace.trace_id) scope)
|
?trace_id:(Option.map (fun scope -> scope.Otel.Trace.trace_id) scope)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue