Skip to content

Commit 5eec183

Browse files
committed
fix
1 parent 81b7e3d commit 5eec183

File tree

1 file changed

+9
-1
lines changed
  • instrumentation/log4j/log4j-appender-2.17/library/src/main/java/io/opentelemetry/instrumentation/log4j/appender/v2_17/internal

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import io.opentelemetry.semconv.ExceptionAttributes;
1717
import java.io.PrintWriter;
1818
import java.io.StringWriter;
19+
import java.util.ArrayList;
1920
import java.util.List;
2021
import java.util.function.Supplier;
2122
import javax.annotation.Nullable;
@@ -76,9 +77,16 @@ public LogEventMapper(
7677
this.captureExperimentalAttributes = captureExperimentalAttributes;
7778
this.captureMapMessageAttributes = captureMapMessageAttributes;
7879
this.captureMarkerAttribute = captureMarkerAttribute;
79-
this.captureContextDataAttributes = captureContextDataAttributes;
8080
this.captureAllContextDataAttributes =
8181
captureContextDataAttributes.size() == 1 && captureContextDataAttributes.get(0).equals("*");
82+
// If captureEventName is enabled, ensure "event.name" is in the list that we loop over
83+
if (captureEventName
84+
&& !captureAllContextDataAttributes
85+
&& !captureContextDataAttributes.contains("event.name")) {
86+
captureContextDataAttributes = new ArrayList<>(captureContextDataAttributes);
87+
captureContextDataAttributes.add("event.name");
88+
}
89+
this.captureContextDataAttributes = captureContextDataAttributes;
8290
this.captureEventName = captureEventName;
8391
}
8492

0 commit comments

Comments
 (0)