Module Opentelemetry_cohttp_lwt.Server

val trace : ?tracer:Otel.Tracer.t -> ?attrs:Otel.Span.key_value list -> ('conn -> Cohttp.Request.t -> 'body -> (Cohttp.Response.t * 'body) Lwt.t) -> 'conn -> Cohttp.Request.t -> 'body -> (Cohttp.Response.t * 'body) Lwt.t

Trace requests to a Cohttp server.

Use it like this:

  let my_server callback =
    let callback_traced =
      Opentelemetry_cohttp_lwt.Server.trace ~service_name:"my-service"
        (fun _scope -> callback)
    in
    Cohttp_lwt_unix.Server.create
      ~mode:(`TCP (`Port 8080))
      (Server.make () ~callback:callback_traced)
val with_ : ?tracer:Otel.Tracer.t -> ?trace_state:string -> ?attrs:Otel.Span.key_value list -> ?kind:Otel.Span.kind -> ?links:Otel.Span_link.t list -> string -> Cohttp.Request.t -> (Cohttp.Request.t -> 'a Lwt.t) -> 'a Lwt.t

Trace a new internal span, parented to the ambient span. req is passed through unchanged.

  • deprecated use Opentelemetry_lwt.Tracer.with_
val get_trace_context : Cohttp.Request.t -> Otel.Span_ctx.t option

Remote span context from the W3C traceparent and tracestate headers.

  • since 0.92 returns a {!Otel.Span_ctx.t}, no [?from]