Skip to content

feat(scope): update aggregator flush to use a client#2125

Open
Litarnus wants to merge 1 commit into
remove-hub-from-transactionfrom
aggregator-flush-signatures
Open

feat(scope): update aggregator flush to use a client#2125
Litarnus wants to merge 1 commit into
remove-hub-from-transactionfrom
aggregator-flush-signatures

Conversation

@Litarnus

Copy link
Copy Markdown
Contributor

This PR removes the Hub from the flush signature and replaces it with the Client

@Litarnus Litarnus marked this pull request as ready for review June 22, 2026 14:38
Comment thread src/Logs/LogsAggregator.php
$event = Event::createLogs()->setLogs($logs->drain());

return $hub->captureEvent($event);
return $client->captureEvent($event);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The direct call to client->captureEvent($event) during flush operations bypasses the hub, causing the event to be sent with a null scope and losing all contextual data.
Severity: HIGH

Suggested Fix

Instead of passing the Client to the flush methods in LogsAggregator and MetricsAggregator, pass the Hub instance. Then, inside the flush method, call hub->captureEvent($event) instead of $client->captureEvent($event). This will ensure that the event is processed with the correct scope from the hub before being sent.

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/Logs/LogsAggregator.php#L178

Potential issue: The refactoring in `LogsAggregator::flush()` and
`MetricsAggregator::flush()` now calls `$client->captureEvent($event)` directly, instead
of going through the hub. This bypasses the mechanism that attaches the current scope to
the event. As a result, when logs or metrics are flushed, all scope-level context—such
as user data, tags, breadcrumbs, and trace information—is lost. The events are sent
without this critical enrichment, which severely degrades their value for debugging and
analysis. The previous implementation correctly used `$hub->captureEvent()`, which
ensured the scope was applied.

Also affects:

  • src/Metrics/MetricsAggregator.php:143~143

Did we get this right? 👍 / 👎 to inform future reviews.

@Litarnus Litarnus force-pushed the remove-hub-from-transaction branch from db6e223 to 14d6804 Compare June 22, 2026 22:12
@Litarnus Litarnus force-pushed the aggregator-flush-signatures branch from 8d1c6f0 to 4d924bf Compare June 22, 2026 22:12
@Litarnus Litarnus force-pushed the remove-hub-from-transaction branch from 14d6804 to 0352e56 Compare June 22, 2026 22:46
@Litarnus Litarnus force-pushed the aggregator-flush-signatures branch from 4d924bf to 471adb8 Compare June 22, 2026 22:46
@Litarnus Litarnus force-pushed the remove-hub-from-transaction branch from 0352e56 to 3a5d496 Compare June 22, 2026 22:54
@Litarnus Litarnus force-pushed the aggregator-flush-signatures branch from 471adb8 to 52283d4 Compare June 22, 2026 22:54
Comment thread src/Logs/LogsAggregator.php
@Litarnus Litarnus force-pushed the remove-hub-from-transaction branch from 3a5d496 to 0f25f5f Compare June 24, 2026 11:14
@Litarnus Litarnus force-pushed the aggregator-flush-signatures branch from 52283d4 to 7958239 Compare June 24, 2026 11:14

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7958239. Configure here.

$event = Event::createLogs()->setLogs($logs->drain());

return $hub->captureEvent($event);
return $client->captureEvent($event);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flush skips hub scope enrichment

Medium Severity

LogsAggregator and MetricsAggregator now send batched telemetry via Client::captureEvent without the hub scope. Previously Hub::captureEvent passed $this->getScope() into prepareEvent, so scope event processors, tags, and other scope enrichment no longer run on flush.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7958239. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant