Class: OpenTelemetry::SDK::Trace::SpanLimits

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

Overview

Class that holds global trace parameters.

Constant Summary collapse

DEFAULT =
new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute_count_limit: Integer(ENV.fetch('OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT', 128)), attribute_length_limit: ENV.fetch('OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT', ENV['OTEL_RUBY_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT']), event_count_limit: Integer(ENV.fetch('OTEL_SPAN_EVENT_COUNT_LIMIT', 128)), link_count_limit: Integer(ENV.fetch('OTEL_SPAN_LINK_COUNT_LIMIT', 128)), event_attribute_count_limit: Integer(ENV.fetch('OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT', 128)), link_attribute_count_limit: Integer(ENV.fetch('OTEL_LINK_ATTRIBUTE_COUNT_LIMIT', 128))) ⇒ SpanLimits

Returns a OpenTelemetry::SDK::Trace::SpanLimits with the desired values.

Raises:

  • (ArgumentError)

    if any of the max numbers are not positive.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/opentelemetry/sdk/trace/span_limits.rb', line 34

def initialize(attribute_count_limit: Integer(ENV.fetch('OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT', 128)), # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
               attribute_length_limit: ENV.fetch('OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT',
                                                 ENV['OTEL_RUBY_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT']),
               event_count_limit: Integer(ENV.fetch('OTEL_SPAN_EVENT_COUNT_LIMIT', 128)),
               link_count_limit: Integer(ENV.fetch('OTEL_SPAN_LINK_COUNT_LIMIT', 128)),
               event_attribute_count_limit: Integer(ENV.fetch('OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT', 128)),
               link_attribute_count_limit: Integer(ENV.fetch('OTEL_LINK_ATTRIBUTE_COUNT_LIMIT', 128)))
  raise ArgumentError, 'attribute_count_limit must be positive' unless attribute_count_limit.positive?
  raise ArgumentError, 'attribute_length_limit must not be less than 32' unless attribute_length_limit.nil? || Integer(attribute_length_limit) >= 32
  raise ArgumentError, 'event_count_limit must be positive' unless event_count_limit.positive?
  raise ArgumentError, 'link_count_limit must be positive' unless link_count_limit.positive?
  raise ArgumentError, 'event_attribute_count_limit must be positive' unless event_attribute_count_limit.positive?
  raise ArgumentError, 'link_attribute_count_limit must be positive' unless link_attribute_count_limit.positive?

  @attribute_count_limit = attribute_count_limit
  @attribute_length_limit = attribute_length_limit.nil? ? nil : Integer(attribute_length_limit)
  @event_count_limit = event_count_limit
  @link_count_limit = link_count_limit
  @event_attribute_count_limit = event_attribute_count_limit
  @link_attribute_count_limit = link_attribute_count_limit
end

Instance Attribute Details

#attribute_count_limitObject (readonly)

The global default max number of attributes per OpenTelemetry::SDK::Trace::Span.



13
14
15
# File 'lib/opentelemetry/sdk/trace/span_limits.rb', line 13

def attribute_count_limit
  @attribute_count_limit
end

#attribute_length_limitObject (readonly)

The global default max length of attribute value per OpenTelemetry::SDK::Trace::Span.



16
17
18
# File 'lib/opentelemetry/sdk/trace/span_limits.rb', line 16

def attribute_length_limit
  @attribute_length_limit
end

#event_attribute_count_limitObject (readonly)

The global default max number of attributes per Event.



25
26
27
# File 'lib/opentelemetry/sdk/trace/span_limits.rb', line 25

def event_attribute_count_limit
  @event_attribute_count_limit
end

#event_count_limitObject (readonly)

The global default max number of Events per OpenTelemetry::SDK::Trace::Span.



19
20
21
# File 'lib/opentelemetry/sdk/trace/span_limits.rb', line 19

def event_count_limit
  @event_count_limit
end

The global default max number of attributes per Trace::Link.



28
29
30
# File 'lib/opentelemetry/sdk/trace/span_limits.rb', line 28

def link_attribute_count_limit
  @link_attribute_count_limit
end

The global default max number of Trace::Link entries per OpenTelemetry::SDK::Trace::Span.



22
23
24
# File 'lib/opentelemetry/sdk/trace/span_limits.rb', line 22

def link_count_limit
  @link_count_limit
end