Skip to content
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

Instrument Queues - PHP example #11711

Open
rodion-k opened this issue Nov 1, 2024 · 1 comment
Open

Instrument Queues - PHP example #11711

rodion-k opened this issue Nov 1, 2024 · 1 comment

Comments

@rodion-k
Copy link

rodion-k commented Nov 1, 2024

SDK

PHP SDK

Description

In the consumer instrumentation example, the $job variable is used before initialization:

$context = \Sentry\continueTrace(
    $job->getMetadata('sentry_trace'), // $job variable is used here
    $job->getMetadata('baggage')
)
    ->setOp('queue.process')
    ->setName('App\Jobs\MyJob');

$transaction = \Sentry\startTransaction($context);

\Sentry\SentrySdk::getCurrentHub()->setSpan($transaction);

$job = Queue::pop(); // but initialization is here

try {
    // Continue job processing...
} catch (\Throwable $e) {
    $transaction->setStatus(\Sentry\Tracing\SpanStatus::internalError());
}

$transaction
    ->setData([
        'messaging.message.id' => $job->getId(),
        'messaging.destination.name' => $job->getQueue(),
        'messaging.message.body.size' => $job->getSize(),
        'messaging.message.receive.latency' =>  microtime(true) - $job->getMetadata('publish_time'),
        'messaging.message.retry.count' => $job->getRetryCount(),
    ])
    ->finish();

https://docs.sentry.io/platforms/php/guides/symfony/tracing/instrumentation/queues-module/#consumer-instrumentation

Suggested Solution

No response

@getsantry
Copy link
Contributor

getsantry bot commented Nov 1, 2024

Assigning to @getsentry/support for routing ⏲️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for: Support
Development

No branches or pull requests

2 participants