Skip to content
Prev Previous commit
Next Next commit
Prevent closure allocation in GetTransaction
  • Loading branch information
KnapSac committed Jun 10, 2025
commit c53044e90fcc5aa682ae0c78e7dfc12e5c6dc516
9 changes: 7 additions & 2 deletions src/Sentry/HubExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,14 @@ internal static ITransactionTracer StartTransaction(
_ => hub.StartTransaction(context, customSamplingContext)
};

internal static ITransactionTracer? GetTransaction(this IHub hub)
internal static ITransactionTracer ? GetTransaction(this IHub hub)
{
ITransactionTracer? transaction = null;
if (hub is Hub fullHub)
{
return fullHub.ScopeManager.GetCurrent().Key.Transaction;
}

ITransactionTracer ? transaction = null;
hub.ConfigureScope(scope => transaction = scope.Transaction);
return transaction;
}
Expand Down