Skip to content

Commit 77f9bcc

Browse files
committed
remove non-declarative configuration
1 parent 6ebecb3 commit 77f9bcc

File tree

2 files changed

+18
-37
lines changed

2 files changed

+18
-37
lines changed

instrumentation-api-incubator/javaagent-testing/build.gradle.kts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,8 @@ dependencies {
1010

1111
tasks {
1212
test {
13-
jvmArgs("-Dotel.instrumentation.http.client.emit-experimental-telemetry=true")
14-
jvmArgs("-Dotel.instrumentation.http.client.url-template-rules=http://localhost:.*/hello/.*,/hello/*")
15-
}
16-
17-
val declarativeConfigTest by registering(Test::class) {
18-
testClassesDirs = sourceSets.test.get().output.classesDirs
19-
classpath = sourceSets.test.get().runtimeClasspath
20-
2113
jvmArgs(
2214
"-Dotel.experimental.config.file=$projectDir/src/test/resources/declarative-config.yaml"
2315
)
2416
}
25-
26-
check {
27-
dependsOn(declarativeConfigTest)
28-
}
2917
}

javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/http/RegexUrlTemplateCustomizerInitializer.java

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,26 @@ public void beforeAgent(AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemet
3030
// url template is emitted only when http client experimental telemetry is enabled
3131
boolean urlTemplateEnabled =
3232
config.getBoolean("otel.instrumentation.http.client.emit-experimental-telemetry", false);
33-
if (!urlTemplateEnabled) {
33+
if (!urlTemplateEnabled || !config.isDeclarative()) {
3434
return;
3535
}
36-
if (config.isDeclarative()) {
37-
DeclarativeConfigProperties configuration =
38-
config.getDeclarativeConfig("http").getStructured("client", empty());
39-
configuration
40-
.getStructuredList("url_template_rules", emptyList())
41-
.forEach(
42-
rule -> {
43-
String patternString = rule.getString("pattern", "");
44-
String template = rule.getString("template", "");
45-
if (patternString.isEmpty() || template.isEmpty()) {
46-
return;
47-
}
48-
boolean override = rule.getBoolean("override", false);
49-
Pattern pattern = toPattern(patternString);
50-
if (pattern != null) {
51-
UrlTemplateRules.addRule(pattern, template, override);
52-
}
53-
});
54-
} else {
55-
String rules = config.getString("otel.instrumentation.http.client.url-template-rules");
56-
if (rules != null && !rules.isEmpty()) {
57-
parse(rules);
58-
}
59-
}
36+
DeclarativeConfigProperties configuration =
37+
config.getDeclarativeConfig("http").getStructured("client", empty());
38+
configuration
39+
.getStructuredList("url_template_rules", emptyList())
40+
.forEach(
41+
rule -> {
42+
String patternString = rule.getString("pattern", "");
43+
String template = rule.getString("template", "");
44+
if (patternString.isEmpty() || template.isEmpty()) {
45+
return;
46+
}
47+
boolean override = rule.getBoolean("override", false);
48+
Pattern pattern = toPattern(patternString);
49+
if (pattern != null) {
50+
UrlTemplateRules.addRule(pattern, template, override);
51+
}
52+
});
6053
}
6154

6255
// visible for testing

0 commit comments

Comments
 (0)