Skip to content

feat(telemetry): enrich trace attributes and harden AI provider connection resilience - #672

Merged
dan-petty merged 1 commit into
release/v0.2.23from
feat/telemetry-rich-attributes
Sep 28, 2026
Merged

dan-petty merged 1 commit into
release/v0.2.23from
feat/telemetry-rich-attributes

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

Enriches OpenTelemetry traces with granular runtime, VCS, Kubernetes, caller location, and GenAI telemetry attributes, while hardening AI provider clients (OpenAI and Claude) against transient network drops, connect timeouts, and uninformative error masking during parallel branch reviews.

Key Changes

  1. Telemetry Trace Enrichment:
    • Zero-subprocess Git HEAD inspection for vcs.ref.name and vcs.revision_id.
    • Kubernetes context and namespace detection (k8s.context, k8s.namespace).
    • Call frame inspector extracting caller source file (code.filepath), function name (code.function), and line number (code.lineno).
    • Thread and process metadata (thread.name, thread.id, process.pid).
    • Granular GenAI telemetry: gen_ai.response.model, gen_ai.server.served_by, gen_ai.tokens_per_second, gen_ai.request.temperature, gen_ai.request.top_p.
  2. AI Provider Connection Resilience & Error Hardening:
    • Updated OpenAI-compatible and Claude provider mixins to reuse connection pools (_shared_client()) rather than re-negotiating TLS handshakes on every prompt/file turn.
    • Wired native tenacity-based retry transport (create_retry_transport) for automatic exponential backoff and Retry-After header parsing across transient 408, 429, 500, 502, 503, and 504 responses.
    • Introduced DEFAULT_AI_CONNECT_TIMEOUT_SECONDS (5.0s) to prevent spurious connect timeouts over WAN ingress and Cloudflare tunnels.
    • Enhanced _provider_http_error to report informative HTTP status codes and response bodies (sanitized against secrets) rather than masking failures with generic credential warnings.

Verification

  • uv run devops ci: 100% pass across all quality gates (python_version, test, coverage >= 90.6%, lint, format, typecheck, audit, security, actionlint, docs).
  • tests/test_telemetry.py: 28 passed.
  • tests/test_ai_client_retries.py: 11 passed.
  • tests/test_architectural_invariants.py: 13 passed.

…ction resilience

- Add zero-subprocess Git HEAD inspection for vcs.ref.name and vcs.revision_id
- Add Kubernetes context and namespace detection for telemetry spans
- Add automatic caller code inspection (code.filepath, code.function, code.lineno)
- Enrich thread and process metadata (thread.name, thread.id, process.pid)
- Add granular GenAI telemetry (gen_ai.response.model, gen_ai.server.served_by, gen_ai.tokens_per_second)
- Harden OpenAI and Claude provider clients to use connection-pooled shared clients with tenacity retry transport
- Add DEFAULT_AI_CONNECT_TIMEOUT_SECONDS (5.0s) to prevent spurious connect timeouts over WAN tunnels
- Enhance provider HTTP error formatting to report informative HTTP status codes and details rather than masking as credential failures
@dan-petty
dan-petty merged commit 5d4aea1 into release/v0.2.23 Sep 28, 2026
8 checks passed
@dan-petty
dan-petty deleted the feat/telemetry-rich-attributes branch September 28, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

1 participant