fix(sdk-metrics): fix duplicated registration of metrics for collectors (#3488)

This commit is contained in:
Chengzhong Wu 2023-01-03 23:32:29 +08:00 committed by GitHub
parent 93222fc65a
commit 3fd6fb8a8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -23,6 +23,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
* `telemetry.sdk.language`
* `telemetry.sdk.version`
* fix(selenium-tests): updated webpack version for selenium test issue [#3456](https://github.com/open-telemetry/opentelemetry-js/issues/3456) @SaumyaBhushan
* fix(sdk-metrics): fix duplicated registration of metrics for collectors [#3488](https://github.com/open-telemetry/opentelemetry-js/pull/3488) @legendecas
### :books: (Refine Doc)

View File

@ -96,7 +96,7 @@ export class MetricStorageRegistry {
return null;
}
const storages = this._sharedRegistry.get(expectedDescriptor.name);
const storages = storageMap.get(expectedDescriptor.name);
if (storages === undefined) {
return null;
}

View File

@ -401,7 +401,22 @@ describe('MetricStorageRegistry', () => {
// registered the storage for each collector
assert.deepStrictEqual(registry.getStorages(collectorHandle), [storage]);
assert.strictEqual(
registry.findOrUpdateCompatibleCollectorStorage(
collectorHandle,
descriptor
),
storage
);
assert.deepStrictEqual(registry.getStorages(collectorHandle2), [storage]);
assert.strictEqual(
registry.findOrUpdateCompatibleCollectorStorage(
collectorHandle2,
descriptor
),
storage
);
});
});
});