Tracking request headers in Application Insights

Written by ppolyzos

Software engineer based in beautiful Luxembourg


  1. Mauro Masucci

    Good information but there seems to be an error in your code, you create the class as “public class TelemetryHeadersInitializer : ITelemetryInitializer”

    but then initialise it using “TelemetryConfiguration.Active.TelemetryInitializers.Add(new HeaderTelemetryInitializer()”

    Should it not be the same as the class so it would become “TelemetryConfiguration.Active.TelemetryInitializers.Add(new TelemetryHeadersInitializer()”

    1. ppolyzos

      I also agree it’s somewhat a hack.
      I think there is a method named `EnableRewind()` that can be applied to the `context.request` and give you access to the Request Body, however I ‘ve never measured the performance on that.
      Another way would be to move the tracking to the client side using the javascript SDK of Application Insights and transmit the request body.

Leave a Comment

Your email address will not be published. Required fields are marked *