Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@sentry/nestjs SentryTraced decorator does not retain metadata #14384

Open
3 tasks done
nathan-knight opened this issue Nov 20, 2024 · 1 comment
Open
3 tasks done

@sentry/nestjs SentryTraced decorator does not retain metadata #14384

nathan-knight opened this issue Nov 20, 2024 · 1 comment
Assignees
Labels
Package: nestjs Issues related to the Sentry Nestjs SDK

Comments

@nathan-knight
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nestjs

SDK Version

8.38.0

Framework Version

NestJS 10.4.2

Link to Sentry event

No response

Reproduction Example/SDK Setup

No response

Steps to Reproduce

If you apply the SentryTraced decorator to a function, it replaces it with a new function that retains the name of the original function but does not copy over the metadata using reflect-metadata that may have been applied by another decorator (which is a common pattern in NestJS) such as SetMetadata from @nestjs/common.

Expected Result

After the decorator assigns decorator.value, it should do something like:

const metadataKeys = Reflect.getMetadataKeys(originalMethod);
for (const metadataKey of metadataKeys) {
    const value = Reflect.getMetadata(metadataKey, originalMethod);
    Reflect.defineMetadata(metadataKey, value, descriptor.value);
}

I have applied a patch to get things working for us that does exactly this

Actual Result

It does not copy the metadata so other functionality that relies on it breaks.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Nov 20, 2024
@github-actions github-actions bot added the Package: nestjs Issues related to the Sentry Nestjs SDK label Nov 20, 2024
@andreiborza
Copy link
Member

Hi @nathan-knight, thanks for taking the time to file this.

Would you like to contribute this? No pressure, we can also take care of this on our end.

cc @chargome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nestjs Issues related to the Sentry Nestjs SDK
Projects
Status: No status
Development

No branches or pull requests

3 participants