-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(node): Add postgresjs instrumentation #16665
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
Conversation
size-limit report 📦
|
4e076b1
to
5cae445
Compare
…pression Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
bcf73bf
to
ff9248e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make sure we collect as much as possible as per https://opentelemetry.io/docs/specs/semconv/database/database-spans/
Similar to the pg instrumentation, let's implement the requireParentSpan
option and set it as true.
We should also implement requestHook
so we can attach span origin.
`; | ||
|
||
await sql` | ||
UPDATE "User" SET "name" = 'Foo' WHERE "email" = 'bar@baz.com'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd perhaps want to leave the email in a constant since we are repeating it over and over.
it doesn't really matter since it's a dummy email, what I'm thinking is: what if at some point we want to run the test on a specific email? (if we ever want to do that)
It would be easier to just change the value of the constant over changing every single instance of it.
Just my thought 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, updated. Thanks 👍
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
ah @onurtemizkan we have to export this from all relevant sdks |
Resolves: #15621
Adds instrumentation for https://github.com/porsager/postgres
Sampled event: (Emitted from the integration tests added here): Link
This implementation patches
connection
andquery
classes to create database transactions:connection
, we pick up the databasename
,url
andport
to use in the db query spansquery
instance, we create adb
spancursor
usedInitially, I implemented a way to capture
db.operation
(ascommand
is available when the query resolves) but it seems the ingestion extracts the operation anyway, so I removed it.Also added sanitization/normalization for raw query, which we use as the span description, also seems to be normalized by the ingestion engine. We can remove it too if it's not worth having, as it creates a possibly-unnecessary performance overhead on the SDK side.