aws/aws-xray-sdk-node

Feature Request: Allow to filter out specific hostnames when capturing HTTP(s) requests

dreamorosi opened this issue · 5 comments

Description

As a user I would like to be able to filter out from my traces specific requests based on the hostname of the request itself when using captureHTTPsGlobal & captureHTTPs. This way I can avoid sending sensitive data or polluting traces to X-Ray when I instrument my functions.

Example

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']);

aws-xray-sdk-python supports this: https://github.com/aws/aws-xray-sdk-python#ignoring-httplib-requests

Hi @dreamorosi,

Thanks for the suggestion and we'll take a look and put it in our backlog. As a workaround, you can customize the sampling rule to filter out the unwanted requests that may contain sensitive date: https://docs.aws.amazon.com/xray/latest/devguide/xray-console-sampling.html#xray-console-custom

Hi @lupengamzn thanks for acknowledging the request and for the alternative suggestion. Just to clarify, let's say I'd want to suppress all requests for host example.com, would this sampling config do it?


{
  "version": 2,
  "rules": [
    {
      "description": "Mask Example",
      "host": "example.com",
      "http_method": "*",
      "url_path": "*",
      "fixed_target": 0,
      "rate": 0
    }
  ],
  "default": {
    "fixed_target": 1,
    "rate": 0.05
  }
}

Hi @dreamorosi ,

At this moment, if you want to suppress specific hosts, you may have to add the ones that you would like to trace in the Host section in the sampling rule.

Adding another use case to this feature request: AWS X-Ray has a limit of 64K tracing data (see X-Ray docs). This could be a problem if you're making hundreds of HTTP requests to the same endpoint.

Allowing customers to ignore a specific noisy endpoint would allow to keep tracing the function without hitting the limit. At the moment the alternative is to use different http clients, one instrumented with the sdk for requests you want to trace and another, not instrumented, for requests you don't want to trace. Not ideal.

Hi @dreamorosi, thanks for the feature request. We are always open to PRs if you'd like to add functionality similar to the X-Ray SDK for Python's. We are also aware of the challenge with 64K size segments, and have it on our roadmap to address this in the backend eventually. However at this point we do not have it on our roadmap to implement this behavior on the X-Ray SDK for Node.js.

Customers can check out the AWS Distro for OpenTelemetry, which offers request-level sampling so you can e.g. sample nested subsegments for HTTP requests at a low rate to not exceed the trace size limit.