Dd-trace-rb: Faraday Integration Usage

Created on 2 Aug 2019  路  4Comments  路  Source: DataDog/dd-trace-rb

Hi,

I am attempting to use the faraday integration in a rails app. I am unclear on the usage of the integration. Looking at the API spec:

require 'faraday'
require 'ddtrace'

# Configure default Faraday tracing behavior
Datadog.configure do |c|
  c.use :faraday, options
end

# Configure Faraday tracing behavior for single connection
connection = Faraday.new('https://example.com') do |builder|
  builder.use(:ddtrace, options)
  builder.adapter Faraday.default_adapter
end

connection.get('/foo')

Are both of these additions necessary for faraday tracing? I ask because I originally attempted to add just the Datadog.configure block, but was unable to see any tracing in datadog. Once I added the builder.use line to a single connection for a sanity check, I was able to see the tracing show up. I was under the impression that was only necessary to customize a single connection if desired. Was I incorrect (and this is needed for every connection), or is something funky occurring with my default behavior (if the latter I can provide more information)? I am using faraday version 0.9.2 and ddtrace version 0.25.1.

Thanks,
Mike

bug community integrations

Most helpful comment

@mdross95 @martinisoft The change for this should roll with 0.29.0. Thanks for reporting this!

All 4 comments

My understanding was you should only need Datadog.configure, but can use builder.use(:ddtrace, options) to customize individual connections. However, looking at the unit tests, I can't see that we test with only Datadog.configure, so there's a reasonable chance this doesn't work as intended.

If so, we'll look into adjusting this so you only have to do Datadog.configure, if at all possible. Thanks for the report!

Thanks!

This has also affected our integration as well despite having the latest Faraday and Faraday Middleware gems. Had to manually inject in .use :ddtrace in more than a few places where I thought it was working. I too was under the impression from the docs and the code that this injected itself automatically when enabled, but that doesn't appear to be the case.

@mdross95 @martinisoft The change for this should roll with 0.29.0. Thanks for reporting this!

Was this page helpful?
0 / 5 - 0 ratings