From 9b081e19339dd636f5b37e72987cdf4f2a198532 Mon Sep 17 00:00:00 2001 From: jason plumb <75337021+breedx-splk@users.noreply.github.com> Date: Fri, 15 Sep 2023 13:15:35 -0700 Subject: [PATCH] Allow instrument names to contain a forward slash (#5824) --- .../src/main/java/io/opentelemetry/sdk/metrics/SdkMeter.java | 4 ++-- .../test/java/io/opentelemetry/sdk/metrics/SdkMeterTest.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeter.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeter.java index 5b36cef4e87..02eb45a26ff 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeter.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/SdkMeter.java @@ -42,12 +42,12 @@ final class SdkMeter implements Meter { *
  • They are not null or empty strings. *
  • They are case-insensitive, ASCII strings. *
  • The first character must be an alphabetic character. - *
  • Subsequent characters must belong to the alphanumeric characters, '_', '.', and '-'. + *
  • Subsequent characters must belong to the alphanumeric characters, '_', '.', '/', and '-'. *
  • They can have a maximum length of 255 characters. * */ private static final Pattern VALID_INSTRUMENT_NAME_PATTERN = - Pattern.compile("([A-Za-z]){1}([A-Za-z0-9\\_\\-\\.]){0,254}"); + Pattern.compile("([A-Za-z]){1}([A-Za-z0-9\\_\\-\\./]){0,254}"); private static final Meter NOOP_METER = MeterProvider.noop().get("noop"); private static final String NOOP_INSTRUMENT_NAME = "noop"; diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/SdkMeterTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/SdkMeterTest.java index 8cf501da64b..4bc44bf46cb 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/SdkMeterTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/SdkMeterTest.java @@ -110,6 +110,7 @@ void checkValidInstrumentNameTest() { assertThat(checkValidInstrumentName("a1234567890")).isTrue(); assertThat(checkValidInstrumentName("a_-.")).isTrue(); assertThat(checkValidInstrumentName(new String(new char[255]).replace('\0', 'a'))).isTrue(); + assertThat(checkValidInstrumentName("a/b")).isTrue(); // Empty and null not allowed assertThat(checkValidInstrumentName(null)).isFalse();