Minor refactoring (#2987)
Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
This commit is contained in:
parent
6973a539d3
commit
abea4b60f6
|
|
@ -33,7 +33,6 @@ namespace OpenTelemetry.Metrics
|
||||||
private readonly ConcurrentDictionary<Tags, int> tagsToMetricPointIndexDictionary =
|
private readonly ConcurrentDictionary<Tags, int> tagsToMetricPointIndexDictionary =
|
||||||
new ConcurrentDictionary<Tags, int>();
|
new ConcurrentDictionary<Tags, int>();
|
||||||
|
|
||||||
private readonly AggregationTemporality temporality;
|
|
||||||
private readonly string name;
|
private readonly string name;
|
||||||
private readonly string metricPointCapHitMessage;
|
private readonly string metricPointCapHitMessage;
|
||||||
private readonly bool outputDelta;
|
private readonly bool outputDelta;
|
||||||
|
|
@ -65,8 +64,7 @@ namespace OpenTelemetry.Metrics
|
||||||
this.metricPoints = new MetricPoint[maxMetricPoints];
|
this.metricPoints = new MetricPoint[maxMetricPoints];
|
||||||
this.currentMetricPointBatch = new int[maxMetricPoints];
|
this.currentMetricPointBatch = new int[maxMetricPoints];
|
||||||
this.aggType = aggType;
|
this.aggType = aggType;
|
||||||
this.temporality = temporality;
|
this.outputDelta = temporality == AggregationTemporality.Delta;
|
||||||
this.outputDelta = temporality == AggregationTemporality.Delta ? true : false;
|
|
||||||
this.histogramBounds = histogramBounds;
|
this.histogramBounds = histogramBounds;
|
||||||
this.startTimeExclusive = DateTimeOffset.UtcNow;
|
this.startTimeExclusive = DateTimeOffset.UtcNow;
|
||||||
if (tagKeysInteresting == null)
|
if (tagKeysInteresting == null)
|
||||||
|
|
@ -102,7 +100,7 @@ namespace OpenTelemetry.Metrics
|
||||||
{
|
{
|
||||||
this.batchSize = 0;
|
this.batchSize = 0;
|
||||||
var indexSnapshot = Math.Min(this.metricPointIndex, this.maxMetricPoints - 1);
|
var indexSnapshot = Math.Min(this.metricPointIndex, this.maxMetricPoints - 1);
|
||||||
if (this.temporality == AggregationTemporality.Delta)
|
if (this.outputDelta)
|
||||||
{
|
{
|
||||||
this.SnapshotDelta(indexSnapshot);
|
this.SnapshotDelta(indexSnapshot);
|
||||||
}
|
}
|
||||||
|
|
@ -125,7 +123,7 @@ namespace OpenTelemetry.Metrics
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
metricPoint.TakeSnapshot(this.outputDelta);
|
metricPoint.TakeSnapshot(outputDelta: true);
|
||||||
this.currentMetricPointBatch[this.batchSize] = i;
|
this.currentMetricPointBatch[this.batchSize] = i;
|
||||||
this.batchSize++;
|
this.batchSize++;
|
||||||
}
|
}
|
||||||
|
|
@ -146,7 +144,7 @@ namespace OpenTelemetry.Metrics
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
metricPoint.TakeSnapshot(this.outputDelta);
|
metricPoint.TakeSnapshot(outputDelta: false);
|
||||||
this.currentMetricPointBatch[this.batchSize] = i;
|
this.currentMetricPointBatch[this.batchSize] = i;
|
||||||
this.batchSize++;
|
this.batchSize++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -111,14 +111,14 @@ namespace OpenTelemetry.Metrics
|
||||||
|
|
||||||
private void ExporterProc()
|
private void ExporterProc()
|
||||||
{
|
{
|
||||||
var sw = Stopwatch.StartNew();
|
int index;
|
||||||
|
int timeout;
|
||||||
var triggers = new WaitHandle[] { this.exportTrigger, this.shutdownTrigger };
|
var triggers = new WaitHandle[] { this.exportTrigger, this.shutdownTrigger };
|
||||||
|
var sw = Stopwatch.StartNew();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var timeout = (int)(this.exportIntervalMilliseconds - (sw.ElapsedMilliseconds % this.exportIntervalMilliseconds));
|
timeout = (int)(this.exportIntervalMilliseconds - (sw.ElapsedMilliseconds % this.exportIntervalMilliseconds));
|
||||||
|
|
||||||
int index;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.Metrics;
|
using System.Diagnostics.Metrics;
|
||||||
using System.Threading;
|
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
using OpenTelemetry;
|
using OpenTelemetry;
|
||||||
using OpenTelemetry.Metrics;
|
using OpenTelemetry.Metrics;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue