Skip to content

Commit ed4ceca

Browse files
committed
Revert "feat: Use an empty frozen hash as default advice"
This reverts commit d2318b0.
1 parent d2318b0 commit ed4ceca

File tree

6 files changed

+7
-9
lines changed

6 files changed

+7
-9
lines changed

metrics_api/lib/opentelemetry/internal/proxy_instrument.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module OpenTelemetry
88
module Internal
99
# @api private
1010
class ProxyInstrument
11-
def initialize(kind, name, unit, desc, callable, advice = Metrics::Meter::EMPTY_ADVICE)
11+
def initialize(kind, name, unit, desc, callable, advice = nil)
1212
@kind = kind
1313
@name = name
1414
@unit = unit

metrics_api/lib/opentelemetry/metrics/meter.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ class Meter
1515
UP_DOWN_COUNTER = Instrument::UpDownCounter.new
1616
OBSERVABLE_UP_DOWN_COUNTER = Instrument::ObservableUpDownCounter.new
1717

18-
EMPTY_ADVICE = {}.freeze
19-
2018
NAME_REGEX = /\A[a-zA-Z][-.\w]{0,62}\z/
2119

2220
private_constant(:COUNTER, :OBSERVABLE_COUNTER, :HISTOGRAM, :OBSERVABLE_GAUGE, :UP_DOWN_COUNTER, :OBSERVABLE_UP_DOWN_COUNTER)
@@ -35,7 +33,7 @@ def create_counter(name, unit: nil, description: nil)
3533
create_instrument(:counter, name, unit, description, nil) { COUNTER }
3634
end
3735

38-
def create_histogram(name, unit: nil, description: nil, advice: EMPTY_ADVICE)
36+
def create_histogram(name, unit: nil, description: nil, advice: nil)
3937
create_instrument(:histogram, name, unit, description, nil, advice) { HISTOGRAM }
4038
end
4139

@@ -57,7 +55,7 @@ def create_observable_up_down_counter(name, callback:, unit: nil, description: n
5755

5856
private
5957

60-
def create_instrument(kind, name, unit, description, callback, advice = EMPTY_ADVICE)
58+
def create_instrument(kind, name, unit, description, callback, advice = nil)
6159
raise InstrumentNameError if name.nil?
6260
raise InstrumentNameError if name.empty?
6361
raise InstrumentNameError unless NAME_REGEX.match?(name)

metrics_sdk/lib/opentelemetry/sdk/metrics/instrument/histogram.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Metrics
1010
module Instrument
1111
# {Histogram} is the SDK implementation of {OpenTelemetry::Metrics::Histogram}.
1212
class Histogram < OpenTelemetry::SDK::Metrics::Instrument::SynchronousInstrument
13-
def initialize(name, unit, description, instrumentation_scope, meter_provider, advice = OpenTelemetry::Metrics::Meter::EMPTY_ADVICE)
13+
def initialize(name, unit, description, instrumentation_scope, meter_provider, advice = nil)
1414
@advice = advice
1515

1616
super

metrics_sdk/lib/opentelemetry/sdk/metrics/instrument/synchronous_instrument.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module Instrument
1111
# {SynchronousInstrument} contains the common functionality shared across
1212
# the synchronous instruments SDK instruments.
1313
class SynchronousInstrument
14-
def initialize(name, unit, description, instrumentation_scope, meter_provider, advice = OpenTelemetry::Metrics::Meter::EMPTY_ADVICE)
14+
def initialize(name, unit, description, instrumentation_scope, meter_provider, advice = nil)
1515
@name = name
1616
@unit = unit
1717
@description = description

metrics_sdk/lib/opentelemetry/sdk/metrics/meter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def add_metric_reader(metric_reader)
3333
end
3434
end
3535

36-
def create_instrument(kind, name, unit, description, callback, advice = OpenTelemetry::Metrics::Meter::EMPTY_ADVICE)
36+
def create_instrument(kind, name, unit, description, callback, advice = nil)
3737
super do
3838
case kind
3939
when :counter then OpenTelemetry::SDK::Metrics::Instrument::Counter.new(name, unit, description, @instrumentation_scope, @meter_provider)

metrics_sdk/test/opentelemetry/sdk/metrics/meter_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
it 'does not require advice' do
3535
instrument = meter.create_histogram('histogram', description: 'stuff', unit: 'things')
3636

37-
assert_equal({}, instrument.instance_variable_get(:@advice))
37+
assert_nil instrument.instance_variable_get(:@advice)
3838
end
3939
end
4040

0 commit comments

Comments
 (0)