Skip to content

Commit 9527b78

Browse files
committed
- use compile dependency on `:javaagent-bootstrap` and do runtime check before use.
1 parent 7683547 commit 9527b78

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/library-autoconfigure/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
base.archivesName.set("${base.archivesName.get()}-autoconfigure")
66

77
dependencies {
8-
implementation(project(":javaagent-bootstrap"))
8+
compileOnly(project(":javaagent-bootstrap"))
99
library("org.apache.logging.log4j:log4j-core:2.17.0")
1010

1111
testImplementation(project(":instrumentation:log4j:log4j-context-data:log4j-context-data-common:testing"))

instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/log4j/contextdata/v2_17/OpenTelemetryContextDataProvider.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ public Map<String, String> supplyContextData() {
4848
contextData.put(TRACE_ID, spanContext.getTraceId());
4949
contextData.put(SPAN_ID, spanContext.getSpanId());
5050
contextData.put(TRACE_FLAGS, spanContext.getTraceFlags().asHex());
51-
contextData.putAll(ConfiguredResourceAttributesHolder.getResourceAttributes());
51+
52+
try {
53+
Class.forName("io.opentelemetry.javaagent.bootstrap.ConfiguredResourceAttributesHolder");
54+
contextData.putAll(ConfiguredResourceAttributesHolder.getResourceAttributes());
55+
} catch (ClassNotFoundException ok) {
56+
// This probably shouldn't happen, however if it does happen we don't care.
57+
}
5258

5359
if (BAGGAGE_ENABLED) {
5460
Baggage baggage = Baggage.fromContext(context);

0 commit comments

Comments
 (0)