Skip to content

Fix HTTP instrumentation for http gem v6.0+#614

Merged
lancetarn merged 2 commits into
masterfrom
613-http-instrumentation-incompatible-with-http-gem-v60
Mar 31, 2026
Merged

Fix HTTP instrumentation for http gem v6.0+#614
lancetarn merged 2 commits into
masterfrom
613-http-instrumentation-incompatible-with-http-gem-v60

Conversation

@lancetarn
Copy link
Copy Markdown
Contributor

@lancetarn lancetarn commented Mar 26, 2026

Summary

  • Fixes HTTP instrumentation incompatible with http gem v6.0 #613ArgumentError: wrong number of arguments (given 3, expected 2) when using http gem v6.0+
  • http gem v6.0 changed HTTP::Client#request from positional args (verb, uri, opts = {}) to keyword args (verb, uri, **opts)
  • Adds version detection via Gem::Version and separate instrumentation paths for v5 (positional) and v6+ (keyword) in both the prepend and alias code paths

Test plan

  • Existing HTTP instrumentation test updated and passes with http gem v6.0.2
  • Full test suite (284 tests) passes with no regressions
  • Verify with http gem v5.x to confirm backwards compatibility

🤖 Generated with Claude Code

…ation

http gem v6.0 changed HTTP::Client#request from positional args (verb, uri, opts = {})
to keyword args (verb, uri, **opts). Add version detection and separate instrumentation
paths for v5 (positional) and v6+ (keyword) to maintain backwards compatibility.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@lancetarn lancetarn linked an issue Mar 26, 2026 that may be closed by this pull request
@kjanoudi
Copy link
Copy Markdown

We hit the same incompatibility in production after upgrading to http 6.

Our environment:

  • scout_apm 6.1.1
  • http 6.0.2
  • Ruby 3.4.7
  • Rails 8.0.2.1

Observed error:
ArgumentError: wrong number of arguments (given 3, expected 2)

One failing path for us was a Sidekiq job calling HTTP.get(..., params: ...) through IpInfo.fetch_ipstack, but we also found other backend HTTP calls using params:, json:, and form: that would go through the same Scout wrapper.

We applied a local compatibility patch that forwards **opts in both the alias and prepend instrumentation paths, and that resolved the issue for us. So this PR matches what we needed downstream.

Thanks for putting this together.

@lancetarn lancetarn merged commit 480d3f5 into master Mar 31, 2026
42 checks passed
@lancetarn lancetarn deleted the 613-http-instrumentation-incompatible-with-http-gem-v60 branch March 31, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP instrumentation incompatible with http gem v6.0

3 participants