Skip to content

Commit 05093f8

Browse files
committed
add metric > scope precedence test
1 parent 8124f8f commit 05093f8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/core/test/lib/metrics/internal.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,24 @@ describe('_INTERNAL_captureMetric', () => {
199199
});
200200
});
201201

202+
it('prefers metric attributes over scope attributes', () => {
203+
const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN });
204+
const client = new TestClient(options);
205+
const scope = new Scope();
206+
scope.setClient(client);
207+
scope.setAttribute('my-attribute', 42);
208+
209+
_INTERNAL_captureMetric(
210+
{ type: 'counter', name: 'test.metric', value: 1, attributes: { 'my-attribute': 43 } },
211+
{ scope },
212+
);
213+
214+
const metricAttributes = _INTERNAL_getMetricBuffer(client)?.[0]?.attributes;
215+
expect(metricAttributes).toEqual({
216+
'my-attribute': { value: 43, type: 'integer' },
217+
});
218+
});
219+
202220
it('flushes metrics buffer when it reaches max size', () => {
203221
const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN });
204222
const client = new TestClient(options);

0 commit comments

Comments
 (0)