Skip to content

Commit

Permalink
Attempt to ensure metric names are always unique
Browse files Browse the repository at this point in the history
Only unique metric names will appear in New Relic, so text is added to
the metric name to ensure that all reported metrics have unique names.
  • Loading branch information
Fydon committed Jan 8, 2015
1 parent b298d02 commit e401e02
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions newrelic_perfmon_plugin/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public override void PollCycle()
try
{
Scope.Connect();
var metricNames = new Dictionary<string, int>();

foreach (Dictionary<string, Object> counter in Counters)
{
Expand Down Expand Up @@ -89,6 +90,15 @@ public override void PollCycle()

string metricName = string.Format("{0}{2}/{1}", categoryName, counterName, instanceName);

if (metricNames.ContainsKey(metricName))
{
metricName = metricName + "#" + metricNames[metricName]++;
}
else
{
metricNames.Add(metricName, 1);
}

logger.Debug("{0}/{1}: {2} {3}", Name, metricName, value, unitValue);

ReportMetric(metricName, unitValue, value);
Expand Down

0 comments on commit e401e02

Please sign in to comment.