You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nuget package: Microsoft.ApplicationInsights.AspNetCore v 2.22.0
Runtime version: net8.0
Hosting environment: Windows 11, Visual Studio 2022
Describe the bug
I want to create a metric that describes how many times something happened in my application. For example, when people place an order. So if 3 orders are placed within a minute, I expect the "Sum" of the metric to be 3 for that minute.
When I try to track this metric via an EventSource using the EventCounter or IncrementingEventCounter, the metrics are not adding up, but looking more like an "Orders per minute" statistic.
When using the _telemetryClient.GetMetric() approach, the metric is tracked exactly as I want it, but I would like to instrument my code using the EventSource instead.
To Reproduce
Using the default aspnet mvc template project I did the following:
Created an event source with two types of counters:
[EventSource(Name = "My.App")]
internal sealed class MyEventSource : EventSource
{
public static MyEventSource Log = new();
private readonly EventCounter _eventCounter;
private readonly IncrementingEventCounter _incrementingCounter;
public MyEventSource()
{
_eventCounter = new EventCounter("test-eventcounter", this)
{
DisplayName = "test-eventcounter"
};
_incrementingCounter = new IncrementingEventCounter("test-incrementing", this)
{
DisplayName = "test-incrementing"
};
}
[Event(1)]
public void HitEventCounter()
{
WriteEvent(1);
_eventCounter?.WriteMetric(1);
}
[Event(2)]
public void HitIncrementingCounter()
{
WriteEvent(2);
_incrementingCounter?.Increment();
}
}
Configured the EventCounterCollectionModule like this:
Describe the bug
I want to create a metric that describes how many times something happened in my application. For example, when people place an order. So if 3 orders are placed within a minute, I expect the "Sum" of the metric to be 3 for that minute.
When I try to track this metric via an EventSource using the EventCounter or IncrementingEventCounter, the metrics are not adding up, but looking more like an "Orders per minute" statistic.
When using the
_telemetryClient.GetMetric()
approach, the metric is tracked exactly as I want it, but I would like to instrument my code using the EventSource instead.To Reproduce
Using the default aspnet mvc template project I did the following:
Created an event source with two types of counters:
Configured the EventCounterCollectionModule like this:
Calling three different ways of tracking the metric in my Home controller:
The resulting data in the
customMetrics
table in Application Insights:I would expect the EventSource based metrics to work the same way as the SDK metric, creating a correct "Sum" for the number of events.
The text was updated successfully, but these errors were encountered: