From e401e02610dc41f334385b9315fa3faa55d8af29 Mon Sep 17 00:00:00 2001 From: Fydon Date: Thu, 8 Jan 2015 09:54:07 +0000 Subject: [PATCH] Attempt to ensure metric names are always unique 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. --- newrelic_perfmon_plugin/Agent.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/newrelic_perfmon_plugin/Agent.cs b/newrelic_perfmon_plugin/Agent.cs index 12d9dee..91ba9a4 100644 --- a/newrelic_perfmon_plugin/Agent.cs +++ b/newrelic_perfmon_plugin/Agent.cs @@ -52,6 +52,7 @@ public override void PollCycle() try { Scope.Connect(); + var metricNames = new Dictionary(); foreach (Dictionary counter in Counters) { @@ -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);