Skip to content

Conversation

@zeitlinger
Copy link
Member

@zeitlinger zeitlinger commented Dec 16, 2025

Fixes #15566

Replaces #15339

Part of #15599

Note: This PR takes into account open-telemetry/opentelemetry-java#7927 for method naming.

@zeitlinger zeitlinger self-assigned this Dec 16, 2025
@zeitlinger zeitlinger requested a review from a team as a code owner December 16, 2025 07:57
@zeitlinger zeitlinger requested a review from Copilot December 16, 2025 07:57
@github-actions github-actions bot added the test native This label can be applied to PRs to trigger them to run native tests label Dec 16, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors library configuration access to use DeclarativeConfigUtil instead of directly using ConfigPropertiesUtil, enabling support for declarative configuration. The changes include introducing new utility classes for declarative config support, renaming the otel.experimental.javascript-snippet property to otel.instrumentation.servlet.experimental.javascript-snippet for naming convention consistency, and updating multiple instrumentations (servlet, log4j, kafka, jdbc, aws-sdk) to use the new configuration approach.

Key Changes

  • Introduces DeclarativeConfigUtil and SystemPropertiesBackedDeclarativeConfigProperties to enable declarative config support with fallback to system properties
  • Renames JavaScript snippet property from otel.experimental.javascript-snippet to otel.instrumentation.servlet.experimental.javascript-snippet with backward compatibility
  • Refactors AWS SDK v2.2 configuration by consolidating factory logic into AwsSdkTelemetryFactory and removing the abstract base class

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/config/internal/DeclarativeConfigUtil.java New utility class providing main API for accessing declarative config with fallback support
instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/config/internal/SystemPropertiesBackedDeclarativeConfigProperties.java New implementation of DeclarativeConfigProperties backed by system properties and environment variables
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/ConfigUtil.java New low-level config utilities copied from SDK for safe property access
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/ConfigPropertiesUtil.java Refactored to use ConfigUtil and added deprecation notices recommending DeclarativeConfig
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java Added declarative config support check and moved span suppression strategy resolution to instance method
instrumentation/servlet/servlet-common/bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/servlet/ExperimentalSnippetHolder.java Updated to use DeclarativeConfigUtil and added deprecation warning for old property name
instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/log4j/contextdata/v2_17/internal/ContextDataKeys.java Migrated to DeclarativeConfigUtil for logging configuration keys
instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/main/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/TracingProducerInterceptor.java Migrated to DeclarativeConfigUtil for capture headers configuration
instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/main/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/TracingConsumerInterceptor.java Migrated to DeclarativeConfigUtil for receive telemetry and capture headers configuration
instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcInstrumenterFactory.java Updated to use DeclarativeConfigUtil and accept OpenTelemetry parameter for config access
instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/OpenTelemetryDriver.java Migrated SQL commenter configuration to DeclarativeConfigUtil with fallback logic
instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkTelemetryFactory.java New factory class consolidating AWS SDK v2.2 telemetry configuration using DeclarativeConfigUtil
instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AbstractAwsSdkTelemetryFactory.java Removed abstract factory class, replaced by concrete AwsSdkTelemetryFactory
instrumentation/aws-sdk/aws-sdk-2.2/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/autoconfigure/AwsSdkSingletons.java Simplified to use new AwsSdkTelemetryFactory
instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/AwsSdkSingletons.java Simplified to use new AwsSdkTelemetryFactory
instrumentation/aws-sdk/aws-sdk-1.11/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/autoconfigure/TracingRequestHandler.java Migrated to DeclarativeConfigUtil for AWS SDK v1.11 configuration
instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/config/internal/SystemPropertiesBackedDeclarativeConfigPropertiesTest.java New comprehensive test coverage for SystemPropertiesBackedDeclarativeConfigProperties
instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/internal/ConfigPropertiesUtilTest.java Updated tests to use correct otel.instrumentation prefix
instrumentation-api-incubator/build.gradle.kts Added junit-pioneer dependency and JVM args for Java 17 compatibility
instrumentation/servlet/servlet-common/bootstrap/build.gradle.kts Added compileOnly dependency on instrumentation-api-incubator
docs/advanced-configuration-options.md Updated documentation with new JavaScript snippet property name
CHANGELOG.md Added breaking change entry for JavaScript snippet property rename
docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt Documents new public isDeclarativeConfig method in InstrumenterBuilder
smoke-tests/src/main/java/io/opentelemetry/smoketest/AbstractTestContainerManager.java Updated smoke tests to use new JavaScript snippet property name

@zeitlinger zeitlinger requested a review from trask December 20, 2025 23:10
@zeitlinger zeitlinger force-pushed the use-bridge-instread-of-config-property-util branch 2 times, most recently from 90ffe39 to ef0cae6 Compare December 22, 2025 07:00
@zeitlinger zeitlinger force-pushed the use-bridge-instread-of-config-property-util branch from 2391693 to 90865dd Compare December 22, 2025 19:01
@open-telemetry open-telemetry deleted a comment from github-actions bot Dec 22, 2025
DeclarativeConfigProperties instrumentationConfig =
((ExtendedOpenTelemetry) openTelemetry).getConfigProvider().getInstrumentationConfig();
if (instrumentationConfig == null) {
return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once getConfigProvider() is moved out of ExtendedOpenTelemetry to OpenTelemetry, I think we'll need to check the sys prop here? If so, may be good to do that now, could be easy to forget when refactoring later

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a mapping to check for the old value

SPECIAL_MAPPINGS.put(
"java.common.span_suppression_strategy/development",
"otel.instrumentation.experimental.span-suppression-strategy");

Comment on lines +22 to +23
// use ConfigPropertiesUtil only to prevent that the deprecated property is used in
// declarative config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure what this comment is trying to say

Comment on lines +68 to +88
boolean enabled =
DeclarativeConfigUtil.getInstrumentationConfig(openTelemetry, "jdbc")
.get("sqlcommenter/development")
.getBoolean("enabled", false);
if (!enabled) {
enabled =
ConfigPropertiesUtil.getBoolean(
"otel.instrumentation.jdbc.experimental.sqlcommenter.enabled", false);
}
if (!enabled) {
enabled =
DeclarativeConfigUtil.getInstrumentationConfig(openTelemetry, "common")
.get("database")
.get("sqlcommenter/development")
.getBoolean("enabled", false);
}
if (!enabled) {
enabled =
ConfigPropertiesUtil.getBoolean(
"otel.instrumentation.common.experimental.db-sqlcommenter.enabled", false);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the fallback shouldn't happen if there's an explicit false

I think you need to use the @nullable Boolean returning version and check for null return

Comment on lines +32 to +38
return AwsSdkTelemetry.builder(openTelemetry)
.setCapturedHeaders(
messaging.getScalarList(
"capture_headers/development",
String.class,
ConfigPropertiesUtil.getList(
"otel.instrumentation.messaging.experimental.capture-headers", emptyList())))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking more about this, mayb we should keep the two subclasses in order to avoid exposing the javaagent instrumentation to direct system property access

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test native This label can be applied to PRs to trigger them to run native tests

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Rename otel.instrumentation.experimental.span-suppression-strategy

3 participants