-
Notifications
You must be signed in to change notification settings - Fork 238
feat: Drop unsampled transactions when connected to APM Server 8.0+ #2546
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
Conversation
This updates to an elastic-apm-http-client that calls the APM Server Information API on creation to get the APM Server version. Closes: #2455
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
It was failing because there were two asserts for
"server received client request":
```
[2022-01-25T00:10:48.113Z] running test: cd . && node --unhandled-rejections=strict test\integration\allow-invalid-cert.test.js
[2022-01-25T00:10:48.690Z] TAP version 13
[2022-01-25T00:10:48.690Z] # should allow self signed certificate
[2022-01-25T00:10:48.956Z] ok 1 server received client request
[2022-01-25T00:10:48.956Z] {"log.level":"error","@timestamp":"2022-01-25T00:10:49.113Z","log":{"logger":"elastic-apm-node"},"ecs":{"version":"1.6.0"},"message":"APM Server transport error: APM Server information endpoint returned no body, often this indicates authentication (\"apiKey\" or \"secretToken\") is incorrect"}
[2022-01-25T00:10:48.956Z] {"log.level":"info","@timestamp":"2022-01-25T00:10:49.118Z","log":{"logger":"elastic-apm-node"},"ecs":{"version":"1.6.0"},"message":"Sending error to Elastic APM: {\"id\":\"737eadd48ee233f960b8fa5f58c5b234\"}"}
[2022-01-25T00:10:48.956Z] ok 2 server received client request
[2022-01-25T00:10:48.956Z] ok 3 undefined
[2022-01-25T00:10:48.956Z] ok 4 agent.captureError callback called
[2022-01-25T00:10:48.956Z] not ok 5 plan != count
```
I'm guessing the extra one is from the APM Server version fetch.
…urprised the test asserts
astorm
left a comment
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.
- I see that when we create the base configuration object for the HTTP transport that it has a new top level property named apmServerVersion, and that its default value comes from the agent's configuration
- I see that when ending a transaction we check both the sampled value and the new
supportsKeepingUnsampledTransactionmethod on the HTTP client -- if sampled is false-ish (meaning we did not collect spans for this transaction) AND we're not using an older version of APM server (per supportsKeepingUnsampledTransaction), we exit the method before the transaction can be encoded and sent. - One quirk of this implementation is that end-users will be able to override the value of
apmServerVersionby providing a configuration value to thestartmethod. They could say they're on APM Server version 0.4.2, and the client would take them at their word. This seems harmless (so long as we don't documentapmServerVersionas something folks can use) but also seems at least worth mentioning out loud for googlers of the future.
approving.
package.json
Outdated
| "cookie": "^0.4.0", | ||
| "core-util-is": "^1.0.2", | ||
| "elastic-apm-http-client": "^10.3.0", | ||
| "elastic-apm-http-client": "elastic/apm-nodejs-http-client#trentm/issue2455-drop-unsampled-trans", |
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.
Just the obvious note update this before merging.
|
Thanks for the reviews! |
…PM server version check In elastic-apm-node@3.28.0 (elastic/apm-agent-nodejs#2546) the APM agent added a default request to "GET /" of the APM server to determine its version. This broke tests here.
…PM server version check (#122) In elastic-apm-node@3.28.0 (elastic/apm-agent-nodejs#2546) the APM agent added a default request to "GET /" of the APM server to determine its version. This broke tests here.
This updates to an elastic-apm-http-client that calls the APM Server
Information API on creation to get the APM Server version.
Closes: #2455
Checklist
"elastic-apm-http-client": "^10.4.0"when feat: Add APM Server version fetching and client.supportsKeepingUnsampledTransaction() apm-nodejs-http-client#176 is merged and published.