[feature request] Filter at end of activity #2464
Labels
comp:instrumentation.aspnetcore
Things related to OpenTelemetry.Instrumentation.AspNetCore
enhancement
New feature or request
Component
OpenTelemetry.Instrumentation.AspNetCore
Is your feature request related to a problem?
I'd like the ability to be able to filter logged items based on the status code of the HTTP Response.
What is the expected behavior?
At the end of the activity processing have a filter that is able to exclude items. Similar to the filter that is applied at the start of the activity.
Which alternative solutions or features have you considered?
The goal is to drop any logging for a request to a specific endpoint with a certain status code
e.g. anything sent to / with a 401 response code.
So I call UseAzureMonitor
And added a processor
Which when hooked up partially worked, it removes the dependencies of the request but the parent request was still getting logged in the requests table in application insights.
After a bit more digging I found you can add a filter to the AddAspNetCoreInstrumentation call but as we're calling UseAzureMonitor we need to call configure using AspNetCoreTraceInstrumentationOptions
The problem is the StatusCode is 200 and not 401, I'm assuming because the logging/filter fires before the authentication middleware has kicked in as the filter runs in OnStartActivity in HttpInListener.
Is there a filter that fires at the end of the request like the OnEnd of the processor or is there a better way of achieving the goal?
Cheers,
Danny
Additional context
No response
The text was updated successfully, but these errors were encountered: