Skip to content

Commit d067071

Browse files
fix: Update max instrument length from 63 to 255 (#1883)
* fix: Update max instrument length from 63 to 255 The current specification states that the max instrument length is 255 chars: https://opentelemetry.io/docs/specs/otel/metrics/api/#instrument-name-syntax This commit updates the Ruby sdk to reflect this! * Update metrics_api/lib/opentelemetry/metrics/meter.rb Co-authored-by: Kayla Reopelle <[email protected]> * Update metrics_sdk/lib/opentelemetry/sdk/metrics/meter.rb Co-authored-by: Kayla Reopelle <[email protected]> * Update metrics_sdk/test/opentelemetry/sdk/metrics/meter_test.rb Co-authored-by: Kayla Reopelle <[email protected]> * Include forward slash in instrument name test * Use percent literal for regexes with forward slash * Remove redundant escape inside regex literal --------- Co-authored-by: Kayla Reopelle <[email protected]>
1 parent 6168e9c commit d067071

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

metrics_api/lib/opentelemetry/metrics/meter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Meter
1616
UP_DOWN_COUNTER = Instrument::UpDownCounter.new
1717
OBSERVABLE_UP_DOWN_COUNTER = Instrument::ObservableUpDownCounter.new
1818

19-
NAME_REGEX = /\A[a-zA-Z][-.\w]{0,62}\z/
19+
NAME_REGEX = %r{\A[a-zA-Z][-./\w]{0,254}\z}
2020

2121
private_constant(:COUNTER, :OBSERVABLE_COUNTER, :HISTOGRAM, :GAUGE, :OBSERVABLE_GAUGE, :UP_DOWN_COUNTER, :OBSERVABLE_UP_DOWN_COUNTER)
2222

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module SDK
1111
module Metrics
1212
# {Meter} is the SDK implementation of {OpenTelemetry::Metrics::Meter}.
1313
class Meter < OpenTelemetry::Metrics::Meter
14-
NAME_REGEX = /\A[a-zA-Z][-.\w]{0,62}\z/
14+
NAME_REGEX = %r{\A[a-zA-Z][-./\w]{0,254}\z}
1515

1616
# @api private
1717
#

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,14 @@
185185
_(-> { meter.create_counter('1_counter') }).must_raise(INSTRUMENT_NAME_ERROR)
186186
end
187187

188-
it 'instrument name must not exceed 63 character limit' do
189-
long_name = 'a' * 63
188+
it 'instrument name must not exceed 255 character limit' do
189+
long_name = 'a' * 255
190190
meter.create_counter(long_name)
191191
_(-> { meter.create_counter(long_name + 'a') }).must_raise(INSTRUMENT_NAME_ERROR)
192192
end
193193

194-
it 'instrument name must belong to alphanumeric characters, _, ., and -' do
195-
meter.create_counter('a_-..-_a')
194+
it 'instrument name must belong to alphanumeric characters, _, ., -, and /' do
195+
meter.create_counter('a_/-..-/_a')
196196
_(-> { meter.create_counter('a@') }).must_raise(INSTRUMENT_NAME_ERROR)
197197
_(-> { meter.create_counter('a!') }).must_raise(INSTRUMENT_NAME_ERROR)
198198
end

0 commit comments

Comments
 (0)