-
Notifications
You must be signed in to change notification settings - Fork 228
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: support @elastic/elasticsearch@8 #2385
Conversation
This is a first incomplete crack at it. TAV is probably wrong. There are some XXXs to complete in the tests for a change in the 'request' diagnostic data.
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
…or config.test.js
Local TAV test run pass FWIW:
|
running (cwd: ./): node --unhandled-rejections=strict test/instrumentation/modules/@elastic/elasticsearch-canary.test.js TAP version 13 # client.ping with promise not ok 1 ProductNotSupportedError: The client noticed that the server is not Elasticsearch and we do not support this unknown product. --- operator: error stack: |- ProductNotSupportedError: The client noticed that the server is not Elasticsearch and we do not support this unknown product. at SniffingTransport.request (/home/runner/work/apm-agent-nodejs/apm-agent-nodejs/node_modules/@elastic/transport/lib/Transport.js:405:27) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async ApmClient.PingApi [as ping] (/home/runner/work/apm-agent-nodejs/apm-agent-nodejs/node_modules/@elastic/elasticsearch-canary/lib/api/api/ping.js:37:12)
…upport ES 7.10.1, but do 7.15.1
…differ enough, esp. while v8 is still pre-release
…and published in @elastic/[email protected]
I believe this is (a) safer and (b) doesn't lose any functionality. "Safer" because, a recent change in elastic/elasticsearch-js to the types for this "body" field on the "request" diagnostic event shows these possible types for version 8 of the ES client: body?: string | Buffer | ReadableStream | null That "body" can be a Buffer or a ReadableStream. JSON.stringify-ing those for span.context.db.statement could possibly result in a HUGE object. This isn't the intent. No loss in functionality because we have tests for most of the ES queries that we support: const pathIsAQuery = /\/(_search|_msearch|_count|_async_search|_sql|_eql)(\/|$)/ or we should, and a TAV test run shows no test failures with this change. Better safe for possible future additions to `pathIsAQuery` than a theoretical regression in the value captured for span.context.db.statement.
if (body) { | ||
if (typeof (body) === 'string') { | ||
parts.push(body) | ||
} else if (Array.isArray(body)) { | ||
parts.push(body.map(JSON.stringify).join('\n')) // ndjson | ||
} else if (typeof (body) === 'object') { | ||
parts.push(JSON.stringify(body)) | ||
} | ||
if (typeof (body) === 'string') { | ||
parts.push(body) |
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.
REVIEW NOTE: The acc97e5 commit message explains the reasoning for this change.
…asticsearch' client
Tests all passed, I'm running a TAV test run now. From the TAV test run I only care about elasticsearch client tests. I expect there may be failures in fastify and hapi tests (see #2387 for a later fix for those). |
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.
👍 approving. It does the thing, splitting the new example makes sense with the API changes in 8, and adding the canary repo should help us be ahead of the curve when it comes to changes.
name: '@elastic/elasticsearch' | ||
versions: '>=7.12.0 <8.0.0' | ||
node: '>=10.0.0' | ||
commands: node test/instrumentation/modules/@elastic/elasticsearch.test.js | ||
'@elastic/elasticsearch-canary': | ||
name: '@elastic/elasticsearch-canary' | ||
versions: '^8.0.0-canary.35' |
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.
TIL: semver canary conventions 👍
Also -- it looks like canary release are coming fast and furious, with multiples in a day. We may wan to revisit testing every release greater than -canary.35
in the future and adopt an approach similar to what we do for AWS modules with a large number of releases. What we have here now though should be fine.
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.
Right now I am trying to (manually) track what the Kibana 8.0 PR is using.
Potentially after the 8.0 release of the ES client settles down we should remove testing of the canary package.
@@ -11,7 +11,7 @@ var shimmer = require('./shimmer') | |||
var Transaction = require('./transaction') | |||
|
|||
var MODULES = [ | |||
'@elastic/elasticsearch', | |||
['@elastic/elasticsearch', '@elastic/elasticsearch-canary'], |
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.
👍 tested this manually (in addition to the automated test changes below), and both a require('@elastic/elasticsearch')
and require('@elastic/elasticsearch-canary')
result in the agent loading the instrumentation module.
Something in the Jenkins run for the TAV tests is ridiculously slow/stuck: https://apm-ci.elastic.co/job/apm-agent-nodejs/job/apm-agent-nodejs-mbp/job/PR-2385/14/ |
💔 Build Failed
Expand to view the summary
Build stats
Steps errors
Expand to view the steps failures
|
When `npm test` is run outside of CI, then "test/docker-compose.yml" is used to setup required services (redis, ES, etc.). This is a separate compose file than is used in CI. To test @elastic/elasticsearch@8 instrumentation requires an ES server at least 7.14 for its product check to work. The test ES service had been updated for Jenkins and GH CI, but this one was missed. Refs: #2385
When `npm test` is run outside of CI, then "test/docker-compose.yml" is used to setup required services (redis, ES, etc.). This is a separate compose file than is used in CI. To test @elastic/elasticsearch@8 instrumentation requires an ES server at least 7.14 for its product check to work. The test ES service had been updated for Jenkins and GH CI, but this one was missed. Refs: #2385
When `npm test` is run outside of CI, then "test/docker-compose.yml" is used to setup required services (redis, ES, etc.). This is a separate compose file than is used in CI. To test @elastic/elasticsearch@8 instrumentation requires an ES server at least 7.14 for its product check to work. The test ES service had been updated for Jenkins and GH CI, but this one was missed. Refs: #2385
This adds support for the still pre-release version 8.x of the ES client. We are testing canary releases via the
@elastic/elasticsearch-canary
package. Kibana v8 is working to use v8 of the ES client and part of that is the self-APM integration in Kibana supporting instrumenting it.Fixes: #2355
Checklist