-
-
Notifications
You must be signed in to change notification settings - Fork 213
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
Filtering topmost Activities via Processor is not respected by Sentry Exporter #3887
Comments
Possibly |
Hi @CezaryKlus , Thanks for the detailed report. What you're saying makes sense, and yet I'm not able to reproduce this. I've got a much simpler filter than yours: internal sealed class FilteringProcessor : BaseProcessor<Activity>
{
// Filters out some activities
public override void OnEnd(Activity activity)
{
// If the activity does not have a parent that matches the specified kinds or tags, mark it as not recorded
if (activity.Tags.Any(t => t is { Key: "Answer", Value: "unknown" }))
{
Console.WriteLine($"Filtering out activity: {activity.OperationName} {activity.DisplayName}");
activity.ActivityTraceFlags &= ~ActivityTraceFlags.Recorded;
activity.IsAllDataRequested = false;
}
}
} And I'm using this in the Otel sample that we provide: using (var activity = activitySource.StartActivity("Main"))
{
// This creates a span called "Task 1" within the transaction
using (var task = activitySource.StartActivity("Task 1"))
{
task?.SetTag("Answer", 42);
Thread.Sleep(100); // simulate some work
Console.WriteLine("Task 1 completed");
task?.SetStatus(Status.Ok);
}
// This creates a span called "Task 2" within the transaction
using (var task = activitySource.StartActivity("Task 2"))
{
task?.SetTag("Answer", "unknown");
Thread.Sleep(100); // simulate some work
Console.WriteLine("Task 2 completed");
task?.SetStatus(Status.Ok);
}
// Since we use `AddHttpClientInstrumentation` when initializing OpenTelemetry, the following Http request will also
// be captured as a Sentry span
var httpClient = new HttpClient();
var html = await httpClient.GetStringAsync("https://example.com/");
Console.WriteLine(html);
} The filtered trace is correctly being removed from the traceview in Sentry: ![]() Or are you not using Sentry to view the resulting traces? Are you viewing the traces somewhere else? |
@jamescrosswell thanks for the feedback. I should have been more precise. I am trying to filter out the Activities coming from some background ASP.NET Core processes that are not related to e.g. any HTTP request. And these are definitely the ones that I filter. So maybe in your example, the attempt to reproduce would be to try to filter out the Main activity. |
Hi @CezaryKlus, OK, that I can reproduce. We can tweak the SentrySpanProcessor to filter these spans out. As a workaround, in the short term, you could use Sentry's BeforeSendTransaction hook to prevent these transactions from being sent to Sentry. |
Package
Sentry
.NET Flavor
.NET
.NET Version
8.0.0
OS
Linux
SDK Version
5.0.1
Self-Hosted Sentry Version
No response
Steps to Reproduce
Filtering out activity
debug messages in the consoleExpected Result
Sentry Exporter respects the
ActivityTraceFlags
and is not transmitting topmost Activities that are flagged as notRecorded
Actual Result
Sentry still reports these filtered Activities
The text was updated successfully, but these errors were encountered: