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
I ended filtering it by the logger tag
builder.AddSentry(options => {
options.SetBeforeSend((sentryEvent, hint) =>
{
if (sentryEvent.Logger == "Elastic.Apm")
{
return null;
}
return sentryEvent;
});
});