-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(node): Add knex
integration
#13526
base: develop
Are you sure you want to change the base?
feat(node): Add knex
integration
#13526
Conversation
Set up initial code and dependencies. Enable integration by default. Signed-off-by: Kaung Zin Hein <[email protected]>
@@ -47,6 +47,7 @@ | |||
"graphql": "^16.3.0", | |||
"http-terminator": "^3.2.0", | |||
"ioredis": "^5.4.1", | |||
"knex": "^2.5.1", |
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.
Breaking change in major version 3 drops support for node < 16. See here.
Set up postgres for testing. Update span attributes to be named under 'knex'. Signed-off-by: Kaung Zin Hein <[email protected]>
Differentiate knex spans from other database spans. Signed-off-by: Kaung Zin Hein <[email protected]>
const spanJSON = spanToJSON(span); | ||
const spanData = spanJSON.data; | ||
|
||
if (spanData && 'knex.version' in spanData) { |
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.
In knex instr, the prop knex.version
is added to the span attribute.
Signed-off-by: Kaung Zin Hein <[email protected]>
Add mysql2 client tests using knex. Add `knexIntegration` exports in several packages. Signed-off-by: Kaung Zin Hein <[email protected]>
knex
integration
I've fixed all the failing CI builds/tests. The current fail is unrelated to the added integration. |
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.
Hey thanks for adding the instrumentation!
In general looks good to me. After we resolve the db.system
concern we are good to merge.
If possible, could you share a screenshot of an example trace with knex instrumentation spans?
|
||
if (spanData && 'knex.version' in spanData) { | ||
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.knex'); | ||
span.setAttribute('db.system', 'knex'); |
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 shouldn't override db.system
here, it's already being set by the instrumentation: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/19454560b49b669c8f9c0cca9fcc3308b415f2b1/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts#L138
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.
noted
|
||
export const instrumentKnex = generateInstrumentOnce( | ||
INTEGRATION_NAME, | ||
() => new KnexInstrumentation({ requireParentSpan: true }), |
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.
Here, requireParentSpan
is set to true by default. So, we'd have to expose the config. Similar discussion.
|
||
if (spanData && 'knex.version' in spanData) { | ||
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.knex'); | ||
span.setAttribute('db.system', 'knex'); |
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.
noted
Resolves #13311
Implement Knex OTL instrumentation in
packages/node
.This integration is not enabled by default.