Skip to content

Feature request: ability to capture HTTP requests #675

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

Closed
dreamorosi opened this issue Mar 18, 2022 · 2 comments
Closed

Feature request: ability to capture HTTP requests #675

dreamorosi opened this issue Mar 18, 2022 · 2 comments
Assignees
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility tracer This item relates to the Tracer Utility

Comments

@dreamorosi
Copy link
Contributor

Description of the feature request

Problem statement

As a customer using Tracer I want to be able to trace HTTP requests made to hosts/APIs just like I do with AWS SDK clients.

Summary of the feature

Other runtimes support this feature and currently Powertools for TypeScript supports it as well via the escape hatch mechanism:

import { Tracer } from '@aws-lambda-powertools/tracer`;

const tracer = new Tracer();
tracer.provider.captureHTTPsGlobal(require('http'));

This unit of work aims at adding a more ergonomic way of enabling this plus providing examples & documentation that use more common request libraries like axios.

Before staring the implementation there are two points on which I need a feedback:

1

The Python version of AWS Lambda Powertools, in addition to the above, supports another feature that allows to ignore arbitrary hostnames so that they don't appear in the traces, this is possible because the aws-xray-sdk-python supports the feature:

var AWSXRay = require('aws-xray-sdk');
AWSXRay.captureHTTPsGlobal(require('http'));
var http = require('http');

// ignore requests to test.myapp.com
AWSXRay.ignore_hostnames('test.myapp.com');
// OR ignore requests to test.myapp.com AND other.myapp.com
AWSXRay.ignore_hostnames(['test.myapp.com', 'other.myapp.com']);

At the moment the aws-xray-sdk-node doesn't support it, although it's on the team's backlog according to this answer on an issue I've opened: aws/aws-xray-sdk-node#480

Question: Are we OK with moving forward without this feature? If the feature ever lands in the SDK we could add it.

2

The Python version of Powertools also captures automatically all requests (and AWS SDK clients) so that they are traced whenever a customer uses Tracer. For AWS SDK this is not possible since that we have two potential SDK versions being used (v2 & v3) and after this discussion we have opted to not capture SDK clients automatically and make it opt-in.

For HTTP requests this could still be a possibility given that we could patch the http module which is then used by other higher level request packages (i.e. axios).

Question: Do we want to make capturing HTTP requests opt-in to be consistent with TypeScript behaviour of all captures are opt-in OR do we want to capture HTTP requests by default and have customers opt-out (in this second scenario all customers would always be importing the http module)?

Code examples

Example 1:

import { Tracer } from '@aws-lambda-powertools/tracer`;

const tracer = new Tracer();
tracer.captureRequests();

Example 2:

import { Tracer } from '@aws-lambda-powertools/tracer`;

const tracer = new Tracer({ captureRequests: false }); // default: true

Benefits for you and the wider AWS community

Additional features available in using Tracer from this library.

Describe alternatives you've considered

Continue using the escape hatch method.

Additional context

N/A

Related issues, RFCs

#275

@dreamorosi dreamorosi added enhancement tracer This item relates to the Tracer Utility triage This item has not been triaged by a maintainer, please wait labels Mar 18, 2022
@dreamorosi dreamorosi added this to the production-ready-release milestone Mar 18, 2022
@dreamorosi dreamorosi self-assigned this Mar 18, 2022
@dreamorosi
Copy link
Contributor Author

Merged in #677, will be available in next release.

@dreamorosi dreamorosi removed the triage This item has not been triaged by a maintainer, please wait label Apr 7, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Apr 7, 2022

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@dreamorosi dreamorosi changed the title Feature (tracer): ability to capture HTTP requests Feature request: ability to capture HTTP requests Nov 14, 2022
@dreamorosi dreamorosi added feature-request This item refers to a feature request for an existing or new utility completed This item is complete and has been merged/shipped labels Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility tracer This item relates to the Tracer Utility
Projects
None yet
Development

No branches or pull requests

2 participants