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

contrib/jackc/pgx/v5: add initial support #2160

Closed
wants to merge 13 commits into from

Conversation

j-sv
Copy link
Contributor

@j-sv j-sv commented Aug 1, 2023

What does this PR do?

Like #1840, this is based on #1537 in an attempt to get support for this merged. It implements all the tracer interfaces in jackc/pgx/v5 in addition to the QueryTracer. It adds unit tests and examples for the connection and pool usage.

Tracers other than QueryTracer are disabled by default but can be enabled by options.

This PR should close #697.

Motivation

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.

Add support for utilizing the integrated tracing functionality in
github.com/jackc/pgx/v5, rather than having to go through the
database/sql interface.
@j-sv j-sv requested a review from a team August 1, 2023 13:22
@j-sv j-sv requested a review from a team as a code owner August 1, 2023 13:22
@ahmed-mez ahmed-mez added the apm:ecosystem contrib/* related feature requests or bugs label Aug 2, 2023
@zarirhamza
Copy link
Contributor

We definitely have our eyes on this after several requests for a proper pgx integration. We definitely want to see this through. Just wanted to ask @j-sv if it's ok to contribute directly to your branch to format things and add other pieces of code that we require in all our integrations.

@j-sv
Copy link
Contributor Author

j-sv commented Sep 1, 2023

@zarirhamza, of course!

Copy link
Contributor

@ajgajg1134 ajgajg1134 left a comment

Choose a reason for hiding this comment

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

This is just a very initial review, @zarirhamza and @rarguelloF will give a more complete review next week. Thanks again for opening this contribution!!

defer db.Close(ctx)

// Any calls made to the database will be traced as expected.
rows, err := db.Query(ctx, "SELECT name FROM users WHERE age=?", 27)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
rows, err := db.Query(ctx, "SELECT name FROM users WHERE age=?", 27)
rows, err := db.Query(ctx, "SELECT name FROM users WHERE age=$1", 27)


type Option func(*tracer)

func WithServiceName(name string) Option {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add godoc comments to all these public functions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated with comments and tried to add some examples.

return ctx
}

opts := t.spanOptions(
Copy link
Contributor

Choose a reason for hiding this comment

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

The now time is the default so no need to create and use this option here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the start time from all span options.

if err != nil {
return nil, err
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

@sejin-P
Copy link

sejin-P commented Sep 18, 2023

@ajgajg1134 Thank you for your attention, how's it coming? 

Additionally, I appreciate to your contribution, @j-sv

@zarirhamza
Copy link
Contributor

Just an update for everyone watching, we decided to continue this on another PR #2236 because it required a bit more work to be more complete especially on the testing side.

We will continue using the bulk of the tracing capabilities from this PR which was a massive contribution, so thank you!

@katiehockman
Copy link
Contributor

@zarirhamza should we just go ahead and close this PR then, to clean up the backlog a bit?

@zarirhamza
Copy link
Contributor

zarirhamza commented Nov 28, 2023

Moved to separate PR #2236 so closing this one.

@zarirhamza zarirhamza closed this Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:ecosystem contrib/* related feature requests or bugs do-not-merge/WIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

proposal: integrate with github.com/jackc/pgx
6 participants