-
Notifications
You must be signed in to change notification settings - Fork 225
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: AWS S3 instrumentation #2112
Conversation
3ad0cb1
to
ccc7fd7
Compare
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪 |
…is'll handle ESM imports
…10 because the package doesn't support older nodes
The state of instrumenting v3 of the JavaScript AWS SDK (https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-s3) is as follows. (See https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-s3#import for what I mean by the import styles.)
import apm from 'elastic-apm-node/start.js'
import { S3Client, HeadObjectCommand } from "@aws-sdk/client-s3";
const s3client = new S3Client({ region: 'us-west-1' })
apm.instrumentAwsSdkClient(s3client) // <--- this is the only new line
// ... I'm not sure if that is worthwhile. |
…ng node in tests Error: Command failed: /opt/hostedtoolcache/node/10.0.0/x64/bin/node fixtures/use-s3-callback-style.js openssl config failed: error:02001002:system library:fopen:No such file or directory
… run; better localstack healthcheck
testing access pointsS3 Access Points is a
This comment documents my testing of the S3 instrumentation with Access Points. First I created one to use:
In the v2 JavaScript AWS SDK, using an access point and the With an access point the
I used the following ARN in my dev script that exercises the S3 API a little bit.
A resulting span for a HeadObject call is:
|
@@ -15,7 +15,7 @@ fi | |||
# Skip for node v8 because it results in this warning: | |||
# openssl config failed: error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library | |||
if [[ $major_node_version -gt 8 ]]; then | |||
export NODE_OPTIONS="${NODE_OPTIONS:+${NODE_OPTIONS}} --openssl-config=./test/openssl-config-for-testing.cnf" | |||
export NODE_OPTIONS="${NODE_OPTIONS:+${NODE_OPTIONS}} --openssl-config=$(pwd)/test/openssl-config-for-testing.cnf" |
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: This was necessary to avoid this error message:
openssl config failed: error:02001002:system library:fopen:No such file or directory
when executing a subprocess to run node fixtures/use-s3.js
as part of s3.test.js
below... because that subprocess is run in a separate directory (in "test/instrumentation/modules/aws-sdk") rather than at the top-level. Using an absolute path fixes this -- which is the same thing that is done for this in test/test.js:
args.unshift('--require', path.join(__dirname, '_promise_rejection.js'))
@@ -210,6 +213,8 @@ else | |||
DOCKER_COMPOSE_FILE=docker-compose-all.yml | |||
fi | |||
|
|||
ELASTIC_APM_ASYNC_HOOKS=${ELASTIC_APM_ASYNC_HOOKS:-true} | |||
|
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: This ensures that ELASTIC_APM_ASYNC_HOOKS
is either "true" or "false", and not "" or "false". When it is the empty string, things are fine, but the agent logs:
{"log.level":"warn","@timestamp":"2021-06-22T23:22:55.871Z","log":{"logger":"elastic-apm-node"},"ecs":{"version":"1.6.0"},"message":"unrecognized boolean value \"\" for \"asyncHooks\""}
{"log.level":"warn","@timestamp":"2021-06-22T23:22:55.872Z","log":{"logger":"elastic-apm-node"},"ecs":{"version":"1.6.0"},"message":"unrecognized boolean value \"\" for \"asyncHooks\""}
which is just noise in test output.
@astorm I haven't yet added a changelog entry, but this is ready for review. Our AWS instrumentation might benefit from a separate documentation page, but I think that could be done in a separate issue. |
That "Integration Tests failure" above (https://apm-ci.elastic.co/job/apm-agent-nodejs/job/apm-agent-nodejs-mbp/job/PR-2112/) has this in the log:
I don't know whta that is about. I'll try to run it again -> https://apm-ci.elastic.co/job/apm-integration-tests-selector-mbp/job/master/18016/ |
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.
Overall looks good.
Just to say it out loud I do have mixed feeling about incorporating another dependency (localstack) directly into our CI ... but I think I'm slightly in favor of it if it can get us out of the business of mocking requests (especially with the specre of a new SDK with different requests to mock out)
Review is just some due diligence style questions and some nits. Trending towards approval once those questions are answered. 👍
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.
👍
Note that this only includes 'aws-sdk@2' instrumentation. Instrumentation of '@awk-sdk/client-s3' (aka "v3" or the "Modular AWS SDK for JavaScript") will be done in a separate change. This adds localstack to the test suite for testing the S3 API. Fixes: elastic#1954
Fixes: #1954
Note that this PR will only include
aws-sdk@2
instrumentation. A separate PR will address instrumentation of@awk-sdk/client-s3
(aka "v3" or the "Modular AWS SDK for JavaScript").Checklist