Replies: 2 comments
-
I'm assuming you're using AspNetCore instrumentation package. If yes, you could use the .AddAspNetCoreInstrumentation(options =>
{
options.EnrichWithHttpResponse = (activity, response) =>
{
if (response.StatusCode < 500)
{
if (Random.Shared.Next(0, 100) >= 10)
{
activity.IsAllDataRequested = false;
activity.ActivityTraceFlags &= ~ActivityTraceFlags.Recorded;
}
}
};
}); Note: This is different from sampling in that it does not prevent an activity from being created. You would just be marking an activity (that's already created) to not be recorded. |
Beta Was this translation helpful? Give feedback.
-
No. OpenTelemetry sampling is head-based, so sampling decision is taken at the beginning of the Span, and can only leverage information available at that time. Things like "Status", "Success", etc. are not available when a Span starts, so they cannot be leveraged by OTel sampler. Apart from the suggestion to leverage Instrumentation Library's capabilities, also consider : https://github.com/open-telemetry/opentelemetry-dotnet/tree/main/docs/trace/tail-based-sampling-span-level. There is also the option to use tail-sampler in OTel Collector. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to record all failed requests (status code=500). For other requests, sampling rate is 10%.
In Application Insight, we implement by this code:
Beta Was this translation helpful? Give feedback.
All reactions