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

feat: set "destination" context for "mongodb" instrumentation #1893

Merged
merged 7 commits into from
Nov 26, 2020

Conversation

trentm
Copy link
Member

@trentm trentm commented Nov 25, 2020

Fixes #1892

@github-actions github-actions bot added the agent-nodejs Make available for APM Agents project planning. label Nov 25, 2020
@trentm trentm self-assigned this Nov 25, 2020
@trentm
Copy link
Member Author

trentm commented Nov 25, 2020

Current status: just a first pass.

TODOs:

  • test case
  • More robust/defensive handling of the event.address etc.

@apmmachine
Copy link
Contributor

apmmachine commented Nov 25, 2020

💚 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

Expand to view the summary

Build stats

  • Build Cause: Pull request #1893 updated

  • Start Time: 2020-11-26T00:51:20.523+0000

  • Duration: 14 min 17 sec

Test stats 🧪

Test Results
Failed 0
Passed 16398
Skipped 0
Total 16398

@trentm
Copy link
Member Author

trentm commented Nov 25, 2020

TAV test run for me:

% TAV=mongodb ./node_modules/.bin/tav --compat
Testing compatibility with mongodb:
✔ 3.6.3
✔ 3.6.2
✔ 3.5.11
✔ 3.6.1
✔ 3.6.0
✔ 3.5.10
✔ 3.5.9
✔ 3.5.8
✔ 3.5.7
✔ 3.5.6
✔ 3.5.5
✔ 3.5.4
✔ 3.5.3
✔ 3.5.2
✔ 3.5.1
✔ 3.5.0
✔ 3.4.1
✔ 3.4.0
✔ 3.3.5
✔ 3.3.4
✔ 3.3.3
✔ 3.3.2
✔ 3.3.1
✔ 3.3.0

@trentm trentm requested a review from astorm November 25, 2020 23:52
@trentm trentm marked this pull request as ready for review November 25, 2020 23:53
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.

code and concepts look solid and reflect what we discovered about this in slack today. Soft approving, presuming that the lint and ci pass.

// available via the `address` or `connectionId` field.
// https://github.com/mongodb/node-mongodb-native/blob/dd356f0ede/lib/core/connection/apm.js#L155-L169
const address = event.address || event.connectionId
let match
Copy link
Contributor

Choose a reason for hiding this comment

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

Capturing an online conversation here -- both the docs and some spot checking of a port-less mongo connection (mongoose.connect('mongodb://localhost/myapp', {useNewUrlParser: true});) indicate that the address/connection ID will be normalized to include a port, even if the client is configured without one. If somehow a portless address does end up in there, we won't hard fail as exec won't match and the conditional will fail.

@trentm trentm merged commit e6018a6 into master Nov 26, 2020
@trentm trentm deleted the trentm/mongodb-destination-context branch November 26, 2020 01:29
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.

"mongodb" module instrumentation is missing "destination" context
3 participants