Skip to content

Commit

Permalink
Use UpDownCounter for grain and system target counts
Browse files Browse the repository at this point in the history
UpDownCounter and Counter have the same implementation but they are interpreted differently by the .Net OTel SDK.
UpDownCounter supports reporting negative values and is suitable to keep track of the number of active grain per type.
The metric will be exported by the OTel SDK as a cumulative value instead of a delta for Counter.
  • Loading branch information
Costo committed Dec 15, 2023
1 parent d54dc1e commit f4b54fc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Orleans.Core/Diagnostics/Metrics/GrainInstruments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static GrainInstruments()
GrainMetricsListener.Start();
}

internal static Counter<int> GrainCounts = Instruments.Meter.CreateCounter<int>(InstrumentNames.GRAIN_COUNTS);
internal static UpDownCounter<int> GrainCounts = Instruments.Meter.CreateUpDownCounter<int>(InstrumentNames.GRAIN_COUNTS);
internal static void IncrementGrainCounts(string grainTypeName)
{
GrainCounts.Add(1, new KeyValuePair<string, object>("type", grainTypeName));
Expand All @@ -20,7 +20,7 @@ internal static void DecrementGrainCounts(string grainTypeName)
GrainCounts.Add(-1, new KeyValuePair<string, object>("type", grainTypeName));
}

internal static Counter<int> SystemTargetCounts = Instruments.Meter.CreateCounter<int>(InstrumentNames.SYSTEM_TARGET_COUNTS);
internal static UpDownCounter<int> SystemTargetCounts = Instruments.Meter.CreateUpDownCounter<int>(InstrumentNames.SYSTEM_TARGET_COUNTS);
internal static void IncrementSystemTargetCounts(string systemTargetTypeName)
{
SystemTargetCounts.Add(1, new KeyValuePair<string, object>("type", systemTargetTypeName));
Expand Down

0 comments on commit f4b54fc

Please sign in to comment.