Skip to content

Commit 6863c2e

Browse files
committed
Prevent closure allocation in GetTransaction
1 parent ef0ff93 commit 6863c2e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/Sentry/HubExtensions.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,14 @@ internal static ITransactionTracer StartTransaction(
242242
_ => hub.StartTransaction(context, customSamplingContext)
243243
};
244244

245-
internal static ITransactionTracer? GetTransaction(this IHub hub)
245+
internal static ITransactionTracer ? GetTransaction(this IHub hub)
246246
{
247-
ITransactionTracer? transaction = null;
247+
if (hub is Hub fullHub)
248+
{
249+
return fullHub.ScopeManager.GetCurrent().Key.Transaction;
250+
}
251+
252+
ITransactionTracer ? transaction = null;
248253
hub.ConfigureScope(scope => transaction = scope.Transaction);
249254
return transaction;
250255
}

0 commit comments

Comments
 (0)