Skip to content

Commit

Permalink
feat(host-metrics)!: use the package name as the default instrumentat…
Browse files Browse the repository at this point in the history
…ion scope name, to align with instrumentations (open-telemetry#1822)

Closes: open-telemetry#1782
  • Loading branch information
trentm authored Dec 7, 2023
1 parent 4782f5b commit bcf3501
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/opentelemetry-host-metrics/src/BaseMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface MetricsCollectorConfig {
url?: string;
}

const DEFAULT_NAME = 'opentelemetry-host-metrics';
const DEFAULT_NAME = '@opentelemetry/host-metrics';

/**
* Base Class for metrics
Expand Down
8 changes: 7 additions & 1 deletion packages/opentelemetry-host-metrics/test/metric.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ describe('Host Metrics', () => {

hostMetrics = new HostMetrics({
meterProvider,
name: 'opentelemetry-host-metrics',
name: '', // to get default instrumentation scope name
});

await hostMetrics.start();

const dateStub = sandbox
Expand Down Expand Up @@ -341,6 +342,11 @@ async function getRecords(
assert(collectionResult != null);
assert.strictEqual(collectionResult.resourceMetrics.scopeMetrics.length, 1);
const scopeMetrics = collectionResult.resourceMetrics.scopeMetrics[0];
assert.strictEqual(
scopeMetrics.scope.name,
'@opentelemetry/host-metrics',
'default instrumentation scope name is the package name'
);
const metricDataList = scopeMetrics.metrics.filter(
metric => metric.descriptor.name === name
);
Expand Down

0 comments on commit bcf3501

Please sign in to comment.