Skip to content

Commit 8cb03d6

Browse files
sergicalclaude
andauthored
feat(deno): Export metrics API from Deno SDK (#19305)
## Summary - Add `metrics` to the `@sentry/core` re-export block in `packages/deno/src/index.ts` - The `metrics` namespace is already exported from `@sentry/core` and re-exported by `@sentry/node`, but was missing from the Deno SDK ## Test plan - [x] `yarn build:dev:filter @sentry/deno` passes - [x] `cd packages/deno && yarn test` — all 12 tests pass - [x] `eslint src/index.ts` — no lint issues 🤖 Generated with [Claude Code](https://claude.com/claude-code) Closes #19307 (added automatically) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c7614d1 commit 8cb03d6

File tree

4 files changed

+46
-3
lines changed

4 files changed

+46
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ tmp.js
5454
packages/deno/build-types
5555
packages/deno/build-test
5656
packages/deno/lib.deno.d.ts
57+
deno.lock
5758

5859
# gatsby
5960
packages/gatsby/gatsby-node.d.ts

codecov.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ coverage:
1414
patch:
1515
default:
1616
enabled: no
17+
18+
ignore:
19+
- 'packages/deno/**'

packages/deno/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export type {
22
Breadcrumb,
33
BreadcrumbHint,
4+
Metric,
45
PolymorphicRequest,
56
RequestEventData,
67
SdkInfo,
@@ -89,6 +90,7 @@ export {
8990
updateSpanName,
9091
wrapMcpServerWithSentry,
9192
featureFlagsIntegration,
93+
metrics,
9294
} from '@sentry/core';
9395

9496
export { DenoClient } from './client';

packages/deno/test/mod.test.ts

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { Event } from '@sentry/core';
2-
import { createStackParser, nodeStackLineParser } from '@sentry/core';
1+
import type { Envelope, Event } from '@sentry/core';
2+
import { createStackParser, forEachEnvelopeItem, nodeStackLineParser } from '@sentry/core';
33
import { assertEquals } from 'https://deno.land/std@0.202.0/assert/assert_equals.ts';
44
import { assertSnapshot } from 'https://deno.land/std@0.202.0/testing/snapshot.ts';
5-
import { DenoClient, getCurrentScope, getDefaultIntegrations } from '../build/esm/index.js';
5+
import { DenoClient, getCurrentScope, getDefaultIntegrations, metrics, Scope } from '../build/esm/index.js';
66
import { getNormalizedEvent } from './normalize.ts';
77
import { makeTestTransport } from './transport.ts';
88

@@ -74,6 +74,43 @@ Deno.test('captureMessage twice', async t => {
7474
await assertSnapshot(t, ev);
7575
});
7676

77+
Deno.test('metrics.count captures a counter metric', async () => {
78+
const envelopes: Array<Envelope> = [];
79+
const client = new DenoClient({
80+
dsn: 'https://233a45e5efe34c47a3536797ce15dafa@nothing.here/5650507',
81+
integrations: getDefaultIntegrations({}),
82+
stackParser: createStackParser(nodeStackLineParser()),
83+
transport: makeTestTransport(envelope => {
84+
envelopes.push(envelope);
85+
}),
86+
});
87+
88+
client.init();
89+
const scope = new Scope();
90+
scope.setClient(client);
91+
92+
metrics.count('test.counter', 5, { scope });
93+
94+
await client.flush(2000);
95+
96+
// deno-lint-ignore no-explicit-any
97+
let metricItem: any = undefined;
98+
for (const envelope of envelopes) {
99+
forEachEnvelopeItem(envelope, item => {
100+
const [headers, body] = item;
101+
if (headers.type === 'trace_metric') {
102+
metricItem = body;
103+
}
104+
});
105+
}
106+
107+
assertEquals(metricItem !== undefined, true);
108+
assertEquals(metricItem.items.length, 1);
109+
assertEquals(metricItem.items[0].name, 'test.counter');
110+
assertEquals(metricItem.items[0].type, 'counter');
111+
assertEquals(metricItem.items[0].value, 5);
112+
});
113+
77114
Deno.test('App runs without errors', async _ => {
78115
const cmd = new Deno.Command('deno', {
79116
args: ['run', '--allow-net=some-domain.com', './test/example.ts'],

0 commit comments

Comments
 (0)