class OpenTelemetry::Trace::TraceFlags

TraceFlags contain details about the trace. Unlike Tracestate values, TraceFlags are present in all traces. Currently, the only TraceFlag is a boolean {sampled?} {www.w3.org/TR/trace-context/#trace-flags flag}.

Constants

DEFAULT
SAMPLED

Public Class Methods

from_byte(flags) click to toggle source

Returns a newly created {TraceFlags} with the specified flags.

@param [Integer] flags 8-bit byte of bit flags @return [TraceFlags]

# File lib/opentelemetry/trace/trace_flags.rb, line 20
def from_byte(flags)
  flags = 0 unless flags & ~0xFF == 0 # rubocop:disable Style/NumericPredicate

  new(flags)
end
new(flags) click to toggle source

@api private The constructor is private and only for use internally by the class. Users should use the {from_byte} factory method to obtain a {TraceFlags} instance.

@param [Integer] flags 8-bit byte of bit flags @return [TraceFlags]

# File lib/opentelemetry/trace/trace_flags.rb, line 34
def initialize(flags)
  @flags = flags
end

Public Instance Methods

sampled?() click to toggle source

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

@return [Boolean]

# File lib/opentelemetry/trace/trace_flags.rb, line 42
def sampled?
  (@flags & 1) != 0
end