Skip to content
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

AWS instrumentation for SDK v3, S3 #2955

Closed
Tracked by #2376
estolfo opened this issue Sep 28, 2022 · 2 comments · Fixed by #3287
Closed
Tracked by #2376

AWS instrumentation for SDK v3, S3 #2955

estolfo opened this issue Sep 28, 2022 · 2 comments · Fixed by #3287
Assignees
Labels
8.7-candidate agent-nodejs Make available for APM Agents project planning.
Milestone

Comments

@estolfo
Copy link
Contributor

estolfo commented Sep 28, 2022

Provide instrumentation for AWS SDK version 3 S3 client

See #2124 for draft work.

@estolfo estolfo added this to the 8.6 milestone Sep 28, 2022
@github-actions github-actions bot added the agent-nodejs Make available for APM Agents project planning. label Sep 28, 2022
@trentm trentm self-assigned this Sep 28, 2022
@estolfo estolfo removed this from the 8.6 milestone Nov 21, 2022
@trentm trentm added this to the 8.8 milestone Feb 2, 2023
@david-luna david-luna self-assigned this Apr 21, 2023
@trentm trentm modified the milestones: 8.8, 8.9 Apr 24, 2023
@david-luna
Copy link
Member

Reviewed @aws-sdk/node-http-handler package which is used by the clients (S3, SNS, SQS) and instrumented it. The approach is to see if there is a way to identify the client from the request and only instrument node-http-handler module for all AWS clients

After instrumenting it I saw the requests have the following shapes

For ListBucketsCommand request

HttpRequest {
  method: 'GET',
  hostname: 's3.us-east-2.amazonaws.com',
  port: undefined,
  query: {},
  headers: {
    'content-type': 'application/xml',
    host: 's3.us-east-2.amazonaws.com',
    'x-amz-user-agent': 'aws-sdk-js/3.319.0',
    'user-agent': 'aws-sdk-js/3.319.0 os/darwin/22.4.0 lang/js md/nodejs/18.16.0 api/s3/3.319.0',
    'amz-sdk-invocation-id': '001e0d75-xxx',
    'amz-sdk-request': 'attempt=1; max=3',
    'x-amz-date': '20230425T171036Z',
    'x-amz-content-sha256': 'e3b...',
    authorization: 'AWS4-HMAC-SHA256 Credential=...'
  },
  body: '',
  protocol: 'https:',
  path: '/'
}

For CreateBucketCommand request

HttpRequest {
  method: 'PUT',
  hostname: 's3.us-east-2.amazonaws.com',
  port: undefined,
  query: {},
  headers: {
    'content-type': 'application/xml',
    'content-length': '497',
    Expect: '100-continue',
    host: 's3.us-east-2.amazonaws.com',
    'x-amz-user-agent': 'aws-sdk-js/3.319.0',
    'user-agent': 'aws-sdk-js/3.319.0 os/darwin/22.4.0 lang/js md/nodejs/18.16.0 api/s3/3.319.0',
    'amz-sdk-invocation-id': '50a4183f-xxx',
    'amz-sdk-request': 'attempt=1; max=3',
    'x-amz-date': '20230425T171037Z',
    'x-amz-content-sha256': '544f...',
    authorization: 'AWS4-HMAC-SHA256 Credential=...'
  },
  body: '<?xml version="1.0" encoding="UTF-8"?><CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><LocationConstraint>async () =&gt; {&#x0A;            if (typeof region === &quot;string&quot;) {&#x0A;                return (0, getRealRegion_1.getRealRegion)(region);&#x0A;            }&#x0A;            const providedRegion = await region();&#x0A;            return (0, getRealRegion_1.getRealRegion)(providedRegion);&#x0A;        }</LocationConstraint></CreateBucketConfiguration>',
  protocol: 'https:',
  path: '/elasticapmtest-bucket-20230425171036/'
}

For DeleteBucketCommand request

HttpRequest {
  method: 'DELETE',
  hostname: 's3.us-east-2.amazonaws.com',
  port: undefined,
  query: {},
  headers: {
    host: 's3.us-east-2.amazonaws.com',
    'x-amz-user-agent': 'aws-sdk-js/3.319.0',
    'user-agent': 'aws-sdk-js/3.319.0 os/darwin/22.4.0 lang/js md/nodejs/18.16.0 api/s3/3.319.0',
    'amz-sdk-invocation-id': '9a5fa4a9-xxx',
    'amz-sdk-request': 'attempt=1; max=3',
    'x-amz-date': '20230425T171819Z',
    'x-amz-content-sha256': 'e3b...',
    authorization: 'AWS4-HMAC-SHA256 Credential=...'
  },
  body: undefined,
  protocol: 'https:',
  path: '/elasticapmtest-bucket-20230425171819/'
}

In this examples we can see Bucket is used as part of the request path so IMO it's going to be tricky to differentiate. We see some references of S3 in the hostname and host header but I think is not enough

@trentm
Copy link
Member

trentm commented Apr 25, 2023

IMO it's going to be tricky to differentiate.

I agree. That looks like it will be too low-level a place to do our instrumentation. We don't want to have to reverse map from the HTTP request shape to the S3 (or SQS, SNS, etc.) API call name.

@david-luna david-luna moved this from Planned to In Progress in APM-Agents (OLD) Apr 28, 2023
APM-Agents (OLD) automation moved this from In Progress to Done May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.7-candidate agent-nodejs Make available for APM Agents project planning.
Projects
Development

Successfully merging a pull request may close this issue.

3 participants