Skip to content

Commit

Permalink
fix: log an error instead of throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 committed Oct 31, 2019
1 parent d7c09fc commit 00115df
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/opentelemetry-metrics/src/Meter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ export class Meter implements types.Meter {
metric: Metric<T>
): void {
if (this._metrics.has(name)) {
throw new Error(
this._logger.error(
`A metric with the name ${name} has already been registered.`
);
return;
}
this._metrics.set(name, metric);
}
Expand Down
7 changes: 0 additions & 7 deletions packages/opentelemetry-metrics/test/Meter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ describe('Meter', () => {
assert.ok(counter instanceof Metric);
});

it('should throw an error when create the same metric', () => {
meter.createCounter('test_metric');
assert.throws(() => {
meter.createCounter('test_metric');
}, /^Error: A metric with the name test_metric has already been registered.$/);
});

describe('.getHandle()', () => {
it('should create a counter handle', () => {
const counter = meter.createCounter('name') as CounterMetric;
Expand Down

0 comments on commit 00115df

Please sign in to comment.