Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
`autoGenerateServiceInstanceId` is `true`.
([#4988](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4988))

* Fixed a bug where isSampled parameter wasn't properly checked in certain cases
within the `UpdateWithExemplar` method of `MetricPoint`.
([#4851](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5004))

## 1.7.0-alpha.1

Released 2023-Oct-16
Expand Down
44 changes: 28 additions & 16 deletions src/OpenTelemetry/Metrics/MetricPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,14 @@ internal void UpdateWithExemplar(long number, ReadOnlySpan<KeyValuePair<string,

this.runningValue.AsLong = number;

Debug.Assert(this.mpComponents.ExemplarReservoir != null, "ExemplarReservoir was null");
if (isSampled)
{
Debug.Assert(this.mpComponents.ExemplarReservoir != null, "ExemplarReservoir was null");

// TODO: Need to ensure that the lock is always released.
// A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
this.mpComponents.ExemplarReservoir!.Offer(number, tags);
// TODO: Need to ensure that the lock is always released.
// A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
this.mpComponents.ExemplarReservoir!.Offer(number, tags);
}

ReleaseLock(ref this.mpComponents!.IsCriticalSectionOccupied);

Expand All @@ -516,11 +519,14 @@ internal void UpdateWithExemplar(long number, ReadOnlySpan<KeyValuePair<string,

this.runningValue.AsLong = number;

Debug.Assert(this.mpComponents.ExemplarReservoir != null, "ExemplarReservoir was null");
if (isSampled)
{
Debug.Assert(this.mpComponents.ExemplarReservoir != null, "ExemplarReservoir was null");

// TODO: Need to ensure that the lock is always released.
// A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
this.mpComponents.ExemplarReservoir!.Offer(number, tags);
// TODO: Need to ensure that the lock is always released.
// A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
this.mpComponents.ExemplarReservoir!.Offer(number, tags);
}

ReleaseLock(ref this.mpComponents!.IsCriticalSectionOccupied);

Expand Down Expand Up @@ -717,11 +723,14 @@ internal void UpdateWithExemplar(double number, ReadOnlySpan<KeyValuePair<string
this.runningValue.AsDouble = number;
}

Debug.Assert(this.mpComponents.ExemplarReservoir != null, "ExemplarReservoir was null");
if (isSampled)
{
Debug.Assert(this.mpComponents.ExemplarReservoir != null, "ExemplarReservoir was null");

// TODO: Need to ensure that the lock is always released.
// A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
this.mpComponents.ExemplarReservoir!.Offer(number, tags);
// TODO: Need to ensure that the lock is always released.
// A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
this.mpComponents.ExemplarReservoir!.Offer(number, tags);
}

ReleaseLock(ref this.mpComponents!.IsCriticalSectionOccupied);

Expand All @@ -737,11 +746,14 @@ internal void UpdateWithExemplar(double number, ReadOnlySpan<KeyValuePair<string
this.runningValue.AsDouble = number;
}

Debug.Assert(this.mpComponents.ExemplarReservoir != null, "ExemplarReservoir was null");
if (isSampled)
{
Debug.Assert(this.mpComponents.ExemplarReservoir != null, "ExemplarReservoir was null");

// TODO: Need to ensure that the lock is always released.
// A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
this.mpComponents.ExemplarReservoir!.Offer(number, tags);
// TODO: Need to ensure that the lock is always released.
// A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
this.mpComponents.ExemplarReservoir!.Offer(number, tags);
}

ReleaseLock(ref this.mpComponents!.IsCriticalSectionOccupied);

Expand Down