Skip to content

Commit

Permalink
Reduce volatile reads in GlobalOpenTelemetry.get (#4009)
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga authored Dec 21, 2021
1 parent 4fbcc5c commit d88b09c
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ private GlobalOpenTelemetry() {}
* interface FQCN but the specified provider cannot be found.
*/
public static OpenTelemetry get() {
if (globalOpenTelemetry == null) {
OpenTelemetry openTelemetry = globalOpenTelemetry;
if (openTelemetry == null) {
synchronized (mutex) {
if (globalOpenTelemetry == null) {
openTelemetry = globalOpenTelemetry;
if (openTelemetry == null) {

OpenTelemetry autoConfigured = maybeAutoConfigure();
if (autoConfigured != null) {
Expand All @@ -65,7 +67,7 @@ public static OpenTelemetry get() {
}
}
}
return globalOpenTelemetry;
return openTelemetry;
}

/**
Expand Down

0 comments on commit d88b09c

Please sign in to comment.