Skip to content

Conversation

@trentm
Copy link
Member

@trentm trentm commented Jan 24, 2022

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

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
@trentm trentm requested a review from astorm January 24, 2022 23:12
@trentm trentm self-assigned this Jan 24, 2022
@github-actions github-actions bot added the agent-nodejs Make available for APM Agents project planning. label Jan 24, 2022
@ghost
Copy link

ghost commented Jan 24, 2022

💚 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

  • Reason: null

  • Start Time: 2022-01-25T23:49:34.220+0000

  • Duration: 35 min 35 sec

  • Commit: 6539959

Test stats 🧪

Test Results
Failed 0
Passed 243071
Skipped 0
Total 243071

🤖 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!)

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.
@trentm trentm marked this pull request as ready for review January 25, 2022 20:16
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.

  • 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 supportsKeepingUnsampledTransaction method 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 apmServerVersion by providing a configuration value to the start method. 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 document apmServerVersion as 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",
Copy link
Contributor

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.

@trentm
Copy link
Member Author

trentm commented Jan 26, 2022

Thanks for the reviews!

@trentm trentm merged commit 52c8f27 into main Jan 26, 2022
@trentm trentm deleted the trentm/issue2455-drop-unsampled-trans branch January 26, 2022 00:24
astorm pushed a commit that referenced this pull request Feb 4, 2022
…2546)

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
trentm added a commit to elastic/ecs-logging-nodejs that referenced this pull request May 10, 2022
…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.
trentm added a commit to elastic/ecs-logging-nodejs that referenced this pull request May 10, 2022
…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.
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.

[META 545] Drop unsampled transactions when connected to APM Server 8.0+

3 participants