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

feat: add SentryIsolationScope decorator #14845

Open
feelgood1987 opened this issue Dec 27, 2024 · 4 comments
Open

feat: add SentryIsolationScope decorator #14845

feelgood1987 opened this issue Dec 27, 2024 · 4 comments
Labels
Package: nestjs Issues related to the Sentry Nestjs SDK

Comments

@feelgood1987
Copy link

feelgood1987 commented Dec 27, 2024

Problem Statement

Add a new decorator, SentryIsolationScope, to create and apply an isolation scope to the relevant method.
Similar to the SentryCron or SentryTrace decorators, this would be useful in situations where we don't have HTTP requests but still need an isolation scope.
For instance, in our case, some MQ event consumers subscribe to a message broker like RabbitMQ. In such cases, there are no HTTP requests, so every Sentry.getIsolationScope call targets the global scope.
Having a decorator to create and assign an isolation scope to these functions would be a great feature for such use cases.

Solution Brainstorm

I've looked for a similar feature but unfortunately couldn't find any, so I've created this issue

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 27, 2024
@feelgood1987 feelgood1987 changed the title feat: add SentryIsolationScope decorator feat: add SentryIsolationScope decorator Dec 27, 2024
@chargome chargome added the Package: nestjs Issues related to the Sentry Nestjs SDK label Dec 27, 2024
@chargome
Copy link
Member

@feelgood1987 thanks for the suggestion. You could make use of withScope or withIsolationScope wherever you need it – is there an advantage of putting that into a separate decorator for you?

@feelgood1987
Copy link
Author

@feelgood1987 thanks for the suggestion. You could make use of withScope or withIsolationScope wherever you need it – is there an advantage of putting that into a separate decorator for you?

Will those methods work with non-HTTP requests, actually the service is a message-broker subscriber, and since I could understand from the documentation, that those methods, create scope based on an HTTP request, in our case, there be no HTTP request, will withIsolationScope work for this sort of issues?

The reason, we've suggested having this new decorator, is the similar nature of the issue to something like SentryCron

@chargome
Copy link
Member

Yeah this should not be http related. As for the decorator I would not see any benefit from it as it would not abstract any logic from the original withScope or withIsolationScope methods – so I would lean towards not implementing it tbh.

@feelgood1987
Copy link
Author

Yeah this should not be http related. As for the decorator, I would not see any benefit from it as it would not abstract any logic from the original withScope or withIsolationScope methods – so I would lean towards not implementing it tbh.

As you've described, using withScope or withIsolationScope will definitely work for us. Thank you for your help!
However, we could consider the following benefits of having a dedicated decorator:

  • Eliminating Redundant Code:
    • A decorator would prevent the need for extra code in non-HTTP functions where we have to manually initialize the scope each time.
  • Reducing Developer Confusion:
    • For HTTP requests, we typically rely on getIsolationScope by default. However, for non-HTTP scenarios, it might not be immediately clear to developers whether they need to create a new scope or not. A decorator would simplify this by standardizing scope creation, making it more intuitive.

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

2 participants