Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

Commit eec8703

Browse files
author
Mateusz Rzeszutek
authored
Rename common HTTP configuration settings (open-telemetry#8758)
1 parent 91a5cce commit eec8703

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/CommonConfig.java

+19-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
package io.opentelemetry.javaagent.bootstrap.internal;
77

8-
import static java.util.Collections.emptyList;
98
import static java.util.Collections.emptyMap;
109

1110
import java.util.List;
@@ -33,14 +32,29 @@ public static CommonConfig get() {
3332
CommonConfig(InstrumentationConfig config) {
3433
peerServiceMapping =
3534
config.getMap("otel.instrumentation.common.peer-service-mapping", emptyMap());
35+
36+
// TODO (mateusz): remove the old config names in 2.0
3637
clientRequestHeaders =
37-
config.getList("otel.instrumentation.http.capture-headers.client.request", emptyList());
38+
DeprecatedConfigProperties.getList(
39+
config,
40+
"otel.instrumentation.http.capture-headers.client.request",
41+
"otel.instrumentation.http.client.capture-request-headers");
3842
clientResponseHeaders =
39-
config.getList("otel.instrumentation.http.capture-headers.client.response", emptyList());
43+
DeprecatedConfigProperties.getList(
44+
config,
45+
"otel.instrumentation.http.capture-headers.client.response",
46+
"otel.instrumentation.http.client.capture-response-headers");
4047
serverRequestHeaders =
41-
config.getList("otel.instrumentation.http.capture-headers.server.request", emptyList());
48+
DeprecatedConfigProperties.getList(
49+
config,
50+
"otel.instrumentation.http.capture-headers.server.request",
51+
"otel.instrumentation.http.server.capture-request-headers");
4252
serverResponseHeaders =
43-
config.getList("otel.instrumentation.http.capture-headers.server.response", emptyList());
53+
DeprecatedConfigProperties.getList(
54+
config,
55+
"otel.instrumentation.http.capture-headers.server.response",
56+
"otel.instrumentation.http.server.capture-response-headers");
57+
4458
statementSanitizationEnabled =
4559
config.getBoolean("otel.instrumentation.common.db-statement-sanitizer.enabled", true);
4660
}

javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/DeprecatedConfigProperties.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55

66
package io.opentelemetry.javaagent.bootstrap.internal;
77

8+
import static java.util.Collections.emptyList;
89
import static java.util.logging.Level.WARNING;
910

11+
import java.util.List;
1012
import java.util.logging.Logger;
1113

1214
/**
@@ -22,14 +24,26 @@ public static boolean getBoolean(
2224
String deprecatedPropertyName,
2325
String newPropertyName,
2426
boolean defaultValue) {
27+
warnIfUsed(config, deprecatedPropertyName, newPropertyName);
28+
boolean value = config.getBoolean(deprecatedPropertyName, defaultValue);
29+
return config.getBoolean(newPropertyName, value);
30+
}
31+
32+
public static List<String> getList(
33+
InstrumentationConfig config, String deprecatedPropertyName, String newPropertyName) {
34+
warnIfUsed(config, deprecatedPropertyName, newPropertyName);
35+
List<String> value = config.getList(deprecatedPropertyName, emptyList());
36+
return config.getList(newPropertyName, value);
37+
}
38+
39+
private static void warnIfUsed(
40+
InstrumentationConfig config, String deprecatedPropertyName, String newPropertyName) {
2541
if (config.getString(deprecatedPropertyName) != null) {
2642
logger.log(
2743
WARNING,
2844
"Deprecated property \"{0}\" was used; use the \"{1}\" property instead",
2945
new Object[] {deprecatedPropertyName, newPropertyName});
3046
}
31-
boolean value = config.getBoolean(deprecatedPropertyName, defaultValue);
32-
return config.getBoolean(newPropertyName, value);
3347
}
3448

3549
private DeprecatedConfigProperties() {}

testing/agent-exporter/src/main/java/io/opentelemetry/javaagent/testing/http/CapturedHttpHeadersTestConfigSupplier.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ public void customize(AutoConfigurationCustomizer autoConfiguration) {
2222

2323
private static Map<String, String> getTestProperties() {
2424
Map<String, String> testConfig = new HashMap<>();
25-
testConfig.put("otel.instrumentation.http.capture-headers.client.request", "X-Test-Request");
26-
testConfig.put("otel.instrumentation.http.capture-headers.client.response", "X-Test-Response");
27-
testConfig.put("otel.instrumentation.http.capture-headers.server.request", "X-Test-Request");
28-
testConfig.put("otel.instrumentation.http.capture-headers.server.response", "X-Test-Response");
25+
testConfig.put("otel.instrumentation.http.client.capture-request-headers", "X-Test-Request");
26+
testConfig.put("otel.instrumentation.http.client.capture-response-headers", "X-Test-Response");
27+
testConfig.put("otel.instrumentation.http.server.capture-request-headers", "X-Test-Request");
28+
testConfig.put("otel.instrumentation.http.server.capture-response-headers", "X-Test-Response");
2929
return testConfig;
3030
}
3131
}

0 commit comments

Comments
 (0)