Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ tmp.js
packages/deno/build-types
packages/deno/build-test
packages/deno/lib.deno.d.ts
deno.lock

# gatsby
packages/gatsby/gatsby-node.d.ts
Expand Down
3 changes: 3 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ coverage:
patch:
default:
enabled: no

ignore:
- 'packages/deno/**'
2 changes: 2 additions & 0 deletions packages/deno/src/index.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m: Please also export the according Metric type here

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export type {
Breadcrumb,
BreadcrumbHint,
Metric,
PolymorphicRequest,
RequestEventData,
SdkInfo,
Expand Down Expand Up @@ -89,6 +90,7 @@ export {
updateSpanName,
wrapMcpServerWithSentry,
featureFlagsIntegration,
metrics,
} from '@sentry/core';

export { DenoClient } from './client';
Expand Down
43 changes: 40 additions & 3 deletions packages/deno/test/mod.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Event } from '@sentry/core';
import { createStackParser, nodeStackLineParser } from '@sentry/core';
import type { Envelope, Event } from '@sentry/core';
import { createStackParser, forEachEnvelopeItem, nodeStackLineParser } from '@sentry/core';
import { assertEquals } from 'https://deno.land/std@0.202.0/assert/assert_equals.ts';
import { assertSnapshot } from 'https://deno.land/std@0.202.0/testing/snapshot.ts';
import { DenoClient, getCurrentScope, getDefaultIntegrations } from '../build/esm/index.js';
import { DenoClient, getCurrentScope, getDefaultIntegrations, metrics, Scope } from '../build/esm/index.js';
import { getNormalizedEvent } from './normalize.ts';
import { makeTestTransport } from './transport.ts';

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

Deno.test('metrics.count captures a counter metric', async () => {
const envelopes: Array<Envelope> = [];
const client = new DenoClient({
dsn: 'https://233a45e5efe34c47a3536797ce15dafa@nothing.here/5650507',
integrations: getDefaultIntegrations({}),
stackParser: createStackParser(nodeStackLineParser()),
transport: makeTestTransport(envelope => {
envelopes.push(envelope);
}),
});

client.init();
const scope = new Scope();
scope.setClient(client);

metrics.count('test.counter', 5, { scope });

await client.flush(2000);

// deno-lint-ignore no-explicit-any
let metricItem: any = undefined;
for (const envelope of envelopes) {
forEachEnvelopeItem(envelope, item => {
const [headers, body] = item;
if (headers.type === 'trace_metric') {
metricItem = body;
}
});
}

assertEquals(metricItem !== undefined, true);
assertEquals(metricItem.items.length, 1);
assertEquals(metricItem.items[0].name, 'test.counter');
assertEquals(metricItem.items[0].type, 'counter');
assertEquals(metricItem.items[0].value, 5);
});

Deno.test('App runs without errors', async _ => {
const cmd = new Deno.Command('deno', {
args: ['run', '--allow-net=some-domain.com', './test/example.ts'],
Expand Down
Loading