Ktor client: HTTP span shows the redirect’s status instead of the final response

Đang mở
#6,346 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, kotlin
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Start by reading the sentry-ktor-client implementation of SentryKtorClientPlugin and its tests for redirect handling; the issue names no specific file or test. Reproduce with Ktor 3.0.0 using a 302 redirect followed by a delayed 500, then trace when the HTTP span is closed and beforeSpan is called. Done when the span covers the full redirect chain, reflects the final response status, and beforeSpan runs once before closure.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug Java Spans
Integration

other

Java Version

17

Other Error Monitoring Solution

No

Other Error Monitoring Solution Name

No response

Version

8.61.0

Steps to Reproduce

Integration: sentry-ktor-client 8.61.0, Ktor client 3.0.0 (Java engine)

  1. Set up a server where /start returns 302 to /fail, and /fail returns 500 after a short delay.
  2. Make a request to /start with a Ktor client that uses SentryKtorClientPlugin (redirects are followed by default), inside a transaction.
  3. Look at the trace in Sentry: the http.client span is ok and much shorter than the request, even though a “HTTP Client Error with status code: 500” event is captured
  4. Repeat with waitForChildren = true on the transaction and call finish() while the request is in flight: the transaction is sent before the 500 comes back.

Example from my own test org: https://kismeow.sentry.io/explore/traces/?end=2026-10-21T23%3A59%3A59&field=id&field=span.name&field=span.description&field=span.duration&field=transaction&field=timestamp&field=span.status&project=-1&start=2026-10-21T00%3A00%3A00&utc=true

Expected Result

The span stays open for the whole redirect chain, then gets the final response's status and is passed to beforeSpan once before it's closed.

Actual Result

When a request made with SentryKtorClientPlugin gets redirected, the HTTP span is closed as soon as the redirect comes back, not when the final response arrives.

For a request that goes 302 → 500:

  • The span is marked ok, even though the request ended with a 500 (the 500 error event is still captured).
  • The span's duration covers only the redirect response, so it looks much faster than it really was.
  • beforeSpan is called for every response in the redirect chain. The second call gets a span that’s already closed.
  • If the transaction waits for its child spans (waitForChildren), it gets sent right after the redirect, before the request is actually done.
Ngôn ngữ chính
Kotlin
Star
1.4k
Fork
483
Merge trung bình
2 ngày 54 phút
Pull request đã merge (30 ngày)
207

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của getsentry/sentry-java

Tất cả issue của getsentry/sentry-java

Issue tương tự

Thêm issue về Kotlin

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.