Extract a span context from HTTP headers received from a client
Source:R/api.R
extract_http_context.RdThe return value can be used as the parent option when starting
a span.
Arguments
- headers
A named list with one or two strings:
traceparentis mandatory, andtracestateis optional.- tracer
Tracer object (otel_tracer) or tracer name to use. If
NULL, then otel uses an internal tracer. You usually do not need to set this, the active span does not depend on the tracer.Passing a tracer might give the wrong result. If it is a no-op tracer, then the result is an invalid span (context), or no HTTP headers, even if there is an active span. This happens if the tracer's scope is turned off, e.g. via the
OTEL_R_SUPPRESS_SCOPESenvironment variable, or if the tracer was created before tracing was turned on. The defaultNULLdoes not have this problem.
Value
And otel_span_context object.
Examples
hdr <- otel::pack_http_context()
ctx <- otel::extract_http_context()
ctx$is_valid()
#> [1] FALSE