What is the proper way to enrich Application insights with custom dimensions?
- Dominant language
- PowerShell
- Stars
- 1.1k
- Forks
- 215
- Avg merge
- 4h 2m
- Merged PRs (30d)
- 1
Description
Hello,
I was looking for a way to enrich the Application Insights Telemetry information with custom dimensions.
- Scenario 1: To be more specific I would like to enrich the _request_ information with custom dimensions coming from the payload in the Azure Function.
- Scenario 2: As a second scenario I would like to ensure that all calls and _dependencies_ executed in the context of that Function are tracked with custom dimensions.
- Scenario 3: As a third scenario I would like to enrich the log messages using the ILogger interface with custom properties
- Scenario 4: Some Azure Functions are linked together logically. Is there a way to link them also in Application Insights. Do you have some recommendations how to do this?
**Scenario 1 and Scenario 2**
Looks that something could be achieved by using the Activity.Current.AddTag method. On the other hand, this seems to work for HTTP triggered functions only.
Do you have some suggestions to enrich the current request with a custom property. This seems to work only for HTTP triggered functions. Is there a way to do the same for Queue Functions?
**Scenario 3**
We are using the ILogger.BeginScope method to enrich the properties. This works fine for all operations that are using the ILogger interface. An example could look as follows:
```
using (log?.BeginScope(new Dictionary { { "CustomProperty", "CustomPropertyValue" } }))
{
log?.LogInformation("Your message...");
}
```
Thank you for your input,
Patrick
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.