Skip to content

Commit ce3c14f

Browse files
committed
Replace IHub with IScopes in core
1 parent 27f2398 commit ce3c14f

File tree

55 files changed

+1092
-793
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1092
-793
lines changed

sentry/src/main/java/io/sentry/Baggage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ public final class Baggage {
3939
@NotNull
4040
public static Baggage fromHeader(final @Nullable String headerValue) {
4141
return Baggage.fromHeader(
42-
headerValue, false, HubAdapter.getInstance().getOptions().getLogger());
42+
headerValue, false, ScopesAdapter.getInstance().getOptions().getLogger());
4343
}
4444

4545
@NotNull
4646
public static Baggage fromHeader(final @Nullable List<String> headerValues) {
4747
return Baggage.fromHeader(
48-
headerValues, false, HubAdapter.getInstance().getOptions().getLogger());
48+
headerValues, false, ScopesAdapter.getInstance().getOptions().getLogger());
4949
}
5050

5151
@ApiStatus.Internal

sentry/src/main/java/io/sentry/DirectoryProcessor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
abstract class DirectoryProcessor {
2020

2121
private static final long ENVELOPE_PROCESSING_DELAY = 100L;
22-
private final @NotNull IHub hub;
22+
private final @NotNull IScopes scopes;
2323
private final @NotNull ILogger logger;
2424
private final long flushTimeoutMillis;
2525
private final Queue<String> processedEnvelopes;
2626

2727
DirectoryProcessor(
28-
final @NotNull IHub hub,
28+
final @NotNull IScopes scopes,
2929
final @NotNull ILogger logger,
3030
final long flushTimeoutMillis,
3131
final int maxQueueSize) {
32-
this.hub = hub;
32+
this.scopes = scopes;
3333
this.logger = logger;
3434
this.flushTimeoutMillis = flushTimeoutMillis;
3535
this.processedEnvelopes =
@@ -86,7 +86,7 @@ public void processDirectory(final @NotNull File directory) {
8686
}
8787

8888
// in case there's rate limiting active, skip processing
89-
final @Nullable RateLimiter rateLimiter = hub.getRateLimiter();
89+
final @Nullable RateLimiter rateLimiter = scopes.getRateLimiter();
9090
if (rateLimiter != null && rateLimiter.isActiveForCategory(DataCategory.All)) {
9191
logger.log(SentryLevel.INFO, "DirectoryProcessor, rate limiting active.");
9292
return;

sentry/src/main/java/io/sentry/EnvelopeSender.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
@ApiStatus.Internal
1818
public final class EnvelopeSender extends DirectoryProcessor implements IEnvelopeSender {
1919

20-
private final @NotNull IHub hub;
20+
private final @NotNull IScopes scopes;
2121
private final @NotNull ISerializer serializer;
2222
private final @NotNull ILogger logger;
2323

2424
public EnvelopeSender(
25-
final @NotNull IHub hub,
25+
final @NotNull IScopes scopes,
2626
final @NotNull ISerializer serializer,
2727
final @NotNull ILogger logger,
2828
final long flushTimeoutMillis,
2929
final int maxQueueSize) {
30-
super(hub, logger, flushTimeoutMillis, maxQueueSize);
31-
this.hub = Objects.requireNonNull(hub, "Hub is required.");
30+
super(scopes, logger, flushTimeoutMillis, maxQueueSize);
31+
this.scopes = Objects.requireNonNull(scopes, "Hub is required.");
3232
this.serializer = Objects.requireNonNull(serializer, "Serializer is required.");
3333
this.logger = Objects.requireNonNull(logger, "Logger is required.");
3434
}
@@ -60,7 +60,7 @@ protected void processFile(final @NotNull File file, final @NotNull Hint hint) {
6060
logger.log(
6161
SentryLevel.ERROR, "Failed to deserialize cached envelope %s", file.getAbsolutePath());
6262
} else {
63-
hub.captureEnvelope(envelope, hint);
63+
scopes.captureEnvelope(envelope, hint);
6464
}
6565

6666
HintUtils.runIfHasTypeLogIfNot(

sentry/src/main/java/io/sentry/Integration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public interface Integration {
1010
/**
1111
* Registers an integration
1212
*
13-
* @param hub the Hub
13+
* @param scopes the Scopes
1414
* @param options the options
1515
*/
16-
void register(@NotNull IHub hub, @NotNull SentryOptions options);
16+
void register(@NotNull IScopes scopes, @NotNull SentryOptions options);
1717
}

sentry/src/main/java/io/sentry/MonitorConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public final class MonitorConfig implements JsonUnknown, JsonSerializable {
2121

2222
public MonitorConfig(final @NotNull MonitorSchedule schedule) {
2323
this.schedule = schedule;
24-
final SentryOptions.Cron defaultCron = HubAdapter.getInstance().getOptions().getCron();
24+
final SentryOptions.Cron defaultCron = ScopesAdapter.getInstance().getOptions().getCron();
2525
if (defaultCron != null) {
2626
this.checkinMargin = defaultCron.getDefaultCheckinMargin();
2727
this.maxRuntime = defaultCron.getDefaultMaxRuntime();

sentry/src/main/java/io/sentry/OutboxSender.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ public final class OutboxSender extends DirectoryProcessor implements IEnvelopeS
3636
@SuppressWarnings("CharsetObjectCanBeUsed")
3737
private static final Charset UTF_8 = Charset.forName("UTF-8");
3838

39-
private final @NotNull IHub hub;
39+
private final @NotNull IScopes scopes;
4040
private final @NotNull IEnvelopeReader envelopeReader;
4141
private final @NotNull ISerializer serializer;
4242
private final @NotNull ILogger logger;
4343

4444
public OutboxSender(
45-
final @NotNull IHub hub,
45+
final @NotNull IScopes scopes,
4646
final @NotNull IEnvelopeReader envelopeReader,
4747
final @NotNull ISerializer serializer,
4848
final @NotNull ILogger logger,
4949
final long flushTimeoutMillis,
5050
final int maxQueueSize) {
51-
super(hub, logger, flushTimeoutMillis, maxQueueSize);
52-
this.hub = Objects.requireNonNull(hub, "Hub is required.");
51+
super(scopes, logger, flushTimeoutMillis, maxQueueSize);
52+
this.scopes = Objects.requireNonNull(scopes, "Hub is required.");
5353
this.envelopeReader = Objects.requireNonNull(envelopeReader, "Envelope reader is required.");
5454
this.serializer = Objects.requireNonNull(serializer, "Serializer is required.");
5555
this.logger = Objects.requireNonNull(logger, "Logger is required.");
@@ -144,7 +144,7 @@ private void processEnvelope(final @NotNull SentryEnvelope envelope, final @NotN
144144
logUnexpectedEventId(envelope, event.getEventId(), currentItem);
145145
continue;
146146
}
147-
hub.captureEvent(event, hint);
147+
scopes.captureEvent(event, hint);
148148
logItemCaptured(currentItem);
149149

150150
if (!waitFlush(hint)) {
@@ -181,7 +181,7 @@ private void processEnvelope(final @NotNull SentryEnvelope envelope, final @NotN
181181
.getTrace()
182182
.setSamplingDecision(extractSamplingDecision(traceContext));
183183
}
184-
hub.captureTransaction(transaction, traceContext, hint);
184+
scopes.captureTransaction(transaction, traceContext, hint);
185185
logItemCaptured(currentItem);
186186

187187
if (!waitFlush(hint)) {
@@ -197,7 +197,7 @@ private void processEnvelope(final @NotNull SentryEnvelope envelope, final @NotN
197197
final SentryEnvelope newEnvelope =
198198
new SentryEnvelope(
199199
envelope.getHeader().getEventId(), envelope.getHeader().getSdkVersion(), item);
200-
hub.captureEnvelope(newEnvelope, hint);
200+
scopes.captureEnvelope(newEnvelope, hint);
201201
logger.log(
202202
SentryLevel.DEBUG,
203203
"%s item %d is being captured.",

sentry/src/main/java/io/sentry/PreviousSessionFinalizer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ final class PreviousSessionFinalizer implements Runnable {
3333

3434
private final @NotNull SentryOptions options;
3535

36-
private final @NotNull IHub hub;
36+
private final @NotNull IScopes scopes;
3737

38-
PreviousSessionFinalizer(final @NotNull SentryOptions options, final @NotNull IHub hub) {
38+
PreviousSessionFinalizer(final @NotNull SentryOptions options, final @NotNull IScopes scopes) {
3939
this.options = options;
40-
this.hub = hub;
40+
this.scopes = scopes;
4141
}
4242

4343
@Override
@@ -116,7 +116,7 @@ public void run() {
116116
// SdkVersion will be outdated.
117117
final SentryEnvelope fromSession =
118118
SentryEnvelope.from(serializer, session, options.getSdkVersion());
119-
hub.captureEnvelope(fromSession);
119+
scopes.captureEnvelope(fromSession);
120120
}
121121
} catch (Throwable e) {
122122
options.getLogger().log(SentryLevel.ERROR, "Error processing previous session.", e);

sentry/src/main/java/io/sentry/SendCachedEnvelopeFireAndForgetIntegration.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public final class SendCachedEnvelopeFireAndForgetIntegration
1818

1919
private final @NotNull SendFireAndForgetFactory factory;
2020
private @Nullable IConnectionStatusProvider connectionStatusProvider;
21-
private @Nullable IHub hub;
21+
private @Nullable IScopes scopes;
2222
private @Nullable SentryOptions options;
2323
private @Nullable SendFireAndForget sender;
2424
private final AtomicBoolean isInitialized = new AtomicBoolean(false);
@@ -35,7 +35,7 @@ public interface SendFireAndForgetDirPath {
3535

3636
public interface SendFireAndForgetFactory {
3737
@Nullable
38-
SendFireAndForget create(@NotNull IHub hub, @NotNull SentryOptions options);
38+
SendFireAndForget create(@NotNull IScopes scopes, @NotNull SentryOptions options);
3939

4040
default boolean hasValidPath(final @Nullable String dirPath, final @NotNull ILogger logger) {
4141
if (dirPath == null || dirPath.isEmpty()) {
@@ -66,8 +66,8 @@ public SendCachedEnvelopeFireAndForgetIntegration(
6666
}
6767

6868
@Override
69-
public void register(final @NotNull IHub hub, final @NotNull SentryOptions options) {
70-
this.hub = Objects.requireNonNull(hub, "Hub is required");
69+
public void register(final @NotNull IScopes scopes, final @NotNull SentryOptions options) {
70+
this.scopes = Objects.requireNonNull(scopes, "Hub is required");
7171
this.options = Objects.requireNonNull(options, "SentryOptions is required");
7272

7373
final String cachedDir = options.getCacheDirPath();
@@ -81,7 +81,7 @@ public void register(final @NotNull IHub hub, final @NotNull SentryOptions optio
8181
.log(SentryLevel.DEBUG, "SendCachedEventFireAndForgetIntegration installed.");
8282
addIntegrationToSdkVersion(getClass());
8383

84-
sendCachedEnvelopes(hub, options);
84+
sendCachedEnvelopes(scopes, options);
8585
}
8686

8787
@Override
@@ -95,14 +95,14 @@ public void close() throws IOException {
9595
@Override
9696
public void onConnectionStatusChanged(
9797
final @NotNull IConnectionStatusProvider.ConnectionStatus status) {
98-
if (hub != null && options != null) {
99-
sendCachedEnvelopes(hub, options);
98+
if (scopes != null && options != null) {
99+
sendCachedEnvelopes(scopes, options);
100100
}
101101
}
102102

103103
@SuppressWarnings({"FutureReturnValueIgnored", "NullAway"})
104104
private synchronized void sendCachedEnvelopes(
105-
final @NotNull IHub hub, final @NotNull SentryOptions options) {
105+
final @NotNull IScopes scopes, final @NotNull SentryOptions options) {
106106
try {
107107
options
108108
.getExecutorService()
@@ -122,7 +122,7 @@ private synchronized void sendCachedEnvelopes(
122122
connectionStatusProvider = options.getConnectionStatusProvider();
123123
connectionStatusProvider.addConnectionStatusObserver(this);
124124

125-
sender = factory.create(hub, options);
125+
sender = factory.create(scopes, options);
126126
}
127127

128128
// skip run only if we're certainly disconnected
@@ -138,7 +138,7 @@ private synchronized void sendCachedEnvelopes(
138138
}
139139

140140
// in case there's rate limiting active, skip processing
141-
final @Nullable RateLimiter rateLimiter = hub.getRateLimiter();
141+
final @Nullable RateLimiter rateLimiter = scopes.getRateLimiter();
142142
if (rateLimiter != null && rateLimiter.isActiveForCategory(DataCategory.All)) {
143143
options
144144
.getLogger()

sentry/src/main/java/io/sentry/SendFireAndForgetEnvelopeSender.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public SendFireAndForgetEnvelopeSender(
2121

2222
@Override
2323
public @Nullable SendCachedEnvelopeFireAndForgetIntegration.SendFireAndForget create(
24-
final @NotNull IHub hub, final @NotNull SentryOptions options) {
25-
Objects.requireNonNull(hub, "Hub is required");
24+
final @NotNull IScopes scopes, final @NotNull SentryOptions options) {
25+
Objects.requireNonNull(scopes, "Hub is required");
2626
Objects.requireNonNull(options, "SentryOptions is required");
2727

2828
final String dirPath = sendFireAndForgetDirPath.getDirPath();
@@ -33,7 +33,7 @@ public SendFireAndForgetEnvelopeSender(
3333

3434
final EnvelopeSender envelopeSender =
3535
new EnvelopeSender(
36-
hub,
36+
scopes,
3737
options.getSerializer(),
3838
options.getLogger(),
3939
options.getFlushTimeoutMillis(),

sentry/src/main/java/io/sentry/SendFireAndForgetOutboxSender.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public SendFireAndForgetOutboxSender(
2121

2222
@Override
2323
public @Nullable SendCachedEnvelopeFireAndForgetIntegration.SendFireAndForget create(
24-
final @NotNull IHub hub, final @NotNull SentryOptions options) {
25-
Objects.requireNonNull(hub, "Hub is required");
24+
final @NotNull IScopes scopes, final @NotNull SentryOptions options) {
25+
Objects.requireNonNull(scopes, "Hub is required");
2626
Objects.requireNonNull(options, "SentryOptions is required");
2727

2828
final String dirPath = sendFireAndForgetDirPath.getDirPath();
@@ -33,7 +33,7 @@ public SendFireAndForgetOutboxSender(
3333

3434
final OutboxSender outboxSender =
3535
new OutboxSender(
36-
hub,
36+
scopes,
3737
options.getEnvelopeReader(),
3838
options.getSerializer(),
3939
options.getLogger(),

0 commit comments

Comments
 (0)