Skip to content
6 changes: 3 additions & 3 deletions sentry-jul/src/main/java/io/sentry/jul/SentryHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.jakewharton.nopen.annotation.Open;
import io.sentry.Breadcrumb;
import io.sentry.Hint;
import io.sentry.HubAdapter;
import io.sentry.ScopesAdapter;
import io.sentry.Sentry;
import io.sentry.SentryEvent;
import io.sentry.SentryIntegrationPackageStorage;
Expand Down Expand Up @@ -210,9 +210,9 @@ SentryEvent createEvent(final @NotNull LogRecord record) {
mdcProperties =
CollectionUtils.filterMapEntries(mdcProperties, entry -> entry.getValue() != null);
if (!mdcProperties.isEmpty()) {
// get tags from HubAdapter options to allow getting the correct tags if Sentry has been
// get tags from ScopesAdapter options to allow getting the correct tags if Sentry has been
// initialized somewhere else
final List<String> contextTags = HubAdapter.getInstance().getOptions().getContextTags();
final List<String> contextTags = ScopesAdapter.getInstance().getOptions().getContextTags();
if (!contextTags.isEmpty()) {
for (final String contextTag : contextTags) {
// if mdc tag is listed in SentryOptions, apply as event tag
Expand Down
2 changes: 1 addition & 1 deletion sentry-log4j2/api/sentry-log4j2.api
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public final class io/sentry/log4j2/BuildConfig {

public class io/sentry/log4j2/SentryAppender : org/apache/logging/log4j/core/appender/AbstractAppender {
public static final field MECHANISM_TYPE Ljava/lang/String;
public fun <init> (Ljava/lang/String;Lorg/apache/logging/log4j/core/Filter;Ljava/lang/String;Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Level;Ljava/lang/Boolean;Lio/sentry/ITransportFactory;Lio/sentry/IHub;[Ljava/lang/String;)V
public fun <init> (Ljava/lang/String;Lorg/apache/logging/log4j/core/Filter;Ljava/lang/String;Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Level;Ljava/lang/Boolean;Lio/sentry/ITransportFactory;Lio/sentry/IScopes;[Ljava/lang/String;)V
public fun append (Lorg/apache/logging/log4j/core/LogEvent;)V
public static fun createAppender (Ljava/lang/String;Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Level;Ljava/lang/String;Ljava/lang/Boolean;Lorg/apache/logging/log4j/core/Filter;Ljava/lang/String;)Lio/sentry/log4j2/SentryAppender;
protected fun createBreadcrumb (Lorg/apache/logging/log4j/core/LogEvent;)Lio/sentry/Breadcrumb;
Expand Down
20 changes: 10 additions & 10 deletions sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import io.sentry.Breadcrumb;
import io.sentry.DateUtils;
import io.sentry.Hint;
import io.sentry.HubAdapter;
import io.sentry.IHub;
import io.sentry.IScopes;
import io.sentry.ITransportFactory;
import io.sentry.ScopesAdapter;
import io.sentry.Sentry;
import io.sentry.SentryEvent;
import io.sentry.SentryIntegrationPackageStorage;
Expand Down Expand Up @@ -50,7 +50,7 @@ public class SentryAppender extends AbstractAppender {
private @NotNull Level minimumBreadcrumbLevel = Level.INFO;
private @NotNull Level minimumEventLevel = Level.ERROR;
private final @Nullable Boolean debug;
private final @NotNull IHub hub;
private final @NotNull IScopes scopes;
private final @Nullable List<String> contextTags;

public SentryAppender(
Expand All @@ -61,7 +61,7 @@ public SentryAppender(
final @Nullable Level minimumEventLevel,
final @Nullable Boolean debug,
final @Nullable ITransportFactory transportFactory,
final @NotNull IHub hub,
final @NotNull IScopes scopes,
final @Nullable String[] contextTags) {
super(name, filter, null, true, null);
this.dsn = dsn;
Expand All @@ -73,7 +73,7 @@ public SentryAppender(
}
this.debug = debug;
this.transportFactory = transportFactory;
this.hub = hub;
this.scopes = scopes;
this.contextTags = contextTags != null ? Arrays.asList(contextTags) : null;
}

Expand Down Expand Up @@ -110,7 +110,7 @@ public SentryAppender(
minimumEventLevel,
debug,
null,
HubAdapter.getInstance(),
ScopesAdapter.getInstance(),
contextTags != null ? contextTags.split(",") : null);
}

Expand Down Expand Up @@ -149,13 +149,13 @@ public void append(final @NotNull LogEvent eventObject) {
final Hint hint = new Hint();
hint.set(SENTRY_SYNTHETIC_EXCEPTION, eventObject);

hub.captureEvent(createEvent(eventObject), hint);
scopes.captureEvent(createEvent(eventObject), hint);
}
if (eventObject.getLevel().isMoreSpecificThan(minimumBreadcrumbLevel)) {
final Hint hint = new Hint();
hint.set(LOG4J_LOG_EVENT, eventObject);

hub.addBreadcrumb(createBreadcrumb(eventObject), hint);
scopes.addBreadcrumb(createBreadcrumb(eventObject), hint);
}
}

Expand Down Expand Up @@ -199,9 +199,9 @@ public void append(final @NotNull LogEvent eventObject) {
CollectionUtils.filterMapEntries(
loggingEvent.getContextData().toMap(), entry -> entry.getValue() != null);
if (!contextData.isEmpty()) {
// get tags from HubAdapter options to allow getting the correct tags if Sentry has been
// get tags from ScopesAdapter options to allow getting the correct tags if Sentry has been
// initialized somewhere else
final List<String> contextTags = hub.getOptions().getContextTags();
final List<String> contextTags = scopes.getOptions().getContextTags();
if (contextTags != null && !contextTags.isEmpty()) {
for (final String contextTag : contextTags) {
// if mdc tag is listed in SentryOptions, apply as event tag
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.sentry.log4j2

import io.sentry.HubAdapter
import io.sentry.ITransportFactory
import io.sentry.ScopesAdapter
import io.sentry.Sentry
import io.sentry.SentryLevel
import io.sentry.checkEvent
Expand Down Expand Up @@ -49,7 +49,7 @@ class SentryAppenderTest {
}
loggerContext.start()
val config: Configuration = loggerContext.configuration
val appender = SentryAppender("sentry", null, "http://key@localhost/proj", minimumBreadcrumbLevel, minimumEventLevel, debug, this.transportFactory, HubAdapter.getInstance(), contextTags?.toTypedArray())
val appender = SentryAppender("sentry", null, "http://key@localhost/proj", minimumBreadcrumbLevel, minimumEventLevel, debug, this.transportFactory, ScopesAdapter.getInstance(), contextTags?.toTypedArray())
config.addAppender(appender)

val ref = AppenderRef.createAppenderRef("sentry", null, null)
Expand Down Expand Up @@ -445,6 +445,6 @@ class SentryAppenderTest {
@Test
fun `sets the debug mode`() {
fixture.getSut(debug = true)
assertTrue(HubAdapter.getInstance().options.isDebug)
assertTrue(ScopesAdapter.getInstance().options.isDebug)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import io.sentry.Breadcrumb;
import io.sentry.DateUtils;
import io.sentry.Hint;
import io.sentry.HubAdapter;
import io.sentry.ITransportFactory;
import io.sentry.ScopesAdapter;
import io.sentry.Sentry;
import io.sentry.SentryEvent;
import io.sentry.SentryIntegrationPackageStorage;
Expand Down Expand Up @@ -134,9 +134,9 @@ protected void append(@NotNull ILoggingEvent eventObject) {
CollectionUtils.filterMapEntries(
loggingEvent.getMDCPropertyMap(), entry -> entry.getValue() != null);
if (!mdcProperties.isEmpty()) {
// get tags from HubAdapter options to allow getting the correct tags if Sentry has been
// get tags from ScopesAdapter options to allow getting the correct tags if Sentry has been
// initialized somewhere else
final List<String> contextTags = HubAdapter.getInstance().getOptions().getContextTags();
final List<String> contextTags = ScopesAdapter.getInstance().getOptions().getContextTags();
if (!contextTags.isEmpty()) {
for (final String contextTag : contextTags) {
// if mdc tag is listed in SentryOptions, apply as event tag
Expand Down