Check isSampled parameter in UpdateWithExemplar method (#5004)

This commit is contained in:
ImoutoChan 2023-10-31 06:19:14 +03:00 committed by GitHub
parent 86a6ba0b7f
commit b45b8a9a12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 16 deletions

View File

@ -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

View File

@ -499,11 +499,14 @@ public struct MetricPoint
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);
@ -516,11 +519,14 @@ public struct MetricPoint
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);
@ -717,11 +723,14 @@ public struct MetricPoint
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);
@ -737,11 +746,14 @@ public struct MetricPoint
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);