Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 29, 2025

Following the pattern established in open-telemetry#7706 for SdkLogger, this PR makes the enabled fields volatile in SdkTracer, SdkMeter, and MetricStorage implementations to ensure that configuration changes to disabled/enabled state are eventually visible across threads, as required by the OpenTelemetry specification update.

Changes Made

  • SdkTracer.java: Changed tracerEnabled from protected boolean to protected volatile boolean and removed the outdated performance comment
  • SdkMeter.java: Changed meterEnabled from private boolean to private volatile boolean
  • DefaultSynchronousMetricStorage.java: Changed enabled field from private boolean to private volatile boolean
  • AsynchronousMetricStorage.java: Changed enabled field from private boolean to private volatile boolean

Background

The OpenTelemetry specification requires that changes to disabled configuration must be eventually visible. Previously, these fields were deliberately non-volatile for performance reasons, which meant configuration updates might not be visible across threads in a timely manner. The decision was made to prioritize correctness over the marginal performance benefit.

This change ensures consistency across all SDK components (logs, traces, and metrics) and enables proper dynamic configuration updates at runtime.

Testing

All existing tests continue to pass, confirming that the behavioral changes maintain backward compatibility while providing the required eventual visibility guarantees.

Relates to open-telemetry#7706

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/gradle-daemon-main-9.1.0.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/agents/gradle-instrumentation-agent-9.1.0.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 9.1.0 (dns block)
  • scans-in.gradle.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -XX:MaxMetaspaceSize=512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/gradle-daemon-main-9.1.0.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/agents/gradle-instrumentation-agent-9.1.0.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 9.1.0 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

@open-telemetry/opentelemetry-javaopen-telemetry/pull/7706

Should make this to relevant places for SdkTracer, SdkMeter (and MetricStorage impls)


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] @open-telemetry/opentelemetry-java/pull/7706 > Should make this to relevant places for SdkTracer, SdkMeter (and MetricStorage impls) Make enabled fields volatile in SdkTracer, SdkMeter, and MetricStorage implementations Sep 29, 2025
@Copilot Copilot AI requested a review from trask September 29, 2025 21:09
Copilot finished work on behalf of trask September 29, 2025 21:09
@trask trask marked this pull request as ready for review September 29, 2025 21:10
@trask trask merged commit fe84c31 into volatile Sep 29, 2025
@trask trask deleted the copilot/fix-de9e7177-fc58-493c-adde-10ae5da2915a branch September 29, 2025 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants