otel_tracer_provider -> otel_tracer -> otel_span -> otel_span_context
Details
This is a representation of a span that can be serialized, copied to other processes, and it can be used to create new child spans.
Methods
span_context$get_span_id()
Get the id of the span.
Value
String scalar, a span id. For invalid spans it is invalid_span_id.
span_context$get_trace_flags()
Get the trace flags of a span.
See the specification for more details on trace flags.
Value
A list with entries:
is_sampled: logical flag, whether the trace of the span is sampled. IfFALSEthen the caller is not recording the trace. See details in the specification.is_random: logical flag, it specifies how trace ids are generated. See details in the specification.
span_context$get_trace_id()
Get the id of the trace the span belongs to.
Value
A string scalar, a trace id. For invalid spans it is invalid_trace_id.
span_context$is_sampled()
Whether the span is sampled. This is the same as the is_sampled
trace flags, see get_trace_flags() above.
span_context$is_valid()
Whether the span is valid. Sometimes otel functions return an
invalid span or a span context referring to an invalid span. E.g.
get_active_span_context() does that if there is no active span.
is_valid() checks if the span is valid.
An span id of an invalid span is invalid_span_id.
See also
Other low level trace API:
get_default_tracer_provider(),
get_tracer(),
otel_span,
otel_tracer,
otel_tracer_provider,
tracer_provider_noop
Examples
spc <- get_active_span_context()
spc$get_trace_flags()
#> list()
spc$get_trace_id()
#> [1] "00000000000000000000000000000000"
spc$get_span_id()
#> [1] "0000000000000000"
spc$is_remote()
#> [1] FALSE
spc$is_sampled()
#> [1] FALSE
spc$is_valid()
#> [1] FALSE
spc$to_http_headers()
#> named character(0)