ApplicationInsights-dotnet: Global Properties do not show up for customMetrics
Hi,
I’m having trouble getting global properties to show up in AI when tracking custom metrics. The code is pasted below. Using the same pattern below for tracking custom events, I can get global properties to show up for custom events just fine, however AI seems to discard them for metrics.
Code / Steps to Repro
public static void TrackMetric(int metricValue)
{
var config = new TelemetryConfiguration
{
InstrumentationKey = _instrumentationKey,
TelemetryChannel = new ServerTelemetryChannel(),
DisableTelemetry = false
};
config.TelemetryChannel.DeveloperMode = Debugger.IsAttached;
config.TelemetryProcessorChainBuilder.UseSampling(100);
var client = new TelemetryClient(config);
client.Context.Session.Id = Guid.NewGuid();
client.Context.GlobalProperties.Add("globalPropertyName1", "globalPropertyValue1");
client.Context.GlobalProperties.Add("globalPropertyName2", "globalPropertyValue2");
client.Context.GlobalProperties.Add("globalPropertyName3", "globalPropertyValue3");
var metricId = new MetricIdentifier("defaultNamespace",
"metricName",
"localPropertyNameA",
"localPropertyNameB",
"localPropertyNameC");
var metric = client.GetMetric(metricId);
metric.TrackValue(metricValue,
"localPropertyValueA",
"localPropertyValueB",
"localPropertyValueC");
}
Actual Behavior
In our AI ‘Logs (Analytics)’ on Azure when I query customMetrics, I see the metric items as expected, however the global properties I’m setting do not show up in customDimensions like they do for customEvents. The item-level properties do show up as expected.
Expected Behavior
Based on how custom events work with global props, I would expect custom metrics to contain the global props as well. Is there a difference in how global properties are handled between customMetrics and customEvents?
Thanks!
Version Info
SDK Version : 2.10.0.0 .NET Version : .NET Framework 4.5.2 How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) : Visual Studio OS : Windows 10 Hosting Info (IIS/Azure WebApps/ etc) : WPF & WCF Windows processes
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (8 by maintainers)
@Liversage “Unfortunately, I’m unable to filter or split the data based on my custom dimensions.”
This is opt-in. You need to enable it explicitly: https://docs.microsoft.com/en-us/azure/azure-monitor/app/pre-aggregated-metrics-log-metrics#custom-metrics-dimensions-and-pre-aggregation
Some time in future, the custom metric gets billed separately, hence its opt-in.