package opentelemetry-cohttp-lwt

  1. Overview
  2. Docs
Opentelemetry tracing for Cohttp HTTP servers

Install

Dune Dependency

Authors

Maintainers

Sources

opentelemetry-0.8.tbz
sha256=8696157e2b9fc279223dd9436c009709b6d8888065bdb0382f6f13696c229691
sha512=9b5273c5fe082da5ef436051da059b5ea7a01b5568f6c64299953a79f1a8c1c118edc79d956378a684f0154727a47ccd0da1bd4ed96ad40a36e0334eb6ee3a0e

doc/opentelemetry-cohttp-lwt/Opentelemetry_cohttp_lwt/Server/index.html

Module Opentelemetry_cohttp_lwt.ServerSource

Sourceval trace : ?service_name:string -> ?attrs:Otel.Span.key_value list -> ('conn -> Cohttp_lwt.Request.t -> 'body -> (Cohttp_lwt.Response.t * 'body) Lwt.t) -> 'conn -> Cohttp_lwt.Request.t -> 'body -> (Cohttp_lwt.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)
Sourceval with_ : ?trace_state:string -> ?service_name:string -> ?attrs:Otel.Span.key_value list -> ?kind:Otel.Span.kind -> ?links:Otel.Span_link.t list -> string -> Cohttp_lwt.Request.t -> (Cohttp_lwt.Request.t -> 'a Lwt.t) -> 'a Lwt.t

Trace a new internal span.

Identical to Opentelemetry_lwt.Trace.with_, but fetches/stores the trace scope in the x-ocaml-otel-traceparent header in the request for convenience.

Sourceval get_trace_context : ?from:[ `Internal | `External ] -> Cohttp_lwt.Request.t -> Otel.Scope.t option

Get the tracing scope from the custom x-ocaml-otel-traceparent header added by trace and with_.

Sourceval set_trace_context : Otel.Scope.t -> Cohttp_lwt.Request.t -> Cohttp_lwt.Request.t

Set the tracing scope in the custom x-ocaml-otel-traceparent header used by trace and with_.

Sourceval remove_trace_context : Cohttp_lwt.Request.t -> Cohttp_lwt.Request.t

Strip the custom x-ocaml-otel-traceparent header added by trace and with_.

OCaml

Innovation. Community. Security.