Skip to content

otel_tracer_provider -> otel_tracer -> otel_span -> otel_span_context

Value

Not applicable.

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.

Usage

span_context$get_span_id()

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.

Usage

span_context$get_trace_flags()

Value

A list with entries:

  • is_sampled: logical flag, whether the trace of the span is sampled. If FALSE then 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.

Usage

span_context$get_trace_id()

Value

A string scalar, a trace id. For invalid spans it is invalid_trace_id.

span_context$is_remote()

Whether the span was propagated from a remote parent.

Usage

span_context$is_remote()

Value

A logical scalar.

span_context$is_sampled()

Whether the span is sampled. This is the same as the is_sampled trace flags, see get_trace_flags() above.

Usage

span_context$is_sampled()

Value

Logical scalar.

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.

Usage

span_context$is_valid()

Value

A logical scalar.

span_context$to_http_headers()

Serialize the span context into one or more HTTP headers that can be transmitted to other processes or servers, to create a distributed trace.

The other process can deserialize these headers into a span context that can be used to create new remote spans.

Usage

span_context$to_http_headers()

Value

A named character vector, the HTTP header representation of the span context. Usually includes a traceparent header. May include other headers.

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)