Skip to content

Commit 9baa5ff

Browse files
committed
up
1 parent ae5b2d6 commit 9baa5ff

4 files changed

Lines changed: 37 additions & 7 deletions

File tree

.github/agents/knowledge/config-property-stability.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Defined in [VERSIONING.md](../../../VERSIONING.md):
5252
Examples (flat ↔ YAML):
5353

5454
- `otel.instrumentation.http.client.capture-request-headers``request_captured_headers`**stable**
55-
- `otel.instrumentation.common.experimental.db-sqlcommenter.enabled``sqlcommenter/development: { enabled: true }`**experimental**
55+
- `otel.instrumentation.common.db.experimental.sqlcommenter.enabled``sqlcommenter/development: { enabled: true }`**experimental**
5656
- `otel.instrumentation.http.client.emit-experimental-telemetry``emit_experimental_telemetry/development: true`**experimental**
5757

5858
## Deprecation Communication

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
`*.query-sanitization.enabled` names, and deprecated the declarative config name
1717
`statement_sanitizer` in favor of `query_sanitization`
1818
- Deprecated the declarative config group `common.database` in favor of `common.db`
19+
- Deprecated the common DB sqlcommenter system property name
20+
`otel.instrumentation.common.experimental.db-sqlcommenter.enabled` in favor of
21+
`otel.instrumentation.common.db.experimental.sqlcommenter.enabled`
1922
- Deprecated the GraphQL system property name
2023
`otel.instrumentation.graphql.query-sanitizer.enabled` and declarative config name
2124
`query_sanitizer` in favor of `otel.instrumentation.graphql.query-sanitization.enabled` and

instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/config/internal/DbConfig.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ private static Boolean getCommonSqlCommenterEnabled(OpenTelemetry openTelemetry)
8787
Boolean deprecatedPropertyValue =
8888
commonConfig.get("db_sqlcommenter/development").getBoolean("enabled");
8989
if (deprecatedPropertyValue != null) {
90-
warnIfDeprecatedSystemPropertyUsed(
91-
"otel.instrumentation.common.experimental.db-sqlcommenter.enabled");
90+
warnIfDeprecatedExperimentalSystemPropertyUsed(
91+
"otel.instrumentation.common.experimental.db-sqlcommenter.enabled",
92+
"otel.instrumentation.common.db.experimental.sqlcommenter.enabled");
9293
return deprecatedPropertyValue;
9394
}
9495

@@ -170,13 +171,15 @@ private static void warnIfDeprecatedSystemPropertyUsed(
170171
}
171172
}
172173

173-
private static void warnIfDeprecatedSystemPropertyUsed(String deprecatedProperty) {
174+
private static void warnIfDeprecatedExperimentalSystemPropertyUsed(
175+
String deprecatedProperty, String replacementProperty) {
174176
if (warnedDeprecatedProperties.add(deprecatedProperty)) {
175177
logger.warning(
176178
"The "
177179
+ deprecatedProperty
178-
+ " system property is deprecated and will be removed in a future version. Use"
179-
+ " equivalent declarative configuration instead.");
180+
+ " system property is deprecated and will be removed in a future version. Use "
181+
+ replacementProperty
182+
+ " instead.");
180183
}
181184
}
182185

instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/OpenTelemetryDriver.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
/** JDBC driver for OpenTelemetry. */
5353
public final class OpenTelemetryDriver implements Driver {
5454

55+
private static final Logger logger = Logger.getLogger(OpenTelemetryDriver.class.getName());
56+
5557
// visible for testing
5658
static final OpenTelemetryDriver INSTANCE = new OpenTelemetryDriver();
5759

@@ -62,21 +64,43 @@ public final class OpenTelemetryDriver implements Driver {
6264

6365
private static final String URL_PREFIX = "jdbc:otel:";
6466
private static final AtomicBoolean REGISTERED = new AtomicBoolean();
67+
private static final AtomicBoolean warnedDeprecatedCommonSqlCommenterProperty =
68+
new AtomicBoolean();
6569
private static final List<Driver> DRIVER_CANDIDATES = new CopyOnWriteArrayList<>();
6670

6771
@SuppressWarnings("deprecation") // library flat config fallback remains supported until 3.0
6872
private static SqlCommenter getSqlCommenter(OpenTelemetry openTelemetry) {
73+
Boolean deprecatedCommonSqlCommenterEnabled = getDeprecatedCommonSqlCommenterEnabled();
6974
boolean enabled =
7075
DbConfig.isSqlCommenterEnabled(
7176
openTelemetry,
7277
"jdbc",
7378
ConfigPropertiesUtil.getBoolean(
7479
"otel.instrumentation.jdbc.experimental.sqlcommenter.enabled",
7580
ConfigPropertiesUtil.getBoolean(
76-
"otel.instrumentation.common.experimental.db-sqlcommenter.enabled", false)));
81+
"otel.instrumentation.common.db.experimental.sqlcommenter.enabled",
82+
deprecatedCommonSqlCommenterEnabled != null
83+
? deprecatedCommonSqlCommenterEnabled
84+
: false)));
7785
return SqlCommenter.builder().setEnabled(enabled).build();
7886
}
7987

88+
@Nullable
89+
@SuppressWarnings("deprecation") // library flat config fallback remains supported until 3.0
90+
private static Boolean getDeprecatedCommonSqlCommenterEnabled() {
91+
Boolean deprecatedValue =
92+
ConfigPropertiesUtil.getBoolean(
93+
"otel.instrumentation.common.experimental.db-sqlcommenter.enabled");
94+
if (deprecatedValue != null
95+
&& warnedDeprecatedCommonSqlCommenterProperty.compareAndSet(false, true)) {
96+
logger.warning(
97+
"The otel.instrumentation.common.experimental.db-sqlcommenter.enabled system property"
98+
+ " is deprecated and will be removed in a future version. Use"
99+
+ " otel.instrumentation.common.db.experimental.sqlcommenter.enabled instead.");
100+
}
101+
return deprecatedValue;
102+
}
103+
80104
static {
81105
try {
82106
int[] version = parseInstrumentationVersion();

0 commit comments

Comments
 (0)