Class: OpenTelemetry::SDK::Metrics::View::RegisteredView

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/sdk/metrics/view/registered_view.rb

Overview

RegisteredView is an internal class used to match Views with a given MetricStream

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, **options) ⇒ RegisteredView

Returns a new instance of RegisteredView.



15
16
17
18
19
20
21
22
# File 'lib/opentelemetry/sdk/metrics/view/registered_view.rb', line 15

def initialize(name, **options)
  @name = name
  @options = options
  @aggregation = options[:aggregation]
  @attribute_keys = options[:attribute_keys] || {}

  generate_regex_pattern(name)
end

Instance Attribute Details

#aggregationObject (readonly)

Returns the value of attribute aggregation.



13
14
15
# File 'lib/opentelemetry/sdk/metrics/view/registered_view.rb', line 13

def aggregation
  @aggregation
end

#attribute_keysObject (readonly)

Returns the value of attribute attribute_keys.



13
14
15
# File 'lib/opentelemetry/sdk/metrics/view/registered_view.rb', line 13

def attribute_keys
  @attribute_keys
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/opentelemetry/sdk/metrics/view/registered_view.rb', line 13

def name
  @name
end

#regexObject (readonly)

Returns the value of attribute regex.



13
14
15
# File 'lib/opentelemetry/sdk/metrics/view/registered_view.rb', line 13

def regex
  @regex
end

Instance Method Details

#match_instrument?(metric_stream) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
32
# File 'lib/opentelemetry/sdk/metrics/view/registered_view.rb', line 24

def match_instrument?(metric_stream)
  return false if @name && !name_match(metric_stream.name)
  return false if @options[:type] && @options[:type] != metric_stream.instrument_kind
  return false if @options[:unit] && @options[:unit] != metric_stream.unit
  return false if @options[:meter_name] && @options[:meter_name] != metric_stream.instrumentation_scope.name
  return false if @options[:meter_version] && @options[:meter_version] != metric_stream.instrumentation_scope.version

  true
end

#name_match(stream_name) ⇒ Object



34
35
36
# File 'lib/opentelemetry/sdk/metrics/view/registered_view.rb', line 34

def name_match(stream_name)
  !!@regex&.match(stream_name)
end

#valid_aggregation?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/opentelemetry/sdk/metrics/view/registered_view.rb', line 38

def valid_aggregation?
  @aggregation.class.name.rpartition('::')[0] == 'OpenTelemetry::SDK::Metrics::Aggregation'
end