fix(sdk-metrics-base): metrics name should be in the max length of 63 (#2495)
Co-authored-by: Bartlomiej Obecny <bobecny@gmail.com> Co-authored-by: Valentin Marchaud <contact@vmarchaud.fr>
This commit is contained in:
parent
faca317da1
commit
ed0ba063ae
|
|
@ -350,6 +350,6 @@ export class Meter implements api.Meter {
|
|||
* @param name Name of metric to be created
|
||||
*/
|
||||
private _isValidName(name: string): boolean {
|
||||
return Boolean(name.match(/^[a-z][a-z0-9_.-]*$/i));
|
||||
return Boolean(name.match(/^[a-z][a-z0-9_.-]{0,62}$/i));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,6 +295,13 @@ describe('Meter', () => {
|
|||
const counter = meter.createCounter('name with invalid characters^&*(');
|
||||
assert.ok(counter instanceof api.NoopMetric);
|
||||
});
|
||||
|
||||
it('should return no op metric if name exceeded length of 63', () => {
|
||||
const counter = meter.createCounter('a'.repeat(63));
|
||||
assert.ok(counter instanceof CounterMetric);
|
||||
const counter2 = meter.createCounter('a'.repeat(64));
|
||||
assert.ok(counter2 instanceof api.NoopMetric);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue