Skip to content

Commit 8763d70

Browse files
committed
change scopes
1 parent c0027c2 commit 8763d70

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

sentry-ktor-client/src/main/java/io/sentry/ktorClient/SentryKtorClientPlugin.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ public val SentryKtorClientPlugin: ClientPlugin<SentryKtorClientPluginConfig> =
106106
val parentSpan: ISpan? =
107107
if (forceScopes) scopes.getSpan()
108108
else {
109-
if (Platform.isAndroid()) scopes.transaction else scopes.span
109+
val currentScopes = Sentry.getCurrentScopes()
110+
if (Platform.isAndroid()) currentScopes.transaction else currentScopes.span
110111
}
111112

112113
val spanOp = "http.client"
@@ -164,10 +165,20 @@ public val SentryKtorClientPlugin: ClientPlugin<SentryKtorClientPluginConfig> =
164165
failedRequestStatusCodes.any { it.isInRange(response.status.value) } &&
165166
PropagationTargetsUtils.contain(failedRequestTargets, request.url.toString())
166167
) {
167-
SentryKtorClientUtils.captureClientError(scopes, request, response)
168+
SentryKtorClientUtils.captureClientError(
169+
if (forceScopes) scopes else Sentry.getCurrentScopes(),
170+
request,
171+
response,
172+
)
168173
}
169174

170-
SentryKtorClientUtils.addBreadcrumb(scopes, request, response, startTimestamp, endTimestamp)
175+
SentryKtorClientUtils.addBreadcrumb(
176+
if (forceScopes) scopes else Sentry.getCurrentScopes(),
177+
request,
178+
response,
179+
startTimestamp,
180+
endTimestamp,
181+
)
171182

172183
response.call.attributes.getOrNull(requestSpanKey)?.let { span ->
173184
var result: ISpan? = span

0 commit comments

Comments
 (0)