mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 20:07:55 -04:00
28 lines
6.7 KiB
HTML
28 lines
6.7 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Server (opentelemetry-cohttp-lwt.Opentelemetry_cohttp_lwt.Server)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 3.1.0"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> – <a href="../../../index.html">Index</a> » <a href="../../index.html">opentelemetry-cohttp-lwt</a> » <a href="../index.html">Opentelemetry_cohttp_lwt</a> » Server</nav><header class="odoc-preamble"><h1>Module <code><span>Opentelemetry_cohttp_lwt.Server</span></code></h1></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-trace"><a href="#val-trace" class="anchor"></a><code><span><span class="keyword">val</span> trace :
|
||
<span><span class="optlabel">?service_name</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?attrs</span>:<span><a href="../../../opentelemetry/Opentelemetry/Span/index.html#type-key_value">Otel.Span.key_value</a> list</span> <span class="arrow">-></span></span>
|
||
<span><span>(<span><span class="type-var">'conn</span> <span class="arrow">-></span></span> <span><a href="../../../cohttp/Cohttp/Request/index.html#type-t">Cohttp.Request.t</a> <span class="arrow">-></span></span> <span><span class="type-var">'body</span> <span class="arrow">-></span></span> <span><span>(<a href="../../../cohttp/Cohttp/Response/index.html#type-t">Cohttp.Response.t</a> * <span class="type-var">'body</span>)</span> <a href="../../../lwt/Lwt/index.html#type-t">Lwt.t</a></span>)</span> <span class="arrow">-></span></span>
|
||
<span><span class="type-var">'conn</span> <span class="arrow">-></span></span>
|
||
<span><a href="../../../cohttp/Cohttp/Request/index.html#type-t">Cohttp.Request.t</a> <span class="arrow">-></span></span>
|
||
<span><span class="type-var">'body</span> <span class="arrow">-></span></span>
|
||
<span><span>(<a href="../../../cohttp/Cohttp/Response/index.html#type-t">Cohttp.Response.t</a> * <span class="type-var">'body</span>)</span> <a href="../../../lwt/Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Trace requests to a Cohttp server.</p><p>Use it like this:</p><pre class="language-ocaml"><code> 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)</code></pre></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-with_"><a href="#val-with_" class="anchor"></a><code><span><span class="keyword">val</span> with_ :
|
||
<span><span class="optlabel">?trace_state</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?service_name</span>:string <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?attrs</span>:<span><a href="../../../opentelemetry/Opentelemetry/Span/index.html#type-key_value">Otel.Span.key_value</a> list</span> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?kind</span>:<a href="../../../opentelemetry/Opentelemetry/Span/index.html#type-kind">Otel.Span.kind</a> <span class="arrow">-></span></span>
|
||
<span><span class="optlabel">?links</span>:<span><a href="../../../opentelemetry/Opentelemetry/Span_link/index.html#type-t">Otel.Span_link.t</a> list</span> <span class="arrow">-></span></span>
|
||
<span>string <span class="arrow">-></span></span>
|
||
<span><a href="../../../cohttp/Cohttp/Request/index.html#type-t">Cohttp.Request.t</a> <span class="arrow">-></span></span>
|
||
<span><span>(<span><a href="../../../cohttp/Cohttp/Request/index.html#type-t">Cohttp.Request.t</a> <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <a href="../../../lwt/Lwt/index.html#type-t">Lwt.t</a></span>)</span> <span class="arrow">-></span></span>
|
||
<span><span class="type-var">'a</span> <a href="../../../lwt/Lwt/index.html#type-t">Lwt.t</a></span></span></code></div><div class="spec-doc"><p>Trace a new internal span.</p><p>Identical to <code>Opentelemetry_lwt.Trace.with_</code>, but fetches/stores the trace scope in the <code>x-ocaml-otel-traceparent</code> header in the request for convenience.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_trace_context"><a href="#val-get_trace_context" class="anchor"></a><code><span><span class="keyword">val</span> get_trace_context :
|
||
<span><span class="optlabel">?from</span>:<span>[ `Internal <span>| `External</span> ]</span> <span class="arrow">-></span></span>
|
||
<span><a href="../../../cohttp/Cohttp/Request/index.html#type-t">Cohttp.Request.t</a> <span class="arrow">-></span></span>
|
||
<span><a href="../../../opentelemetry/Opentelemetry/Scope/index.html#type-t">Otel.Scope.t</a> option</span></span></code></div><div class="spec-doc"><p>Get the tracing scope from the custom <code>x-ocaml-otel-traceparent</code> header added by <code>trace</code> and <code>with_</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-set_trace_context"><a href="#val-set_trace_context" class="anchor"></a><code><span><span class="keyword">val</span> set_trace_context : <span><a href="../../../opentelemetry/Opentelemetry/Scope/index.html#type-t">Otel.Scope.t</a> <span class="arrow">-></span></span> <span><a href="../../../cohttp/Cohttp/Request/index.html#type-t">Cohttp.Request.t</a> <span class="arrow">-></span></span> <a href="../../../cohttp/Cohttp/Request/index.html#type-t">Cohttp.Request.t</a></span></code></div><div class="spec-doc"><p>Set the tracing scope in the custom <code>x-ocaml-otel-traceparent</code> header used by <code>trace</code> and <code>with_</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-remove_trace_context"><a href="#val-remove_trace_context" class="anchor"></a><code><span><span class="keyword">val</span> remove_trace_context : <span><a href="../../../cohttp/Cohttp/Request/index.html#type-t">Cohttp.Request.t</a> <span class="arrow">-></span></span> <a href="../../../cohttp/Cohttp/Request/index.html#type-t">Cohttp.Request.t</a></span></code></div><div class="spec-doc"><p>Strip the custom <code>x-ocaml-otel-traceparent</code> header added by <code>trace</code> and <code>with_</code>.</p></div></div></div></body></html>
|