fix:Default connection middleware order for Faraday < 1.0 #1129
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow up from #1057
Related to #978
This PR addresses the middleware insertion order for global default connections (e.g.
Faraday.get
) for Faraday < 1.0.Functionality is not affect by this change, but a warning emitted by Faraday is now addressed:
Faraday >= 1.0 is not affected, as it uses a different patching code path.
Testing that warnings won't happen in the future is tricky: because activating an integration has irreversible side-effects on the patched library (Faraday in our case), we can only test
Datadog::Contrib::Faraday::Patcher.patch
once per RSpec execution. This would require us to perform all our assertions in a single example run, which is not very practical. We also don't have a mechanism to ensure that a specific test runs first during an RSpec run, as successive runs ofDatadog::Contrib::Faraday::Patcher.patch
will just be a no-op.There are workarounds for this: initializing a fresh child Ruby process to execute specific tests; separating the patcher test into its own RSpec Rake task. But these are not trivial nor great options, and both come with performance and maintenance burden, so we'll try to address this issue in a systemic way in the future.