Class LoggerPropertiesUtil

java.lang.Object
io.sentry.util.LoggerPropertiesUtil

@Internal public final class LoggerPropertiesUtil extends Object
Utility class for applying logger properties (e.g. MDC) to Sentry events and log attributes.
  • Constructor Details

    • LoggerPropertiesUtil

      public LoggerPropertiesUtil()
  • Method Details

    • applyPropertiesToEvent

      @Internal public static void applyPropertiesToEvent(@NotNull @NotNull SentryEvent event, @NotNull @NotNull List<String> targetKeys, @NotNull @NotNull Map<String,String> properties, @NotNull @NotNull String contextName)
      Applies logger properties from a map to a Sentry event as tags and context. The properties that have keys matching any of the `targetKeys` will be applied as tags, while the others will be reported in an ad-hoc context.
      Parameters:
      event - the Sentry event to add tags to
      targetKeys - the list of property keys to apply as tags
      properties - the properties map (e.g. MDC) - this map will be modified by removing properties which were applied as tags
      contextName - the name of the context to use for leftover properties
    • applyPropertiesToEvent

      public static void applyPropertiesToEvent(@NotNull @NotNull SentryEvent event, @NotNull @NotNull List<String> targetKeys, @NotNull @NotNull Map<String,String> properties)
    • applyPropertiesToAttributes

      @Internal public static void applyPropertiesToAttributes(@NotNull @NotNull SentryAttributes attributes, @NotNull @NotNull List<String> targetKeys, @NotNull @NotNull Map<String,String> properties)
      Applies logger properties from a properties map to SentryAttributes for logs. Only the properties with keys that are found in `targetKeys` will be applied as attributes. Properties with null values are filtered out.
      Parameters:
      attributes - the SentryAttributes to add the properties to
      targetKeys - the list of property keys to apply as attributes
      properties - the properties map (e.g. MDC)