microsoft / ApplicationInsights-dotnet-server

Microsoft Application Insights for .NET Web Applications
https://azure.microsoft.com/services/application-insights/
133 stars 67 forks source link

Support reading metadata when collecting EventCounter data #1287

Closed Expecho closed 5 years ago

Expecho commented 5 years ago

Regarding the (new) Microsoft.ApplicationInsights.EventCounterCollector:

When I define a custom EventCounter I can add metadata to it:

methodDurationCounter = new EventCounter(nameof(methodDurationCounter), this);
methodDurationCounter.AddMetadata("Environment", "Production");
methodDurationCounter.AddMetadata("Customer", "Ibis");

This metadata is added to the payload. I would be very happy when this data is included as custom properties of the MetricTelemetry that is send. See the source.

I would be more than willing to provide a PR for this.

cijothomas commented 5 years ago

AddMetadata is available only in .NET Core 3.0 right? But it shouldn't affect listener.

Yes we are happy to accept a PR to make this enhancement.

Expecho commented 5 years ago

AddMetadata is available only in .NET Core 3.0 right? But it shouldn't affect listener. Yes we are happy to accept a PR to make this enhancement.

Yes, .Net Core 3 only. But we can check for payload availability so we can make it backwards compatible.

I'll probably start working on it in the next few days.