@@ -32,11 +32,13 @@ public static boolean isCommonQuerySanitizationEnabled(
3232
3333 public static boolean isQuerySanitizationEnabled (
3434 OpenTelemetry openTelemetry , String instrumentationName ) {
35+ DeclarativeConfigProperties instrumentationConfig =
36+ DeclarativeConfigUtil .getInstrumentationConfig (openTelemetry , instrumentationName );
3537 Boolean querySanitizationEnabled =
3638 getQuerySanitizationEnabled (
37- DeclarativeConfigUtil . getInstrumentationConfig ( openTelemetry , instrumentationName ) ,
38- getDeprecatedQuerySanitizationProperty ( instrumentationName ) ,
39- getQuerySanitizationProperty ( instrumentationName ) );
39+ instrumentationConfig ,
40+ "otel.instrumentation." + instrumentationName + ".statement-sanitizer.enabled" ,
41+ "otel.instrumentation." + instrumentationName + ".query-sanitization.enabled" );
4042 if (querySanitizationEnabled != null ) {
4143 return querySanitizationEnabled ;
4244 }
@@ -72,15 +74,24 @@ private static Boolean getCommonSqlCommenterEnabled(OpenTelemetry openTelemetry)
7274 return value ;
7375 }
7476
77+ // this variant was never a regular (non-declarative) configuration property name
7578 Boolean deprecatedValue =
7679 commonConfig .get ("database" ).get ("sqlcommenter/development" ).getBoolean ("enabled" );
7780 if (deprecatedValue != null ) {
7881 warnIfDeprecatedDeclarativeConfigurationUsed (
79- "common.database.sqlcommenter/development.enabled" ,
80- "common.db.sqlcommenter/development.enabled" );
82+ ".instrumentation/development.java. common.database.sqlcommenter/development.enabled" ,
83+ ".instrumentation/development.java. common.db.sqlcommenter/development.enabled" );
8184 return deprecatedValue ;
8285 }
8386
87+ Boolean deprecatedPropertyValue =
88+ commonConfig .get ("db_sqlcommenter/development" ).getBoolean ("enabled" );
89+ if (deprecatedPropertyValue != null ) {
90+ warnIfDeprecatedSystemPropertyUsed (
91+ "otel.instrumentation.common.experimental.db-sqlcommenter.enabled" );
92+ return deprecatedPropertyValue ;
93+ }
94+
8495 return null ;
8596 }
8697
@@ -89,24 +100,29 @@ private static Boolean getCommonQuerySanitizationEnabled(OpenTelemetry openTelem
89100 DeclarativeConfigProperties commonConfig =
90101 DeclarativeConfigUtil .getInstrumentationConfig (openTelemetry , "common" );
91102
92- Boolean value =
93- getQuerySanitizationEnabled (
94- commonConfig .get ("db" ),
95- "otel.instrumentation.common.db-statement-sanitizer.enabled" ,
96- "otel.instrumentation.common.db.query-sanitization.enabled" );
103+ Boolean value = commonConfig .get ("db" ).get ("query_sanitization" ).getBoolean ("enabled" );
97104 if (value != null ) {
98105 return value ;
99106 }
100107
101- Boolean deprecatedValue =
102- getQuerySanitizationEnabled (
103- commonConfig .get ("database" ),
104- "otel.instrumentation.common.db-statement-sanitizer.enabled" ,
105- "otel.instrumentation.common.db.query-sanitization.enabled" );
106- if (deprecatedValue != null ) {
108+ // this variant was never a regular (non-declarative) configuration property name
109+ Boolean deprecatedStatementSanitizerValue =
110+ commonConfig .get ("database" ).get ("statement_sanitizer" ).getBoolean ("enabled" );
111+ if (deprecatedStatementSanitizerValue != null ) {
107112 warnIfDeprecatedDeclarativeConfigurationUsed (
108- "common.database.statement_sanitizer.enabled" , "common.db.query_sanitization.enabled" );
109- return deprecatedValue ;
113+ ".instrumentation/development.java.common.database.statement_sanitizer.enabled" ,
114+ ".instrumentation/development.java.common.db.query_sanitization.enabled" );
115+ return deprecatedStatementSanitizerValue ;
116+ }
117+
118+ // this variant was never a declarative configuration property name
119+ Boolean deprecatedStatementSanitizerPropertyValue =
120+ commonConfig .get ("db_statement_sanitizer" ).getBoolean ("enabled" );
121+ if (deprecatedStatementSanitizerPropertyValue != null ) {
122+ warnIfDeprecatedSystemPropertyUsed (
123+ "otel.instrumentation.common.db-statement-sanitizer.enabled" ,
124+ "otel.instrumentation.common.db.query-sanitization.enabled" );
125+ return deprecatedStatementSanitizerPropertyValue ;
110126 }
111127
112128 return null ;
@@ -122,7 +138,7 @@ private static Boolean getQuerySanitizationEnabled(
122138
123139 Boolean deprecatedValue = config .get ("statement_sanitizer" ).getBoolean ("enabled" );
124140 if (deprecatedValue != null ) {
125- warnIfDeprecatedConfigurationUsed (deprecatedProperty , replacementProperty );
141+ warnIfDeprecatedSettingOrEquivalentUsed (deprecatedProperty , replacementProperty );
126142 return deprecatedValue ;
127143 }
128144
@@ -135,31 +151,46 @@ private static void warnIfDeprecatedDeclarativeConfigurationUsed(
135151 logger .warning (
136152 "The "
137153 + deprecatedProperty
138- + " declarative configuration is deprecated and will be removed in 3.0. Use "
154+ + " declarative configuration is deprecated"
155+ + " and will be removed in a future version. Use "
139156 + replacementProperty
140157 + " instead." );
141158 }
142159 }
143160
144- private static void warnIfDeprecatedConfigurationUsed (
161+ private static void warnIfDeprecatedSystemPropertyUsed (
145162 String deprecatedProperty , String replacementProperty ) {
146163 if (warnedDeprecatedProperties .add (deprecatedProperty )) {
147164 logger .warning (
148165 "The "
149166 + deprecatedProperty
150- + " setting or equivalent declarative configuration is deprecated and will be"
151- + " removed in 3.0. Use "
167+ + " system property is deprecated and will be removed in 3.0. Use "
152168 + replacementProperty
153- + " or equivalent declarative configuration instead." );
169+ + " instead." );
154170 }
155171 }
156172
157- private static String getQuerySanitizationProperty (String instrumentationName ) {
158- return "otel.instrumentation." + instrumentationName + ".query-sanitization.enabled" ;
173+ private static void warnIfDeprecatedSystemPropertyUsed (String deprecatedProperty ) {
174+ if (warnedDeprecatedProperties .add (deprecatedProperty )) {
175+ logger .warning (
176+ "The "
177+ + deprecatedProperty
178+ + " system property is deprecated and will be removed in a future version. Use"
179+ + " equivalent declarative configuration instead." );
180+ }
159181 }
160182
161- private static String getDeprecatedQuerySanitizationProperty (String instrumentationName ) {
162- return "otel.instrumentation." + instrumentationName + ".statement-sanitizer.enabled" ;
183+ private static void warnIfDeprecatedSettingOrEquivalentUsed (
184+ String deprecatedProperty , String replacementProperty ) {
185+ if (warnedDeprecatedProperties .add (deprecatedProperty )) {
186+ logger .warning (
187+ "The "
188+ + deprecatedProperty
189+ + " setting and the equivalent declarative configuration property"
190+ + " are deprecated and will be removed in 3.0. Use "
191+ + replacementProperty
192+ + " or equivalent declarative configuration instead." );
193+ }
163194 }
164195
165196 private DbConfig () {}
0 commit comments