Skip to content

Instrument HTTP.rb chained requests on version 6#1528

Merged
unflxw merged 1 commit into
mainfrom
http-rb-session-instrumentation
Jul 3, 2026
Merged

Instrument HTTP.rb chained requests on version 6#1528
unflxw merged 1 commit into
mainfrom
http-rb-session-instrumentation

Conversation

@unflxw

@unflxw unflxw commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Part of #1515, spun as a separate PR to make reviewing easier.

While working on distributed tracing for HTTP clients we found a gap in the HTTP.rb integration that stands on its own, so it's split out here without any of the trace-context propagation (which is collector-mode only).


The HTTP.rb integration records its request.http_rb event by prepending onto HTTP::Client#request. In http 6, though, a chained request -- HTTP.follow.get(...), HTTP.headers(...).get(...), HTTP.timeout(...).get(...), and so on -- runs through HTTP::Session#request instead, which never touches HTTP::Client#request. As a result those requests were not instrumented at all: no event was recorded for them.

This prepends the same request instrumentation onto HTTP::Session as well, so a chained request produces a request.http_rb event like any other request. http 5 has no Session; chained requests go through Client#request there, so it's unaffected.

The event is still recorded at the request boundary, so a redirected request stays a single event spanning every hop -- the added spec drives HTTP.follow through a redirect and asserts exactly one request.http_rb event, which fails on http 6 without this change.

In http 6 a chained request -- HTTP.follow.get(...),
HTTP.headers(...).get(...), and so on -- runs through HTTP::Session
rather than HTTP::Client, which never touches the instrumented
Client#request. Those requests were not recorded.

Prepend the request instrumentation onto HTTP::Session too, so a
chained request produces a request.http_rb event like any other. http 5
has no Session; chained requests go through Client#request there.
@backlog-helper

backlog-helper Bot commented Jun 26, 2026

Copy link
Copy Markdown

✔️ All good!

New issue guide | Backlog management | Rules | Feedback

@unflxw unflxw changed the title Instrument HTTP.rb chained requests on http 6 Instrument HTTP.rb chained requests on http 6 Jun 26, 2026
@unflxw unflxw changed the title Instrument HTTP.rb chained requests on http 6 Instrument HTTP.rb chained requests on version 6 Jun 26, 2026
@unflxw
unflxw requested a review from Copilot June 26, 2026 09:37
@unflxw unflxw added the bug Confirmed and unconfirmed bugs reported by us and customers. label Jun 26, 2026
@unflxw
unflxw requested review from lipskis and tombruijn June 26, 2026 09:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR closes an instrumentation gap in the HTTP.rb integration for http v6 by ensuring chained requests (e.g., HTTP.follow.get, HTTP.headers(...).get) emit the request.http_rb event, just like non-chained requests.

Changes:

  • Prepend the existing request instrumentation module onto HTTP::Session (http v6 chained request path) in addition to HTTP::Client.
  • Add a spec asserting redirect-following (HTTP.follow) produces exactly one request.http_rb event spanning all hops.
  • Add a hook spec verifying the HTTP::Session instrumentation module is installed when http v6 is present.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
spec/lib/appsignal/integrations/http_spec.rb Adds a redirect-follow spec asserting a single request.http_rb event for HTTP.follow.
spec/lib/appsignal/hooks/http_spec.rb Verifies HTTP::Session is instrumented for http v6.
lib/appsignal/integrations/http.rb Documents the request-boundary and introduces context for HTTP::Session#request instrumentation.
lib/appsignal/hooks/http.rb Installs instrumentation on HTTP::Session when available (http v6 chained requests).
.changesets/instrument-http-rb-chained-requests.md Records the fix as a patch changeset.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@backlog-helper

This comment has been minimized.

@backlog-helper

This comment has been minimized.

2 similar comments
@backlog-helper

This comment has been minimized.

@backlog-helper

backlog-helper Bot commented Jul 3, 2026

Copy link
Copy Markdown

This is a message from the daily scheduled checks.

New issue guide | Backlog management | Rules | Feedback

@unflxw
unflxw merged commit d7fd56a into main Jul 3, 2026
208 checks passed
unflxw added a commit to appsignal/test-setups that referenced this pull request Jul 9, 2026
Add Faraday GET/POST endpoints to rails7-sidekiq so the new automated
Faraday integration is exercised (and its downstream Net::HTTP event
suppressed). Add chained HTTP.rb requests -- a headers chain and a
followed redirect -- which run through HTTP::Session on http 6 and were
previously uninstrumented.

Targets:
appsignal/appsignal-ruby#1523 (Faraday)
appsignal/appsignal-ruby#1528 (HTTP.rb chained)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Confirmed and unconfirmed bugs reported by us and customers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants