Skip to content

Commit cb4c5e6

Browse files
committed
improve
1 parent 9343cac commit cb4c5e6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,13 @@ protected void captureLog(@NotNull LogEvent loggingEvent) {
277277
event.setExtra("marker", loggingEvent.getMarker().toString());
278278
}
279279

280-
final Map<String, String> contextData = loggingEvent.getContextData().toMap();
281-
if (contextData != null) {
280+
final Map<String, String> contextData =
281+
CollectionUtils.filterMapEntries(
282+
loggingEvent.getContextData().toMap(), entry -> entry.getValue() != null);
283+
if (!contextData.isEmpty()) {
282284
// get tags from ScopesAdapter options to allow getting the correct tags if Sentry has been
283285
// initialized somewhere else
284-
final @NotNull List<String> contextTags = scopes.getOptions().getContextTags();
286+
final List<String> contextTags = scopes.getOptions().getContextTags();
285287
LoggerPropertiesUtil.applyPropertiesToEvent(event, contextTags, contextData);
286288
// put the rest of mdc tags in contexts
287289
if (!contextData.isEmpty()) {

0 commit comments

Comments
 (0)