aws / aws-xray-sdk-ruby

The official AWS X-Ray Recorder SDK for Ruby
Apache License 2.0
59 stars 58 forks source link

cannot trace http + aws sdk clients used in required gems #76

Closed markgllin closed 2 years ago

markgllin commented 2 years ago

Problem:

the net_http and aws_sdk libraries are not patched by the xray sdk if those libraries are used through a gem as opposed to directly through the application.

e.g. our Gemfile for our Rails application:

gem 'aws-xray-sdk', require: ['aws-xray-sdk/facets/rails/railtie']
gem 'faraday'     # uses `net_http` lib by default
gem 'sqs-client'  # our own gem that makes use of aws-sdk-sqs

X-Ray configuration:

## /app/config/initializers/aws_xray.rb
xray_config = {
  name: "App",
  plugins: %I[ec2 elastic_beanstalk],
  patch: %I[net_http aws_sdk],
  sampling: true
}

Rails.application.config.xray = xray_config

Requests made through Faraday to our API Gateway will not be captured by XRay. The same goes for our sqs calls made through our own sqs-client gem.

bhautikpip commented 2 years ago

right I don't think you would be able to trace calls inside the dependencies. I think if you have written ruby app where you're doing HTTP call and aws SDK sqs calls and then do the above x-ray configuration then I think SDK would be able to patch those requests and you should see traces. In this case I guess the HTTP call is made by the lib (faraday) where x-ray SDK is not instrumented so that's why you're seeing no traces.

markgllin commented 2 years ago

in other words, if the libraries that x-ray supports are called through a gem dependency instead of directly, we're unable to trace the call?

Are you able to suggest any workarounds for this?

markgllin commented 2 years ago

worked around this by manually creating a new segment