When configuring the Faraday adapter globally with
Datadog.configure do |c|
c.use :faraday
end
I start seeing this deprecation warning all around:
WARNING: Unexpected middleware set after the adapter. This won't be supported from Faraday 1.0.
Seems to come from the way it's patching Faraday::Connection here:
https://github.com/DataDog/dd-trace-rb/blob/v0.32.0/lib/ddtrace/contrib/faraday/patcher.rb#L42
https://github.com/DataDog/dd-trace-rb/blob/v0.32.0/lib/ddtrace/contrib/faraday/connection.rb
From this issue (https://github.com/lostisland/faraday/issues/946) seems like there's not currently a way to add a default middleware that'll be supported in v1.0.
Is this a know issue? Are there any workarounds around it?
Hmmmm, thanks for the report @kitop !
If I'm understanding things correctly, sounds like Faraday's maintainers don't want default middleware because requests can be sensitive to the presence and order of the middleware stack. Although our APM middleware is unlikely to cause such issues, that's not universally true about other Faraday middleware, such that they'd rather just avoid the problem outright by preventing middleware from being added this way.
If there isn't some way of injecting this middleware at the base class level without raising this warning, then we might have to resort to some other form of aggressive monkey patching, perhaps something like https://github.com/lostisland/faraday/issues/946#issuecomment-500607890
We'll have to experiment... I'll know more when I find the time to replicate this in a test environment.
In the mean time, I think you should be able to avoid this by adding our middleware explicitly to the middleware stack when you declare your own Faraday connection (which should be in our documentation.)
I've opened #971 to address this warning.
:wave: @kitop, our implementation currently works for both Faraday 0.x and 1.x, but version 0.x raises a warning due to the way we are patching Faraday.
We've changed the way we patch 0.x, moving back to the old strategy we used before https://github.com/DataDog/dd-trace-rb/pull/906 was merged, to allow it to run without warnings.
This warning does not affect correctness, so we'll ship it in our regular release cycle.
Hi @marcotc and @delner, thank you both for the quick response and turnaround!! Really appreciate it!
@delner @marcotc when is the next scheduled release? is it possible to release a patch version with #971. The issue is, it's overwhelming our logs, I could silence those temporarily but then we don't want to forget about it and have a breaking change some day.
@rahul342 I think we're aiming for a release early next week; we'll keep you posted.
This will release with 0.34.0.
Most helpful comment
This will release with 0.34.0.