Skip to content

Commit 1eb8846

Browse files
committed
fix(nestjs): Add missing sentry.origin span attribute to SentryTraced decorator
1 parent 7264677 commit 1eb8846

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/nestjs/src/decorators.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import type { MonitorConfig } from '@sentry/core';
2-
import { captureException, isThenable } from '@sentry/core';
2+
import {
3+
captureException,
4+
isThenable,
5+
SEMANTIC_ATTRIBUTE_SENTRY_OP,
6+
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
7+
} from '@sentry/core';
38
import * as Sentry from '@sentry/node';
49
import { startSpan } from '@sentry/node';
510
import { isExpectedError } from './helpers';
@@ -52,6 +57,10 @@ export function SentryTraced(op: string = 'function') {
5257
{
5358
op: op,
5459
name: propertyKey,
60+
attributes: {
61+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nestjs.sentry_traced',
62+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,
63+
},
5564
},
5665
() => {
5766
return originalMethod.apply(this, args);

packages/nestjs/test/decorators.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'reflect-metadata';
22
import * as core from '@sentry/core';
3+
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
34
import { beforeEach, describe, expect, it, vi } from 'vitest';
45
import { SentryCron, SentryExceptionCaptured, SentryTraced } from '../src/decorators';
56
import * as helpers from '../src/helpers';
@@ -96,6 +97,10 @@ describe('SentryTraced decorator', () => {
9697
{
9798
op: 'sync-operation',
9899
name: 'syncMethod',
100+
attributes: {
101+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nestjs.sentry_traced',
102+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'sync-operation',
103+
},
99104
},
100105
expect.any(Function),
101106
);

0 commit comments

Comments
 (0)