Unable to access RouteData from HttpRequest provided in EnrichWithHttpRequest. #4458
-
I'm using AspNetCoreInstrumentationOptions to setup enrichment for HTTP requests where I need to access the route data provided to my API endpoint for the purposes of sanitizing sensitive data before it is logged via telemetry. Under the old App Insights SDK, this was done using a telemetry processor which was provided an instance of IHttpContextAccessor. With the AspNetCoreInstrumentation, the EnrichWithHttpRequest is provided both the activity and an HttpRequest for the raw data, but when I look at httpRequest.RouteValues or httpRequest.HttpContext.GetRouteData(), it is always empty. Is there something I'm missing? How can I get this context that is needed to find the route data names and values so that I can modify the following in the Activity:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@treyjones-ms - Could you share a code snippet on how you are trying to use |
Beta Was this translation helpful? Give feedback.
It turns out, if I use the EnrichWithHttpResponse event, the HttpContext.Request object has the RouteData populated at that point. Now I have a new problem, there are separate log events generated from category Microsoft.AspNetCore.Hosting.Diagnostics and I need to figure out how to get the route data to update the Path state value to sanitize parameters.