Skip to content

Commit

Permalink
fix(sdk-metrics): allow instrument names to contain '/' (#4155)
Browse files Browse the repository at this point in the history
  • Loading branch information
aabmass authored Sep 21, 2023
1 parent 1a8652a commit f2fc0d8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/

### :bug: (Bug Fix)

* fix(sdk-metrics): allow instrument names to contain '/' [#4155](https://github.com/open-telemetry/opentelemetry-js/pull/4155)

### :books: (Refine Doc)

### :house: (Internal)
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-metrics/src/InstrumentDescriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function isDescriptorCompatibleWith(

// ASCII string with a length no greater than 255 characters.
// NB: the first character counted separately from the rest.
const NAME_REGEXP = /^[a-z][a-z0-9_.-]{0,254}$/i;
const NAME_REGEXP = /^[a-z][a-z0-9_.\-/]{0,254}$/i;
export function isValidName(name: string): boolean {
return name.match(NAME_REGEXP) != null;
}
10 changes: 9 additions & 1 deletion packages/sdk-metrics/test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ export const defaultInstrumentationScope: InstrumentationScope = {
};

export const invalidNames = ['', 'a'.repeat(256), '1a', '-a', '.a', '_a'];
export const validNames = ['a', 'a'.repeat(255), 'a1', 'a-1', 'a.1', 'a_1'];
export const validNames = [
'a',
'a'.repeat(255),
'a1',
'a-1',
'a.1',
'a_1',
'a/1',
];

export const commonValues: number[] = [1, -1, 1.0, Infinity, -Infinity, NaN];
export const commonAttributes: MetricAttributes[] = [
Expand Down

0 comments on commit f2fc0d8

Please sign in to comment.