Class: OpenTelemetry::SDK::Metrics::View::RegisteredView
- Inherits:
-
Object
- Object
- OpenTelemetry::SDK::Metrics::View::RegisteredView
- 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
-
#aggregation ⇒ Object
readonly
Returns the value of attribute aggregation.
-
#attribute_keys ⇒ Object
readonly
Returns the value of attribute attribute_keys.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#regex ⇒ Object
readonly
Returns the value of attribute regex.
Instance Method Summary collapse
-
#initialize(name, **options) ⇒ RegisteredView
constructor
A new instance of RegisteredView.
- #match_instrument?(metric_stream) ⇒ Boolean
- #name_match(stream_name) ⇒ Object
- #valid_aggregation? ⇒ Boolean
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, **) @name = name @options = @aggregation = [:aggregation] @attribute_keys = [:attribute_keys] || {} generate_regex_pattern(name) end |
Instance Attribute Details
#aggregation ⇒ Object (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_keys ⇒ Object (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 |
#name ⇒ Object (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 |
#regex ⇒ Object (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
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
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 |