Skip to content

Commit 738c5fa

Browse files
authored
POTEL 18 - Use correct SentryOptions for SentryClient constructor (#3490)
* replace hub with scopes * Add Scopes * Introduce `IScopes` interface. * Replace `IHub` with `IScopes` in core * Replace `IHub` with `IScopes` in android core * Replace `IHub` with `IScopes` in android integrations * Replace `IHub` with `IScopes` in apollo integrations * Replace `IHub` with `IScopes` in okhttp integration * Replace `IHub` with `IScopes` in graphql integration * Replace `IHub` with `IScopes` in logging integrations * Replace `IHub` with `IScopes` in more integrations * Replace `IHub` with `IScopes` in OTel integration * Replace `IHub` with `IScopes` in Spring 5 / Spring Boot 2 integrations * Replace `IHub` with `IScopes` in Spring 6 / Spring Boot 3 integrations * Replace `IHub` with `IScopes` in samples * gitscopes -> github * Replace ThreadLocal with ScopesStorage * Move client and throwable to span map to scope * Add global scope * use global scope in Scopes * Implement pushScope popScope and withScope for Scopes * Add pushIsolationScope; add fork methods to ISCope * Use separate scopes for current, isolation and global scope; rename mainScopes to rootScopes * Allow controlling which scope configureScope uses * Combine scopes * Use new API for CRONS integrations * Add lifecycle helper * Change spring integrations to use new API * Use new API in servlet integrations * Use new API for kotlin coroutines and wrapers for Supplier/Callable * Discussion TODOs * Fix breadcrumb ordering * Mark TODOS with [HSM] * Add getGlobalScope and forkedRootScopes to IScopes * Fix EventProcessor ordering on scopes * Reuse code in Scopes * No longer replace global scope * Replace hub occurrences in comments, var names etc. * Implement ScopesTest * Implement CombinedScopeViewTest * Fix combined contexts * Use combined scopes for cross platform * Changes according to reviews of previous PRs * more * even more * isEnabled checks client instead of having a property on Scopes * Use SentryOptions.empty * Remove Hub * Use OpenTelemetry for Performance and Scopes propagation * Promote certain span attributes * Use OTel in Sentry API * Deduplicate SpanInfo extraction * Forward Sentry API to Sentry through OTel * Use OTel status for Sentry span API * POTel Tracing * fix root span detection (remote flag), and scope closing * Inherit OTel span IDs when sending to sentry * Fix tracing; parse incoming baggage; add baggage to outgoing * Cleanup * Move sampling logic to OTel Sampler * Remove internal span attributes so they are not sent to Sentry * Use transaction name * remove obsolete comment * Keep OTel and Sentry span name/op in sync * more cleanup * Make it possible to ignore span origins * Reuse TracesSampler instance * Catch exceptions thrown by integration.close * Set NoOpSpanFactory as property default * Use correct SentryOptions for SentryClient ctor
1 parent 9f7e431 commit 738c5fa

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

sentry-android-core/src/test/java/io/sentry/android/core/InternalSentrySdkTest.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,20 +199,16 @@ class InternalSentrySdkTest {
199199

200200
@Test
201201
fun `current scope returns obj when scopes is active`() {
202-
val options = SentryOptions().apply {
203-
dsn = "https://key@uri/1234567"
204-
}
205-
Sentry.setCurrentScopes(createTestScopes(options))
202+
val fixture = Fixture()
203+
fixture.init(context)
206204
val scope = InternalSentrySdk.getCurrentScope()
207205
assertNotNull(scope)
208206
}
209207

210208
@Test
211209
fun `current scope returns a copy of the scope`() {
212-
val options = SentryOptions().apply {
213-
dsn = "https://key@uri/1234567"
214-
}
215-
Sentry.setCurrentScopes(createTestScopes(options))
210+
val fixture = Fixture()
211+
fixture.init(context)
216212
Sentry.addBreadcrumb("test")
217213
Sentry.configureScope(ScopeType.CURRENT) { scope -> scope.addBreadcrumb(Breadcrumb("currentBreadcrumb")) }
218214
Sentry.configureScope(ScopeType.ISOLATION) { scope -> scope.addBreadcrumb(Breadcrumb("isolationBreadcrumb")) }

sentry/src/main/java/io/sentry/Sentry.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,7 @@ private static synchronized void init(
284284
final IScope rootIsolationScope = new Scope(options);
285285

286286
scopes.close(true);
287-
globalScope.replaceOptions(options);
288-
rootScopes = new Scopes(rootScope, rootIsolationScope, globalScope, "Sentry.init");
289-
getScopesStorage().set(rootScopes);
290-
globalScope.bindClient(new SentryClient(options));
287+
globalScope.bindClient(new SentryClient(rootScopes.getOptions()));
291288

292289
// If the executorService passed in the init is the same that was previously closed, we have to
293290
// set a new one

0 commit comments

Comments
 (0)