I want to include headers in the request events in Application Insights and found the following post that has a solution for application with a HttpContext. I'm working with a Nancy application where the request headers are stored in the NancyContext. Problem is that Nancy doesn't provide a static accessor like HttpContext.Current so I wonder how I can solve it.
I've made two attempts without succeeding. The first was to build an ITelemetryInitializer like described in the link below but then I could not access the NancyContext.
My second attempt was to pass the NancyModule to a static function that added the request headers to the ITelemetryContext but then I could not get a hold of the current ITelemetryContext instead.
Has anyone else faced and solved this issue?