Skip to content

Commit 785c1ec

Browse files
committed
Address review comment: deduplicate common config warnings
1 parent 94706b7 commit 785c1ec

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

  • instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/config/internal
  • instrumentation/log4j/log4j-appender-2.17/library/src/main/java/io/opentelemetry/instrumentation/log4j/appender/v2_17

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.util.HashSet;
1414
import java.util.List;
1515
import java.util.Set;
16+
import java.util.concurrent.ConcurrentHashMap;
1617
import java.util.logging.Logger;
1718

1819
/**
@@ -21,6 +22,7 @@
2122
*/
2223
public final class CommonConfig {
2324
private static final Logger logger = Logger.getLogger(CommonConfig.class.getName());
25+
private static final Set<String> warnedDeprecatedProperties = ConcurrentHashMap.newKeySet();
2426

2527
private final List<String> clientRequestHeaders;
2628
private final List<String> clientResponseHeaders;
@@ -131,13 +133,15 @@ private static String getConfig(
131133
}
132134
value = config.getString(oldDeclarativeKey);
133135
if (value != null) {
134-
logger.warning(
135-
"The "
136-
+ oldProperty
137-
+ " setting and the equivalent declarative configuration property"
138-
+ " are deprecated and will be removed in 3.0. Use "
139-
+ newProperty
140-
+ " or equivalent declarative configuration instead.");
136+
if (warnedDeprecatedProperties.add(oldProperty)) {
137+
logger.warning(
138+
"The "
139+
+ oldProperty
140+
+ " setting and the equivalent declarative configuration property"
141+
+ " are deprecated and will be removed in 3.0. Use "
142+
+ newProperty
143+
+ " or equivalent declarative configuration instead.");
144+
}
141145
return value;
142146
}
143147
return defaultValue;

instrumentation/log4j/log4j-appender-2.17/library/src/main/java/io/opentelemetry/instrumentation/log4j/appender/v2_17/OpenTelemetryAppender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ private void emit(OpenTelemetry openTelemetry, LogEvent event) {
334334
String traceId = contextDataAccessor.getValue(contextData, contextDataKeys.getTraceIdKey());
335335
String spanId = contextDataAccessor.getValue(contextData, contextDataKeys.getSpanIdKey());
336336
String traceFlags =
337-
contextDataAccessor.getValue(contextData, contextDataKeys.getTraceFlags());
337+
contextDataAccessor.getValue(contextData, contextDataKeys.getTraceFlagsKey());
338338
if (traceId != null && spanId != null && traceFlags != null) {
339339
context =
340340
Context.root()

0 commit comments

Comments
 (0)