Skip to content

ISentryEventProcessor doesn't do anything for transactions #1468

Closed

Description

@seanarmstrong87

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

Activity

  1. lucas-zimerman commented on Feb 7, 2022

    @lucas-zimerman
    Collaborator

    Hi seanarmstrong87.
    Currently EventProcessors only are applied to events but not Transactions

  2. ccurrens commented on Mar 3, 2022

    @ccurrens

    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.

  3. bruno-garcia commented on Mar 3, 2022

    @bruno-garcia
    Member

    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).

  4. mattjohnsonpint commented on Apr 7, 2022

    @mattjohnsonpint
    Contributor

    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.

  5. mattjohnsonpint commented on Apr 7, 2022

    @mattjohnsonpint
    Contributor

    @bruno-garcia - Should there also be a BeforeSendTransaction option?

  6. mattjohnsonpint commented on Apr 8, 2022

    @mattjohnsonpint
    Contributor

    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.)

  7. added
    FeatureNew feature or request
    and removed
    QuestionFurther information is requested
    on May 4, 2022
  8. craigbehnke commented on Jul 17, 2022

    @craigbehnke

    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?

  9. mattjohnsonpint commented on Jul 18, 2022

    @mattjohnsonpint
    Contributor

    @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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions