mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
fix(cohttp): use correct scope for traceparent header
This commit is contained in:
parent
82bcebbb89
commit
5e8affe508
1 changed files with 7 additions and 13 deletions
|
|
@ -162,17 +162,11 @@ let client ?(scope : Otel.Trace.scope option) (module C : Cohttp_lwt.S.Client)
|
||||||
let attrs = attrs_for ~uri ~meth () in
|
let attrs = attrs_for ~uri ~meth () in
|
||||||
(trace_id, parent, attrs)
|
(trace_id, parent, attrs)
|
||||||
|
|
||||||
let add_traceparent headers =
|
let add_traceparent (scope : Otel.Trace.scope) headers =
|
||||||
match scope with
|
let module Traceparent = Otel.Trace_context.Traceparent in
|
||||||
| None -> headers
|
let headers = match headers with | None -> Header.init () | Some headers -> headers in
|
||||||
| Some scope ->
|
Header.add headers Traceparent.name
|
||||||
let module Traceparent = Otel.Trace_context.Traceparent in
|
(Traceparent.to_value ~trace_id:scope.trace_id ~parent_id:scope.span_id ())
|
||||||
let headers = match headers with | None -> Header.init () | Some headers -> headers in
|
|
||||||
let headers =
|
|
||||||
Header.add headers Traceparent.name
|
|
||||||
(Traceparent.to_value ~trace_id:scope.trace_id ~parent_id:scope.span_id ())
|
|
||||||
in
|
|
||||||
Some headers
|
|
||||||
|
|
||||||
let call ?ctx ?headers ?body ?chunked meth (uri : Uri.t) : (Response.t * Cohttp_lwt.Body.t) Lwt.t =
|
let call ?ctx ?headers ?body ?chunked meth (uri : Uri.t) : (Response.t * Cohttp_lwt.Body.t) Lwt.t =
|
||||||
let (trace_id, parent, attrs) = context_for ~uri ~meth in
|
let (trace_id, parent, attrs) = context_for ~uri ~meth in
|
||||||
|
|
@ -182,8 +176,8 @@ let client ?(scope : Otel.Trace.scope option) (module C : Cohttp_lwt.S.Client)
|
||||||
?parent
|
?parent
|
||||||
~attrs
|
~attrs
|
||||||
(fun scope ->
|
(fun scope ->
|
||||||
let headers = add_traceparent headers in
|
let headers = add_traceparent scope headers in
|
||||||
let* (res, body) = C.call ?ctx ?headers ?body ?chunked meth uri in
|
let* (res, body) = C.call ?ctx ~headers ?body ?chunked meth uri in
|
||||||
Otel.Trace.add_attrs scope (fun () ->
|
Otel.Trace.add_attrs scope (fun () ->
|
||||||
let code = Response.status res in
|
let code = Response.status res in
|
||||||
let code = Code.code_of_status code in
|
let code = Code.code_of_status code in
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue