Learn R Programming

otel (version 0.3.0)

pack_http_context: Pack the currently active span context into standard HTTP OpenTelemetry headers

Description

The returned headers can be sent over HTTP, or set as environment variables for subprocesses.

Usage

pack_http_context(tracer = NULL)

Value

A named character vector, with lowercase names. It might be an empty vector, e.g. if tracing is disabled.

Arguments

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_SCOPES environment variable, or if the tracer was created before tracing was turned on. The default NULL does not have this problem.

See Also

extract_http_context()

Examples

Run this code
hdr <- otel::pack_http_context()
ctx <- otel::extract_http_context()
ctx$is_valid()

Run the code above in your browser using DataLab