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

pgx query times report as application times in the Datadog UI #2710

Closed
ewhauser opened this issue May 25, 2024 · 3 comments
Closed

pgx query times report as application times in the Datadog UI #2710

ewhauser opened this issue May 25, 2024 · 3 comments
Assignees

Comments

@ewhauser
Copy link

Version of dd-trace-go
latest

Describe what happened:

We recently switched from libpq to pgx. Our services are now showing all time spent in the application vs. correctly reporting on the application and database times.

Describe what you expected:

The screenshot shows the difference here. The pgx changes were deployed on Thurs 23rd and our service name is telemetry:

Screenshot 2024-05-25 at 9 07 09 AM

Steps to reproduce the issue:
Should be simple to reproduce. Send any pgx traces to Datadog.

Additional environment details (Version of Go, Operating System, etc.):

@ewhauser ewhauser added the bug unintended behavior that has to be fixed label May 25, 2024
@github-actions github-actions bot added the needs-triage New issues that have not yet been triaged label May 25, 2024
@darccio darccio removed the needs-triage New issues that have not yet been triaged label Jun 3, 2024
@darccio
Copy link
Member

darccio commented Jun 3, 2024

@rarguelloF @zarirhamza Can you review this? Thanks!

@rarguelloF
Copy link
Contributor

@ewhauser Sorry for the delayed response.

From the screenshot you are sending, it seems the postgres.db service disappeared, which is something expected as the pgx.v5 integration by default inherits the service name from DD_SERVICE instead of setting a custom one. We are aware this is an inconsistent behavior between different instrumentations, but overall the preferred behavior from now on is to get rid of these "fake" services (like postgres.db) and instead using DD_SERVICE everywhere in the same service. The DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED environment variable ensures this behavior is applied in every integration/instrumentation you are using.

If you want to have the old behavior (having your pgx.v5 spans with a different service name), you can do the following:

import (
	pgxtrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/jackc/pgx.v5"
)

// ...

db, err := pgxtrace.Connect(ctx, dbUrl, pgxtrace.WithServiceName("postgres.db"))

@rarguelloF rarguelloF self-assigned this Jun 10, 2024
@rarguelloF rarguelloF added ack question and removed bug unintended behavior that has to be fixed labels Jun 10, 2024
@rarguelloF rarguelloF changed the title [BUG] pgx query times report as application times in the Datadog UI pgx query times report as application times in the Datadog UI Jun 13, 2024
@darccio
Copy link
Member

darccio commented Jul 31, 2024

Since the question is answered, we close the issue. Feel free to reopen if you want more support.

@darccio darccio closed this as completed Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants