Skip to content

Fix console tracing #930

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Fix console tracing #930

wants to merge 1 commit into from

Conversation

Big-Shark
Copy link
Contributor

I noticed that our project lacks spans when executing console commands. I found that upon completion of a console command, only one specific span is finalized, rather than the entire transaction, unlike the behavior in TracingRequestListener. After locally modifying it to complete the transaction and running console sentry:test, I observed the other spans that were previously missing. Therefore, I believe this fix should resolve the issue.

I noticed that our project lacks spans when executing console commands. I found that upon completion of a console command, only one specific span is finalized, rather than the entire transaction, unlike the behavior in TracingRequestListener. After locally modifying it to complete the transaction and running console sentry:test, I observed the other spans that were previously missing. Therefore, I believe this fix should resolve the issue.
@Big-Shark
Copy link
Contributor Author

The tests failed because they check for the invocation of the getSpan method.

I would like to understand whether there is a bug here and the tests need to be fixed, or if the issue lies elsewhere.

@Big-Shark
Copy link
Contributor Author

@cleptric Hi, can you check my MR?

@Big-Shark Big-Shark marked this pull request as draft August 1, 2025 22:46
@cleptric cleptric requested a review from Litarnus August 11, 2025 05:33
@Litarnus
Copy link

Hi @Big-Shark! Can you provide more information what you received before your change and after your change. It seems to make no difference for me when running sentry:test

@Big-Shark
Copy link
Contributor Author

Big-Shark commented Aug 15, 2025

Hi

Before my changes, running sentry:test produced this output:

Screenshot from 2025-08-15 10-55-20

After my changes, it looks like this:
Screenshot from 2025-08-15 10-56-31

When I add a custom span in SentryTestCommand:

        $spanContext = \Sentry\Tracing\SpanContext::make()
            ->setOp('some_operation')
            ->setDescription('This is a description');
        \Sentry\trace(function () {
            sleep (3);
        }, $spanContext)

The output becomes:

Screenshot from 2025-08-15 10-55-38 Without these changes, the output is similar to the first screenshot.

@Big-Shark
Copy link
Contributor Author

My sentry yaml config

when@prod: &sentry-prod
    parameters:
        sentry.traces_sample_rate: 0.1

    sentry:
        dsn: "%env(SENTRY_DSN)%"
        options:
            environment: "%env(DEPLOYMENT_ENV)%"
            release: '%env(APP_VERSION)%'
            send_default_pii: true
            traces_sample_rate: '%sentry.traces_sample_rate%'
            ignore_exceptions:
                - Symfony\Component\HttpKernel\Exception\NotFoundHttpException
                - Symfony\Component\Messenger\Exception\RejectRedeliveredMessageException
        register_error_listener: false # Disables the ErrorListener to avoid duplicated log in sentry

when@staging:
    <<: *sentry-prod
    parameters:
        sentry.traces_sample_rate: 0.3

when@dev:
    <<: *sentry-prod
    parameters:
        sentry.traces_sample_rate: 1

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.

2 participants