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: |
| # 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.
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'))
| fi | ||
|
|
||
| ELASTIC_APM_ASYNC_HOOKS=${ELASTIC_APM_ASYNC_HOOKS:-true} | ||
|
|
There was a problem hiding this comment.
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/ |
astorm
left a comment
There was a problem hiding this comment.
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. 👍
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@2instrumentation. A separate PR will address instrumentation of@awk-sdk/client-s3(aka "v3" or the "Modular AWS SDK for JavaScript").Checklist