Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
333 changes: 250 additions & 83 deletions sentry/api/sentry.api

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions sentry/src/main/java/io/sentry/Baggage.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public final class Baggage {
@NotNull
public static Baggage fromHeader(final @Nullable String headerValue) {
return Baggage.fromHeader(
headerValue, false, HubAdapter.getInstance().getOptions().getLogger());
headerValue, false, ScopesAdapter.getInstance().getOptions().getLogger());
}

@NotNull
public static Baggage fromHeader(final @Nullable List<String> headerValues) {
return Baggage.fromHeader(
headerValues, false, HubAdapter.getInstance().getOptions().getLogger());
headerValues, false, ScopesAdapter.getInstance().getOptions().getLogger());
}

@ApiStatus.Internal
Expand Down
8 changes: 4 additions & 4 deletions sentry/src/main/java/io/sentry/DirectoryProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
abstract class DirectoryProcessor {

private static final long ENVELOPE_PROCESSING_DELAY = 100L;
private final @NotNull IHub hub;
private final @NotNull IScopes scopes;
private final @NotNull ILogger logger;
private final long flushTimeoutMillis;
private final Queue<String> processedEnvelopes;

DirectoryProcessor(
final @NotNull IHub hub,
final @NotNull IScopes scopes,
final @NotNull ILogger logger,
final long flushTimeoutMillis,
final int maxQueueSize) {
this.hub = hub;
this.scopes = scopes;
this.logger = logger;
this.flushTimeoutMillis = flushTimeoutMillis;
this.processedEnvelopes =
Expand Down Expand Up @@ -86,7 +86,7 @@ public void processDirectory(final @NotNull File directory) {
}

// in case there's rate limiting active, skip processing
final @Nullable RateLimiter rateLimiter = hub.getRateLimiter();
final @Nullable RateLimiter rateLimiter = scopes.getRateLimiter();
if (rateLimiter != null && rateLimiter.isActiveForCategory(DataCategory.All)) {
logger.log(SentryLevel.INFO, "DirectoryProcessor, rate limiting active.");
return;
Expand Down
10 changes: 5 additions & 5 deletions sentry/src/main/java/io/sentry/EnvelopeSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
@ApiStatus.Internal
public final class EnvelopeSender extends DirectoryProcessor implements IEnvelopeSender {

private final @NotNull IHub hub;
private final @NotNull IScopes scopes;
private final @NotNull ISerializer serializer;
private final @NotNull ILogger logger;

public EnvelopeSender(
final @NotNull IHub hub,
final @NotNull IScopes scopes,
final @NotNull ISerializer serializer,
final @NotNull ILogger logger,
final long flushTimeoutMillis,
final int maxQueueSize) {
super(hub, logger, flushTimeoutMillis, maxQueueSize);
this.hub = Objects.requireNonNull(hub, "Hub is required.");
super(scopes, logger, flushTimeoutMillis, maxQueueSize);
this.scopes = Objects.requireNonNull(scopes, "Hub is required.");
this.serializer = Objects.requireNonNull(serializer, "Serializer is required.");
this.logger = Objects.requireNonNull(logger, "Logger is required.");
}
Expand Down Expand Up @@ -60,7 +60,7 @@ protected void processFile(final @NotNull File file, final @NotNull Hint hint) {
logger.log(
SentryLevel.ERROR, "Failed to deserialize cached envelope %s", file.getAbsolutePath());
} else {
hub.captureEnvelope(envelope, hint);
scopes.captureEnvelope(envelope, hint);
}

HintUtils.runIfHasTypeLogIfNot(
Expand Down
1 change: 1 addition & 0 deletions sentry/src/main/java/io/sentry/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@Deprecated
public final class Hub implements IHub, MetricsApi.IMetricsInterface {

private volatile @NotNull SentryId lastEventId;
Expand Down
22 changes: 13 additions & 9 deletions sentry/src/main/java/io/sentry/HubAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* @deprecated use {@link ScopesAdapter} instead
*/
@Deprecated
public final class HubAdapter implements IHub {

private static final HubAdapter INSTANCE = new HubAdapter();
Expand Down Expand Up @@ -50,7 +54,7 @@ public boolean isEnabled() {
@ApiStatus.Internal
@Override
public @NotNull SentryId captureEnvelope(@NotNull SentryEnvelope envelope, @Nullable Hint hint) {
return Sentry.getCurrentHub().captureEnvelope(envelope, hint);
return Sentry.getCurrentScopes().captureEnvelope(envelope, hint);
}

@Override
Expand Down Expand Up @@ -186,7 +190,7 @@ public void flush(long timeoutMillis) {

@Override
public @NotNull IHub clone() {
return Sentry.getCurrentHub().clone();
return Sentry.getCurrentScopes().clone();
}

@Override
Expand All @@ -195,7 +199,7 @@ public void flush(long timeoutMillis) {
@Nullable TraceContext traceContext,
@Nullable Hint hint,
@Nullable ProfilingTraceData profilingTraceData) {
return Sentry.getCurrentHub()
return Sentry.getCurrentScopes()
.captureTransaction(transaction, traceContext, hint, profilingTraceData);
}

Expand All @@ -217,23 +221,23 @@ public void setSpanContext(
final @NotNull Throwable throwable,
final @NotNull ISpan span,
final @NotNull String transactionName) {
Sentry.getCurrentHub().setSpanContext(throwable, span, transactionName);
Sentry.getCurrentScopes().setSpanContext(throwable, span, transactionName);
}

@Override
public @Nullable ISpan getSpan() {
return Sentry.getCurrentHub().getSpan();
return Sentry.getCurrentScopes().getSpan();
}

@Override
@ApiStatus.Internal
public @Nullable ITransaction getTransaction() {
return Sentry.getCurrentHub().getTransaction();
return Sentry.getCurrentScopes().getTransaction();
}

@Override
public @NotNull SentryOptions getOptions() {
return Sentry.getCurrentHub().getOptions();
return Sentry.getCurrentScopes().getOptions();
}

@Override
Expand Down Expand Up @@ -271,11 +275,11 @@ public void reportFullyDisplayed() {
@ApiStatus.Internal
@Override
public @Nullable RateLimiter getRateLimiter() {
return Sentry.getCurrentHub().getRateLimiter();
return Sentry.getCurrentScopes().getRateLimiter();
}

@Override
public @NotNull MetricsApi metrics() {
return Sentry.getCurrentHub().metrics();
return Sentry.getCurrentScopes().metrics();
}
}
Loading