Class: OpenTelemetry::Trace::TraceFlags

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/trace/trace_flags.rb

Overview

TraceFlags contain details about the trace. Unlike Tracestate values, TraceFlags are present in all traces. Currently, the only TraceFlag is a boolean #sampled? flag.

Constant Summary collapse

DEFAULT =
from_byte(0)
SAMPLED =
from_byte(1)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flags) ⇒ TraceFlags

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The constructor is private and only for use internally by the class. Users should use the from_byte factory method to obtain a OpenTelemetry::Trace::TraceFlags instance.

Parameters:

  • flags (Integer)

    8-bit byte of bit flags



34
35
36
# File 'lib/opentelemetry/trace/trace_flags.rb', line 34

def initialize(flags)
  @flags = flags
end

Class Method Details

.from_byte(flags) ⇒ TraceFlags

Returns a newly created OpenTelemetry::Trace::TraceFlags with the specified flags.

Parameters:

  • flags (Integer)

    8-bit byte of bit flags

Returns:



20
21
22
23
24
# File 'lib/opentelemetry/trace/trace_flags.rb', line 20

def from_byte(flags)
  flags = 0 unless flags & ~0xFF == 0

  new(flags)
end

Instance Method Details

#sampled?Boolean

Returns whether the caller may have recorded trace data. When false, the caller did not record trace data out-of-band.

Returns:

  • (Boolean)


42
43
44
# File 'lib/opentelemetry/trace/trace_flags.rb', line 42

def sampled?
  (@flags & 1) != 0
end