Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EventCounters] fix deadlock #1260

Merged
merged 5 commits into from
Jul 10, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

* Added a static constructor to ensure `EventCountersInstrumentationEventSource`
got initialized when `EventCountersMetrics` was accessed for the first time to
prevent potential deadlock;
e.g.: <https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/1024>.
([#1260](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1260))

* Update OpenTelemetry.Api to 1.5.1.
([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ internal sealed class EventCountersMetrics : EventListener
private readonly ConcurrentDictionary<(string, string), double> values = new();
private bool isDisposed;

static EventCountersMetrics()
{
// Ensure EventCountersInstrumentationEventSource got initialized when the class was accessed for the first time
// to prevent potential deadlock:
// https://github.com/open-telemetry/opentelemetry-dotnet-contrib/issues/1024.
_ = EventCountersInstrumentationEventSource.Log;
}

/// <summary>
/// Initializes a new instance of the <see cref="EventCountersMetrics"/> class.
/// </summary>
Expand Down