Application Insights -- add custom dimensions to 'requests' telemetry items generated by the host
See original GitHub issueHi,
I’m really missing the ability to decorate each request with custom dimensions.
I’m using the native functions integration with AppInsights, and I use ILogger
– I wouldn’t want to install the AppInsights nuget and do all the initializations myself.
Optimal solution for me is to have a Dictionary as an optional input in the Function’s signature.
Is this by any chance possible today? If not, can you consider this as a new feature/improvement?
Many thanks ! Jonathan
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Adding Custom Dimension to Request Telemetry - Azure ...
1.In Visual studio, create a function app(In my test, I create a blob triggerd function), and install the following nuget packages: Microsoft.
Read more >Application Insights telemetry data model - Azure Monitor
Custom measurements are associated with the telemetry item they belong to. They're subject to sampling with the telemetry item that contains ...
Read more >Analyze Azure Functions telemetry in Application Insights
Learn how to view and query for Azure Functions telemetry data collected by and stored in Azure Application Insights.
Read more >How to use Application Insights Custom Properties in ...
Azure Application Insights is great for easily adding telemetry to ... to select all items where the FirstName custom dimension is “Cat”, ...
Read more >Azure Application Insights — How not to burn money using it
In this blog post, I'm going to talk about Azure Application Insights and how I learned not to take certain things for granted...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Activity.Current.Tag(…) seems to work and translates into a custom property on the App Insights side. Would be good to have confirmation this is a supported way of working. Similarly, Activity.Current.AddBagage equally seems to work for custom tracking data which you want to pass onto any dependencies (and dependencies of those… all the way down)l. This is compatible with at least Service Bus and .NET Core Http.
The code from @mheskandari works for me to add to
traces
table, but that doesn’t include it inrequests
table. This makes sense: logs written fromILogger
just go totraces
table.To add to
customDimensions
within therequests
table you can do this:e.g. as described here in more detail https://www.davepaquette.com/archive/2020/03/07/enhancing-application-insights-request-telemetry.aspx
@xstof suggests above that you could instead use System.Diagnostics.Activity.Current.AddTag() to add custom dimensions to
requests
but that doesn’t work for me now (Application Insights v2.19.0). The tags don’t seem to go anywhere. Seems like it would be nice, perhaps I’m just doing it wrong.If you want to add custom properties that are automatically added to
dependencies
(e.g. SQL) andtraces
tables you can useSystem.Diagnostics.Activity.Current.AddBaggage()
, e.g. within a middleware class so this gets done at the start of every request. In my testing this does not get added torequests
table though, so I need to do both this and the RequestTelemetry Properties as above.