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

Prepared queries when using Doctrine DBAL are not instrumented #544

Closed
jokaorgua opened this issue Aug 18, 2021 · 5 comments · Fixed by #548
Closed

Prepared queries when using Doctrine DBAL are not instrumented #544

jokaorgua opened this issue Aug 18, 2021 · 5 comments · Fixed by #548
Milestone

Comments

@jokaorgua
Copy link

I'm using bundle 4.2.0 and using tracing for sentry.

When some SQL is used for selecting some data in sentry I see only a trace for sql.conn.prepare. But this does not show the time spent for selecting data itself.

Maybe there is a way to include such information in trace too? I want to see in trace how much time was spent for getting data from db

Thank you.

@ste93cry
Copy link
Collaborator

Maybe there is a way to include such information in trace too?

It is already included, the same way it is for sql.conn.prepare. There is not enough context or information here to help you further, so some code to reproduce the issue would be helpful

@jokaorgua
Copy link
Author

jokaorgua commented Aug 20, 2021

@ste93cry

Initial data:
symfony 5.3.6
Doctrine-orm 2.9.4
sentry bundle 4.2.0

I've created a test command with the following code

$filter = new RequestFilterSearchAll();
$userIds = $this->userFetcher->all($filter);
dump($userIds);

UserFetcher.php::all

$query = $this->connection->createQueryBuilder()
            ->select(
                'some data'
            )
            ->from('users', 'u');

....filter processing.....

$result = $this->connection->fetchAllAssociative(
            $query->getSQL(),
            $query->getParameters(),
            $query->getParameterTypes()
        );

Executed command with bin/console test

The transaction was sent to sentry and I see the following

image

So as you can see there is only sql.conn.prepare time. I want to know how to add there time for select itself, not only the prepare

@jokaorgua
Copy link
Author

jokaorgua commented Aug 20, 2021

And here I have a screenshot with transaction made by following code

dump($this->entityManager->getRepository(User::class)->findAll());

image

We have sql.conn.query

@jokaorgua
Copy link
Author

if I'm right the issue is in https://github.com/doctrine/dbal/blob/2.13.x/lib/Doctrine/DBAL/Connection.php#L1283
When params are not empty the prepare method is called and logged into sentry's transaction

But after that the $stmt->execute is called and it is not covered by tracing driver

Please correct me if I'm wrong

@ste93cry
Copy link
Collaborator

That is indeed the culprit of the issue, nice catch! I will open a PR soon to fix it

@ste93cry ste93cry added this to the 4.2 milestone Aug 20, 2021
@ste93cry ste93cry changed the title HOWTO: Trace Sql query Prepared queries when using Doctrine DBAL are not instrumented Aug 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants