Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

## Unreleased

* Make `IResourceDetector` public to allow custom implementations of resource detectors.
* Make `IResourceDetector` public to allow custom implementations of resource
detectors.
([2897](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2897))

* Perf improvement for HistogramSumCount updates, by implementing lock-free
updates.
([2961](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2961))

## 1.2.0-rc2

Released 2022-Feb-02
Expand Down
2 changes: 2 additions & 0 deletions src/OpenTelemetry/Metrics/HistogramBuckets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class HistogramBuckets

internal double SnapshotSum;

internal int IsCriticalSectionOccupied = 0;

internal HistogramBuckets(double[] explicitBounds)
{
this.ExplicitBounds = explicitBounds;
Expand Down
18 changes: 15 additions & 3 deletions src/OpenTelemetry/Metrics/MetricPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,22 @@ internal void Update(double number)

case AggregationType.HistogramSumCount:
{
lock (this.histogramBuckets.LockObject)
var sw = default(SpinWait);
while (true)
{
this.runningValue.AsLong++;
this.histogramBuckets.RunningSum += number;
if (Interlocked.Exchange(ref this.histogramBuckets.IsCriticalSectionOccupied, 1) == 0)
{
unchecked
{
this.runningValue.AsLong++;
this.histogramBuckets.RunningSum += number;
}

this.histogramBuckets.IsCriticalSectionOccupied = 0;
Comment thread
utpilla marked this conversation as resolved.
break;
}

sw.SpinOnce();
}

break;
Expand Down