skip to Main Content

In my ASP.NET app, we are using sentry to log errors, but we want to filter all the APM messages.

I was intending to filter it using the following approaches:

options.SetBeforeSendTransaction((sentryTransaction, hint) =>
{ 
    if (sentryTransaction // somehow look here if it's APM related)
    {
        return null; // Drop the transaction by returning null
    }

    return sentryTransaction;
});

or

options.SetBeforeSend((sentryEvent, hint) =>
{
    if (sentryEvent //somehow look here if it's APM related) )
    {
        return null; // Don't send this event to Sentry
    }

    sentryEvent.ServerName = null; // Never send Server Name to Sentry
    return sentryEvent;
});

Problem is I couldn’t find a way to check if it’s apm.

I would look for event type and check if it’s a transaction, but IDK if it’s enough, and the sentryEvent doesn’t contain a type property.

Can someone help me find a way? Thanks

2

Answers


  1. Chosen as BEST ANSWER

    I ended filtering it by the logger tag

    builder.AddSentry(options => {
        options.SetBeforeSend((sentryEvent, hint) =>
        {
                if (sentryEvent.Logger == "Elastic.Apm")
                {
                        return null;
                }
                return sentryEvent;
        });
    });
    

  2. You can set options.TracesSampleRate = 0
    or don’t set this value at all since default is 0

    Make sure EnableTracing is also set to false. Not a great name for the option but it in essence enables performance monitoring too.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search