feat(module): add module for tracing SQL queries created by jackc/pgx#1301
feat(module): add module for tracing SQL queries created by jackc/pgx#1301axw merged 44 commits intoelastic:mainfrom
Conversation
…p pgx library version up to v4.17 and write comment for error with min required version
|
💚 CLA has been signed |
|
@gvencadze sorry for the silence, this slipped my attention. Can you please sign the CLA? As there are commits from multiple authors, both you and @EpicStep will need to do this. |
|
@axw hey, I've signed CLA (tried with both of emails that's linked to account), but nothing changed. Do I need to restart pipeline or something else? UPD: merge latest changes and CLA check re-runs, now it's ok |
axw
left a comment
There was a problem hiding this comment.
This looks great, thanks for the PR! I've left some comments, and in addition to those:
- Would you please take a look at adding an integration test? You can adapt the apmsql/pq one here: https://github.com/elastic/apm-agent-go/blob/main/module/apmsql/pq/pq_test.go
- Please run
make update-licenses update-modules fmt scripts/Dockerfile-testing - Please add vanity import comments to the files, so that
make checkpasses
…cepts pgx.ConnConfig. Move duplicate code to separate func called startSpan to make ...Trace functions small and simple. Add type casting checks to avoid instrument runtime panics.
…t with Instrument func for further tests
… and add apmpgx entry to Dockerfile-testing
|
@axw hey, I've done what you've write about above:
that's stdout after make call: |
|
@axw I've added e2e tests for Query and Copy tracing, only the batch trace remain. Can you take a look? Maybe you will find something else that should be changed/discussed |
axw
left a comment
There was a problem hiding this comment.
LGTM! Thank you, this looks great.
|
/test |
|
@gvencadze there's an issue with formatting, CI is failing with this error: Can you please make sure |
Sure, I’ll take a look UPD: @axw, I've run |
| statement, ok := data["sql"].(string) | ||
| if !ok { | ||
| apm.CaptureError(ctx, | ||
| fmt.Errorf("%w: expect string, got: %T", | ||
| ErrInvalidType, | ||
| data["sql"], | ||
| ), | ||
| ).Send() | ||
| return | ||
| } |
There was a problem hiding this comment.
@axw one more question - should I capture and send type casting errors into APM? I didn't find something like this in other modules, but I think it will be good for understanding that something inside module (or its dependency) is broken
There was a problem hiding this comment.
There's no precedent and I'm a bit on the fence about it, but I think it's fine to keep it for now at least. There's not really a good alternative at the moment. Generally errors are about the service, rather than about the instrumentation. I suppose ideally there would be some way to log errors about the instrumentation - we can revise it later.
…r according to stored value in data map
🌐 Coverage report
|
|
@gvencadze I see you've sorted out the last of the tests 🎉 One last thing before I merge it: would you please add an entry to CHANGELOG.asciidoc, to the "Unreleased" section? |
|
@axw done Also, If we want to create another one module for pgx (but for v5 version), should we open issue and link it with MR or not? I'm talking about this new method: They aren't available in V4 version, so I think we should make another one module, something called |
|
run elasticsearch-ci/docs |
I agree, that sounds like the way to go. Yes, please do open a separate issue and reference this PR. |
|
Thank you very much for your contribution! |
This module provide enhanced support of
jackc/pgxlibrary and it's features such asCOPY FROMandBATCHstatementsCloses #854