aws/aws-xray-sdk-node

Networking-level http instrumentation

Closed this issue · 3 comments

Is it possible to break down the http instrumentation even further to expose networking-level events such as dns lookup, tls handshake, time to first header, time to first byte, etc?

This would be super helpful in identifying network-level optimizations such as IP caching, connection reuse, etc.

Edit: proxy networking events would also be helpful

Thanks 🙏

Hi @mattfysh,

Thanks for the feature request. We don't have the bandwidth to add this at the moment, but would always be open to a pull request. This feature would likely have to be opt-in since otherwise it could greatly increase trace size for some users with many HTTP subsegments.

Thanks @willarmiros - I'll send through a PR in the next month or so.

Quick question - is there any way to prevent the X-Amzn-Trace-Id from being sent with http/s requests? ta!

Ended up going with this:

const capture = lib => {
  const origRequest = lib.request
  const interceptRequest = (...args) => {
    const options = typeof args[1] === 'object' ? args[1] : args[0]
    delete options.headers['X-Amzn-Trace-Id']
    return origRequest(...args)
  }
  Object.defineProperties(lib, {
    request: {
      value: interceptRequest,
      configurable: true,
      enumerable: true,
      writable: true,
    },
  })
  AWSXRay.captureHTTPsGlobal(http, false, subsegmentCallback)
}

capture(http)
capture(https)