Skip to content
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

Merged
merged 4 commits into from Aug 14, 2021

Conversation

sstone1
Copy link
Contributor

@sstone1 sstone1 commented Jul 5, 2021

Signed-off-by: Simon Stone simonstone1@gmail.com

Which problem is this PR solving?

Short description of the changes

  • The callback for getConnection is now bound to the active context before it is passed into the instrumented mysql code

@sstone1 sstone1 requested a review from a team as a code owner July 5, 2021 15:27
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jul 5, 2021

CLA Signed

The committers are authorized under a signed CLA.

@sstone1 sstone1 force-pushed the issue-561 branch 2 times, most recently from bed4685 to bc37bf7 Compare July 5, 2021 15:35
@codecov
Copy link

codecov bot commented Jul 5, 2021

Codecov Report

Merging #562 (9d254e4) into main (72b78e6) will decrease coverage by 1.64%.
The diff coverage is n/a.

❗ Current head 9d254e4 differs from pull request most recent head 54b3191. Consider uploading reports for the commit 54b3191 to get more accurate results

@@            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     
Impacted Files Coverage Δ
...metry-propagator-ot-trace/src/OTTracePropagator.ts 95.83% <0.00%> (ø)
...er-extension-autoinjection/src/background/index.ts 0.00% <0.00%> (ø)
.../opentelemetry-instrumentation-router/src/utils.ts 100.00% <0.00%> (ø)
...ource-detector-aws/src/detectors/AwsEc2Detector.ts 97.91% <0.00%> (ø)
...pentelemetry-instrumentation-router/src/version.ts 100.00% <0.00%> (ø)
...opentelemetry-instrumentation-graphql/src/utils.ts 95.26% <0.00%> (ø)
packages/opentelemetry-host-metrics/src/enum.ts 100.00% <0.00%> (ø)
...metry-resource-detector-aws/src/detectors/index.ts 100.00% <0.00%> (ø)
...umentation-cassandra/test/cassandra-driver.test.ts 95.77% <0.00%> (ø)
...etry-instrumentation-hapi/test/hapi-plugin.test.ts 100.00% <0.00%> (ø)
... and 181 more

@sstone1 sstone1 force-pushed the issue-561 branch 2 times, most recently from 844781f to 3454156 Compare July 5, 2021 18:18
@sstone1 sstone1 requested a review from vmarchaud July 5, 2021 18:19
@vmarchaud vmarchaud requested a review from a team July 5, 2021 18:35
Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one comment

Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Member

@vmarchaud vmarchaud left a 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

Comment on lines 434 to 445
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();
});
});
Copy link
Member

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

Copy link
Contributor Author

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.

sstone1 and others added 2 commits August 10, 2021 11:05
Signed-off-by: Simon Stone <simonstone1@gmail.com>
Signed-off-by: Simon Stone <Simon.Stone@docusign.com>
Signed-off-by: Simon Stone <Simon.Stone@docusign.com>
@vmarchaud vmarchaud merged commit 90d4e78 into open-telemetry:main Aug 14, 2021
@vmarchaud vmarchaud added the bug Something isn't working label Aug 14, 2021
@vmarchaud vmarchaud linked an issue Aug 14, 2021 that may be closed by this pull request
@dyladan dyladan mentioned this pull request Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MySQL spans do not link to the active parent span
6 participants