Skip to content

Complete spans for every retry attempt, add error ignoring options - #12

Merged
dubonzi merged 1 commit into
mainfrom
fix/retry-spans-error-ignorer
Oct 12, 2026
Merged

dubonzi merged 1 commit into
mainfrom
fix/retry-spans-error-ignorer

Conversation

@dubonzi

@dubonzi dubonzi commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Fixes Missing parent span if RetryCount > 0 #9: resty re-runs OnBeforeRequest on every retry attempt, but only the final attempt's span was ever completed. Attempts that failed before a response arrived (transport errors) were left dangling, and OnError recorded the error on an already-ended span. The middleware now tracks the current attempt's span in the request context, chains each attempt to the previous one, and closes the previous attempt's span when a retry starts. A regression test reproduces the dangling-span behavior on main and passes with this change.
  • Fixes Add option to ignore certain errors #7: new WithIgnoredErrors(errs ...error) option (matched with errors.Is, covering sentinels like resty.ErrAutoRedirectDisabled) and WithErrorIgnorer(f func(error) bool) predicate option. Ignored errors no longer record an error event or set error status.
  • Skipper fix: response/error handling now operates only on spans created by this instrumentation. Previously, with WithSkipper active and a caller-provided span in the request context, the middleware would end the caller's span.
  • Semconv update: replaces the semconv/v1.4.0 and httpconv v1.13.0 conversion helpers with the current stable HTTP attributes from semconv/v1.43.0 (http.request.method, url.full, url.path, server.address, server.port, http.request.body.size, http.response.status_code, http.response.body.size). resty.url behavior is unchanged. Note this is an observable change for consumers matching on the old attribute names.

Tests

go test ./... -count=1 -race passes, including new tests for: retry attempt span completion and parent-child chaining, all-attempts-fail error recording, ignored errors (list and predicate), skipper not ending caller spans, and WithHideURL redaction.

Resty re-runs OnBeforeRequest on every retry attempt, but only the span
of the final attempt was ever completed: attempts that failed before a
response arrived were left dangling (issue #9), and OnError recorded the
error on an already-ended span when a response was present.

The middleware now tracks the current attempt span in the request
context and closes the previous attempt's span when a retry starts.
Response and error handling operate only on that stored span, so
requests skipped by the skipper no longer end a caller-provided span.

Also adds WithIgnoredErrors and WithErrorIgnorer (issue #7), so benign
errors like resty.ErrAutoRedirectDisabled no longer mark spans as
erroneous, and updates request/response attributes to the current
stable HTTP semantic conventions (http.request.method, url.full,
url.path, server.address/port, http.response.status_code) replacing the
ancient semconv v1.4.0 and httpconv v1.13.0 conversion helpers.

Fixes #9
Fixes #7
@dubonzi
dubonzi force-pushed the fix/retry-spans-error-ignorer branch from 07fe585 to 795c7d8 Compare October 12, 2026 12:37
@dubonzi
dubonzi merged commit 9e15221 into main Oct 12, 2026
1 check passed
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.

Missing parent span if RetryCount > 0 Add option to ignore certain errors

1 participant