feat(scope): remove Hub from Transaction#2122
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit db6e223. Configure here.
| } | ||
|
|
||
| $samplingContext = DynamicSamplingContext::fromTransaction($this->transaction, $this->hub); | ||
| $samplingContext = DynamicSamplingContext::fromTransaction($this->transaction, SentrySdk::getClient()); |
There was a problem hiding this comment.
Bug: getDynamicSamplingContext now uses SentrySdk::getClient(), which may return NoOpClient if a custom hub is used without updating the global client, breaking trace propagation.
Severity: HIGH
Suggested Fix
To build the Dynamic Sampling Context, use the client from the current hub instead of the one from SentrySdk::getClient(). This ensures the correct client configuration is used, especially in multi-hub scenarios where the global client may not be the one associated with the current transaction.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/Tracing/Transaction.php#L93
Potential issue: The function `getDynamicSamplingContext()` was changed to use
`SentrySdk::getClient()` instead of the hub's client. `SentrySdk::getClient()` resolves
the client from the isolation or global scope, not the current hub. In scenarios where a
custom hub is set via `SentrySdk::setCurrentHub()` without also updating the global
client (e.g., in multi-tenant apps), `SentrySdk::getClient()` will return a
`NoOpClient`. This results in an incomplete Dynamic Sampling Context (DSC) missing
`public_key`, `release`, and `environment`, which breaks trace propagation between
services.
Did we get this right? 👍 / 👎 to inform future reviews.
5c69016 to
2e630c8
Compare
db6e223 to
14d6804
Compare
2e630c8 to
012018d
Compare
14d6804 to
0352e56
Compare
012018d to
3b8b293
Compare
0352e56 to
3a5d496
Compare

This PR removes the
Hubfrom the transaction and instead replaces it withClientInterfacein some instances.