-
Notifications
You must be signed in to change notification settings - Fork 534
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
fix(mysql): bind get connection callback to active context #562
Conversation
|
bed4685
to
bc37bf7
Compare
plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## main #562 +/- ##
==========================================
- Coverage 96.68% 95.04% -1.65%
==========================================
Files 13 204 +191
Lines 634 12003 +11369
Branches 124 1137 +1013
==========================================
+ Hits 613 11408 +10795
- Misses 21 595 +574
|
844781f
to
3454156
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.
one comment
plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-mysql/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
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.
lgtm
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.
requesting changes so we don't merge it before addresing flarna feedback
assert.ifError(err); | ||
assert.ok(connection); | ||
const sql = 'SELECT ? as solution'; | ||
connection.query(sql, 1, (err, res) => { | ||
assert.ifError(err); | ||
assert.ok(res); | ||
assert.strictEqual(res[0].solution, 1); | ||
const spans = memoryExporter.getFinishedSpans(); | ||
assert.strictEqual(spans.length, 1); | ||
const querySpan = spans[0]; | ||
assert.strictEqual( | ||
querySpan.parentSpanId, | ||
parentSpan.spanContext().spanId | ||
); | ||
done(); | ||
}); | ||
}); |
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.
This is a very verbose way to check that the context is correctly set in the callback.
Alternative and more direct option is to extract trace.getSpan(context.active())
in the callback and compare it to parentSpan
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.
@blumamir thanks, I've changed the test.
Signed-off-by: Simon Stone <[email protected]>
Signed-off-by: Simon Stone <[email protected]>
Signed-off-by: Simon Stone <[email protected]>
Signed-off-by: Simon Stone [email protected]
Which problem is this PR solving?
Short description of the changes
getConnection
is now bound to the active context before it is passed into the instrumentedmysql
code