-
Notifications
You must be signed in to change notification settings - Fork 643
fix(mysql): bind get connection callback to active context #562
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Simon Stone <simonstone1@gmail.com>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -426,6 +426,30 @@ describe('mysql@2.x', () => { | |
| }); | ||
| }); | ||
| }); | ||
|
|
||
| it('should propagate active context to callback', done => { | ||
| const parentSpan = provider.getTracer('default').startSpan('test span'); | ||
| context.with(trace.setSpan(context.active(), parentSpan), () => { | ||
| pool.getConnection((err, connection) => { | ||
| 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(); | ||
| }); | ||
| }); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @blumamir thanks, I've changed the test. |
||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('#PoolCluster', () => { | ||
|
|
@@ -600,6 +624,30 @@ describe('mysql@2.x', () => { | |
| } | ||
| ); | ||
| }); | ||
|
|
||
| it('should propagate active context to callback', done => { | ||
| const parentSpan = provider.getTracer('default').startSpan('test span'); | ||
| context.with(trace.setSpan(context.active(), parentSpan), () => { | ||
| poolCluster.getConnection((err, connection) => { | ||
| 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(); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.