-
-
Notifications
You must be signed in to change notification settings - Fork 470
feat(scope): remove Hub from Transaction #2122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,18 +9,12 @@ | |
| use Sentry\Options; | ||
| use Sentry\Profiling\Profiler; | ||
| use Sentry\SentrySdk; | ||
| use Sentry\State\HubInterface; | ||
|
|
||
| /** | ||
| * This class stores all the information about a Transaction. | ||
| */ | ||
| final class Transaction extends Span | ||
| { | ||
| /** | ||
| * @var HubInterface The hub instance | ||
| */ | ||
| private $hub; | ||
|
|
||
| /** | ||
| * @var string Name of the transaction | ||
| */ | ||
|
|
@@ -45,15 +39,13 @@ final class Transaction extends Span | |
| * Span constructor. | ||
| * | ||
| * @param TransactionContext $context The context to create the transaction with | ||
| * @param HubInterface|null $hub Instance of a hub to flush the transaction | ||
| * | ||
| * @internal | ||
| */ | ||
| public function __construct(TransactionContext $context, ?HubInterface $hub = null) | ||
| public function __construct(TransactionContext $context) | ||
| { | ||
| parent::__construct($context); | ||
|
|
||
| $this->hub = $hub ?? SentrySdk::getCurrentHub(); | ||
| $this->name = $context->getName(); | ||
| $this->metadata = $context->getMetadata(); | ||
| $this->transaction = $this; | ||
|
|
@@ -98,7 +90,7 @@ public function getDynamicSamplingContext(): DynamicSamplingContext | |
| return $this->metadata->getDynamicSamplingContext(); | ||
| } | ||
|
|
||
| $samplingContext = DynamicSamplingContext::fromTransaction($this->transaction, $this->hub); | ||
| $samplingContext = DynamicSamplingContext::fromTransaction($this->transaction, SentrySdk::getClient()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Suggested FixTo build the Dynamic Sampling Context, use the client from the current hub instead of the one from Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
| $this->getMetadata()->setDynamicSamplingContext($samplingContext); | ||
|
|
||
| return $samplingContext; | ||
|
|
@@ -123,7 +115,7 @@ public function initSpanRecorder(int $maxSpans = 1000): self | |
| public function initProfiler(?Options $options = null): Profiler | ||
| { | ||
| if ($this->profiler === null) { | ||
| $this->profiler = new Profiler($options ?? $this->hub->getClient()->getOptions()); | ||
| $this->profiler = new Profiler($options ?? SentrySdk::getClient()->getOptions()); | ||
| } | ||
|
|
||
| return $this->profiler; | ||
|
|
@@ -188,6 +180,6 @@ public function finish(?float $endTimestamp = null): ?EventId | |
| } | ||
| } | ||
|
|
||
| return $this->hub->captureEvent($event); | ||
| return \Sentry\captureEvent($event); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.