sentry-dotnet
sentry-dotnet copied to clipboard
ISentryEventProcessor doesn't do anything for transactions
Environment
How do you use Sentry? Sentry SaaS (sentry.io)
Which SDK and version? Sentry.AspNetCore 3.13 used in dotnetcoreapp2.2 API project
Steps to Reproduce
I created an ISentryEventProcessor like the example one
public class ExampleEventProcessor : ISentryEventProcessor
{
private readonly IHttpContextAccessor _httpContext;
public ExampleEventProcessor(IHttpContextAccessor httpContext) => _httpContext = httpContext;
public SentryEvent Process(SentryEvent @event)
{
// Here I can modify the event, while taking dependencies via DI
@event.SetExtra("Response:HasStarted", _httpContext.HttpContext?.Response.HasStarted);
return @event;
}
}
Registered in my Startup.cs like so
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient<ISentryEventProcessor, ExampleEventProcessor>();
...
When I call and endpoint I see the transaction in Sentry but breakpoints in the EventProcessor are never triggered and it doesn't run.
I would like to use this to override properties of the event.
What am I doing wrong?
Expected Result
EventProcessor is triggered for a transaction when I call an endpoint in the API
Actual Result
Nothing happened
Hi seanarmstrong87. Currently EventProcessors only are applied to events but not Transactions
Is there a way to filter data from a transaction? I thought both BeforeSend and ISentryEventProcessor may work, but neither does. Right now, the SDK includes all environment variables and authentication cookies when publishing transactions, both of which include sensitive/secret data.
It seems the javascript SDK has support for globalEventProcessor, but I can't find an equivalent in the .NET SDK.
We haven't added a hook to drop transaction other than the TracesSampler callback which happens at the start of the transaction.
In Java we used default interface method so it wasn't a breaking change: https://github.com/getsentry/sentry-java/blob/4afe30c18e7f13d53d5b17afd7d7925351d14a8b/sentry/src/main/java/io/sentry/EventProcessor.java#L32-L33
But we can't use that in .NET while maintaining backwards compat with .NET 4x and old .NET Core versions.
We could add a new interface for processing transactions, or bump a major and add a new overload that takes Transaction to the current IEventProcessor interface (which is my preference).
I think I'd rather implement a new interface, ISentryTransactionProcessor. The other approach mentioned would require all event processors to also process transactions, which shouldn't be necessary in all cases, IMHO.
@bruno-garcia - Should there also be a BeforeSendTransaction option?
Also, it would appear transactions don't participate in a scope. Should they? (Event Processors and Exception Processors can both be set on a scope.)
This should probably be added to the documentation in the interim so that users know about this limitation -- until I found this issue, I had spent a few hours trying to get this to work and thought I was doing something wrong.
Just to throw in my 2 cents, having this functionality would let me anonymize users and IP addresses to enhance user privacy while still being able to get affected user counts and rough GeoIP data.
Is there another way to do filtering on everything (including transactions) that is currently available in the SDK?
@craigbehnke - Unfortunately there's currently no way to do filtering globally either. We need to rethink this for the next large set of breaking changes (4.x release), but that is an end-of-year goal.
In the shorter term, we can add transaction processors without breaking anything. Look for it in the upcoming 3.20.0 or 3.21.0 releases (likely within the next few weeks).