Skip to content

feat(factor-outbound-http): report http.response.body.size for WASI p3 responses#3506

Merged
itowlson merged 1 commit into
spinframework:mainfrom
ChihweiLHBird:zhiwei/p3-outbound-http-resp-body-size
May 12, 2026
Merged

feat(factor-outbound-http): report http.response.body.size for WASI p3 responses#3506
itowlson merged 1 commit into
spinframework:mainfrom
ChihweiLHBird:zhiwei/p3-outbound-http-resp-body-size

Conversation

@ChihweiLHBird
Copy link
Copy Markdown
Contributor

@ChihweiLHBird ChihweiLHBird commented May 12, 2026

Description

Adds the stable OpenTelemetry semantic convention http.response.body.size to the spin_outbound_http.send_request span for outbound HTTP calls made through the WASI p3 interface.

Key points

  • The attribute records the actual number of response body bytes delivered to the guest (counted frame-by-frame during streaming), not a Content-Length guess.
  • Clean end-of-stream (Ready(None) or is_end_stream()) triggers the recording exactly once via a deferred Span::record on the instrumented span.
  • On body read errors the size field is intentionally left unset (to keep the metric untainted) and a warning is emitted with tracing::warn!().

Partially resolve #3188 (Option 2).

@ChihweiLHBird ChihweiLHBird force-pushed the zhiwei/p3-outbound-http-resp-body-size branch from 3ecb386 to 06ff177 Compare May 12, 2026 04:54
… p3 responses

Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
@ChihweiLHBird ChihweiLHBird force-pushed the zhiwei/p3-outbound-http-resp-body-size branch from 06ff177 to 6542f14 Compare May 12, 2026 05:23
Copy link
Copy Markdown
Collaborator

@calebschoepp calebschoepp left a comment

Choose a reason for hiding this comment

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

Seems fine from an OTel perspective. Maybe @dicej can comment from a P3/HTTP perspective.

Copy link
Copy Markdown
Contributor

@dicej dicej left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

This is a good reminder that we need more test coverage for this kind of thing. I see there is a basic otel_smoke_test in tests/integration.rs, but it doesn't currently do much. Expanding that test to check for e.g. http.response.body.size and make it run both p2 and p3 components seems appropriate.

We might also be able to unit test this kind of thing using e.g. https://crates.io/crates/tracing-fluent-assertions, although I don't personally have experience with that.

@itowlson itowlson merged commit 62d2811 into spinframework:main May 12, 2026
17 checks passed
@ChihweiLHBird ChihweiLHBird deleted the zhiwei/p3-outbound-http-resp-body-size branch May 12, 2026 21:36
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.

Include body sizes in outbound HTTP telemetry

4 participants