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: ensure run-context for mysql span does not spill into user code #2463

Merged
merged 3 commits into from
Nov 23, 2021

Conversation

trentm
Copy link
Member

@trentm trentm commented Nov 23, 2021

This fixes the 'mysql' instrumentation to not have the mysql span
context be active in user code. This ensures that user code cannot
create a child span of the mysql span, which would (a) be misleading
and (b) cause problems for coming exit span and compressed span work.

Refs: #2430

Checklist

  • Implement code
  • Add tests
  • Add CHANGELOG.asciidoc entry
  • Commit message follows commit guidelines

This fixes the 'mysql' instrumentation to not have the mysql span
context be active in user code. This ensures that user code cannot
create a child span of the mysql span, which would (a) be misleading
and (b) cause problems for coming exit span and compressed span work.

Refs: #2430
@trentm trentm requested a review from astorm November 23, 2021 00:54
@trentm trentm self-assigned this Nov 23, 2021
@github-actions github-actions bot added the agent-nodejs Make available for APM Agents project planning. label Nov 23, 2021
@apmmachine
Copy link
Contributor

apmmachine commented Nov 23, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-11-23T00:56:53.198+0000

  • Duration: 21 min 45 sec

  • Commit: 9b81f5c

Test stats 🧪

Test Results
Failed 0
Passed 22
Skipped 0
Total 22

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • run module tests for <modules> : Run TAV tests for one or more modules, where <modules> can be either a comma separated list of modules (e.g. memcached,redis) or the string literal ALL to test all modules

  • run benchmark tests : Run the benchmark test only.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@trentm
Copy link
Member Author

trentm commented Nov 23, 2021

This passed a full TAV=mysql ./node_modules/.bin/tav run using node v12.22.6 on my machine.

Copy link
Contributor

@astorm astorm left a comment

Choose a reason for hiding this comment

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

👍 does what is says, approving.

agent.logger.debug('intercepted call to mysql %s.query', objType)

var span = ins.createSpan(null, 'db', 'mysql', 'query')
if (!span) {
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for bailing out early if the span didn't start -- there doesn't appear to be any significant code path that follows in the function for an undefined span.

@trentm trentm merged commit 60dbe32 into master Nov 23, 2021
@trentm trentm deleted the trentm/run-context-mysql branch November 23, 2021 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-nodejs Make available for APM Agents project planning.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants