2 years ago
#66231
n1k1
Microsoft.ApplicationInsights GetMetric intermittently throw error
"Microsoft.ApplicationInsights" Version="2.10.0"
public void GetAppMetric(string metricId, double metricValue)
{
string source = string.IsNullOrWhiteSpace(this.Store[Logging.Constants.Key]) ?
"NA" : this.Store[Logging.Constants.Key];
string correlationId = string.IsNullOrWhiteSpace(this.Store[Logging.Constants.CorrelationId]) ?
"NA" : this.Store[Logging.Constants.CorrelationId];
MetricIdentifier metricIdentifier = new MetricIdentifier("OutboundConnection", metricId, "source", "correlationId");
Metric metric = this.TelemetryClient.GetMetric(metricIdentifier);
if (metric.TryGetDataSeries(out MetricSeries series, source, correlationId))
{
series.TrackValue(metricValue);
}
else
{
this.TelemetryClient.TrackTrace($"No series is present, metricId: {metricId}, source: {source}, correlationId : {correlationId}");
}
}
It does track the value but very often it's adding the trace "No series present" messages.
If all the dimensions are passed correctly, In what case the series return can be false?
I tried debugging, it never goes into else block but on the server, it logs "No series present message" with correct metricId, source, and correlationId.
azure
azure-application-insights
appinsights
0 Answers
Your Answer