Skip to content

Commit 38b07b7

Browse files
committed
improve
1 parent cb4c5e6 commit 38b07b7

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
- Attach MDC properties to logs as attributes ([#4786](https://github.com/getsentry/sentry-java/pull/4786))
88
- MDC properties set using supported logging frameworks (Logback, Log4j2, java.util.Logging) are now attached to structured logs as attributes.
99
- This means that you will be able to filter/aggregate logs in the product based on these properties.
10-
- Only properties with keys matching the configured `contextTags` are sent as attributes. This is consistent with how MDC properties are applied as tags to events.
11-
- To avoid sending certain properties, use the `beforeSendLog` hook. You can also set up [Advanced Data Scrubbing rules](https://docs.sentry.io/security-legal-pii/scrubbing/advanced-datascrubbing/) to redact sensitive information.
12-
- Note that keys containing spaces are not supported.
10+
- Only properties with keys matching the configured `contextTags` are sent as log attributes.
11+
- You can configure which properties are sent using `options.setContextTags` if initalizing manually, or by specifying a comma-separated list of keys with a `context-tags` entry in `sentry.properties` or `sentry.contex-tags` in `application.properties`.
12+
- Note that keys containing spaces are not supported.
1313

1414
### Fixes
1515

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ protected void captureLog(@NotNull LogEvent loggingEvent) {
232232
}
233233

234234
final @NotNull Map<String, String> contextData = loggingEvent.getContextData().toMap();
235-
final @NotNull List<String> contextTags = ScopesAdapter.getInstance().getOptions().getContextTags();
235+
final @NotNull List<String> contextTags =
236+
ScopesAdapter.getInstance().getOptions().getContextTags();
236237
LoggerPropertiesUtil.applyPropertiesToAttributes(attributes, contextTags, contextData);
237238

238239
final @NotNull SentryLogParameters params = SentryLogParameters.create(attributes);
@@ -278,8 +279,8 @@ protected void captureLog(@NotNull LogEvent loggingEvent) {
278279
}
279280

280281
final Map<String, String> contextData =
281-
CollectionUtils.filterMapEntries(
282-
loggingEvent.getContextData().toMap(), entry -> entry.getValue() != null);
282+
CollectionUtils.filterMapEntries(
283+
loggingEvent.getContextData().toMap(), entry -> entry.getValue() != null);
283284
if (!contextData.isEmpty()) {
284285
// get tags from ScopesAdapter options to allow getting the correct tags if Sentry has been
285286
// initialized somewhere else

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ protected void captureLog(@NotNull ILoggingEvent loggingEvent) {
188188
}
189189

190190
final @NotNull Map<String, String> mdcProperties = loggingEvent.getMDCPropertyMap();
191-
final @NotNull List<String> contextTags = ScopesAdapter.getInstance().getOptions().getContextTags();
191+
final @NotNull List<String> contextTags =
192+
ScopesAdapter.getInstance().getOptions().getContextTags();
192193
LoggerPropertiesUtil.applyPropertiesToAttributes(attributes, contextTags, mdcProperties);
193194

194195
final @NotNull SentryLogParameters params = SentryLogParameters.create(attributes);

sentry/api/sentry.api

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7083,7 +7083,6 @@ public final class io/sentry/util/LogUtils {
70837083
public final class io/sentry/util/LoggerPropertiesUtil {
70847084
public fun <init> ()V
70857085
public static fun applyPropertiesToAttributes (Lio/sentry/SentryAttributes;Ljava/util/List;Ljava/util/Map;)V
7086-
public static fun applyPropertiesToAttributes (Lio/sentry/SentryAttributes;Ljava/util/Map;)V
70877086
public static fun applyPropertiesToEvent (Lio/sentry/SentryEvent;Ljava/util/List;Ljava/util/Map;)V
70887087
}
70897088

0 commit comments

Comments
 (0)