Skip to content

Add resty v3 (resty.dev/v3) support via restyv3 subpackage - #13

Merged
dubonzi merged 7 commits into
mainfrom
feat/resty-v3
Oct 12, 2026
Merged

dubonzi merged 7 commits into
mainfrom
feat/resty-v3

Conversation

@dubonzi

@dubonzi dubonzi commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

Implements #8 by adding github.com/dubonzi/otelresty/restyv3 for resty.dev/v3 v3.0.0-rc.4. Users call restyv3.TraceClient(cli, opts...); the root resty v2 instrumentation is retained alongside the new package.

restyv3/
  config.go           tracing options, including ignored errors
  resty.go            request-owned spans, retry lifecycle, HTTP attributes
  transport.go        capture errors before Resty clears them for retries
  resty_test.go       instrumentation and retry coverage
  regression_test.go  nested requests, redaction, retry failures, compatibility
  version.go          instrumentation version independent of the v2 package

Creates one client span per attempt, chained to the previous attempt and ended exactly once. Nested requests can inherit the parent context without ending or modifying the parent's attempt, including when skipped or rejected before tracing runs. Credentials are redacted in both resty.url and url.full; WithHideURL replaces both values with <redacted>.

Uses HTTP semconv v1.37.0 attributes and marks responses with status >= 400 as Error. WithErrorIgnorer and WithIgnoredErrors apply to each attempt. Transport, redirect-policy and response middleware errors are captured before rc.4 clears them during retry processing. Retry spans are finalized when the next attempt starts, using a timestamp from before backoff; cancellation and retry-strategy failures during backoff are recorded by the final error hook.

Configure transport, proxy, redirect policy and response middleware before calling TraceClient. Replacing the wrapped transport or policy afterward bypasses error capture. TLS configuration and idle-connection cleanup still delegate to the original transport. The tests use explicit retry conditions and a custom redirect-policy sentinel because rc.4 has no ErrAutoRedirectDisabled.

The shared OpenTelemetry API/SDK dependencies are updated to v1.47.0. The module now requires Go 1.26.0, matching the SDK's minimum Go version. CI uses the latest released actions/checkout@v7.0.1 and actions/setup-go@v7.0.0, reads the Go version from go.mod, uses setup-go caching, and verifies, builds, vets and race-tests both packages. GOTOOLCHAIN=local prevents CI from silently testing a newer toolchain.

Evidence

  • Before: Five targeted tests reproduced premature parent-span termination, plaintext URL credentials, ignored retry errors marked as failures, lost response middleware errors, and lost cancellation errors during backoff.
    After: All five original reproducers pass, with permanent regression coverage for each case, request-level retry hooks, retry-strategy errors, unrelated transport errors, TLS configuration, ErrUseLastResponse, and retry timestamps.
  • Main was merged into the PR branch; both the v2 and v3 README sections are preserved.
  • Verified with the minimum Go 1.26.0 toolchain:
    • go mod verify
    • go build ./...
    • go vet ./...
    • go test ./... -race -count=1
  • actionlint v1.7.12 passes for .github/workflows/go.yml.
  • git diff --check

Merge Danger

Door: two-way. No migrations or destructive changes.

Blast Radius: project. Consumers need Go 1.26.0 or newer for the updated OpenTelemetry SDK. The new package wraps the configured transport and redirect policy to preserve retry errors; configure these components before instrumentation, as documented in the README and TraceClient godoc.

Adds the restyv3 subpackage with TraceClient for resty.dev/v3 clients.
Creates one client span per request attempt, chained to the previous
attempt and ended exactly once, tracked via a private context key so the
caller's span is never touched. Uses semconv v1.37.0 attributes and adds
WithErrorIgnorer and WithIgnoredErrors options.
Associate attempts with their owning request so nested and skipped requests cannot finalize caller spans. Redact credentials in resty.url. Capture transport, redirect, and response middleware errors before Resty rc.4 clears them for retries, honoring ignored errors on every attempt. Finalize retry spans only when another attempt starts or a final hook runs so backoff cancellation and strategy errors remain observable, retaining pre-backoff end timestamps for actual retries.
Set the minimum Go version to 1.26.0, as required by the latest stable OpenTelemetry SDK, and update the shared API, SDK, trace and metric modules to v1.47.0. Use the latest checkout v7.0.1 and setup-go v7.0.0 releases, read the Go version from go.mod, replace deprecated manual caches with setup-go caching, and verify, build, vet and race-test both packages in CI.
@dubonzi
dubonzi merged commit 685af5e 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.

1 participant