Skip to content

feat: add X-CONFIDENCE-TELEMETRY header#234

Open
nicklasl wants to merge 3 commits intomainfrom
nicklasl/add-telemetry-header
Open

feat: add X-CONFIDENCE-TELEMETRY header#234
nicklasl wants to merge 3 commits intomainfrom
nicklasl/add-telemetry-header

Conversation

@nicklasl
Copy link
Member

Summary

  • Add Telemetry class with thread-safe trace accumulation and manual protobuf encoding matching confidence/telemetry/v1/types.proto
  • Send base64-encoded X-CONFIDENCE-TELEMETRY header on resolve and apply HTTP requests
  • Track flag evaluation outcomes (reason + error code) and resolve latency (duration + status)
  • Tag telemetry with OPEN_FEATURE library when used via ConfidenceFeatureProvider

Test plan

  • Unit tests verify protobuf encoding round-trips against generated proto code
  • Integration tests verify header presence/absence on MockWebServer requests
  • getFlag() → telemetry tracking verified end-to-end
  • Multiple resolves accumulate latency traces
  • Apply requests carry telemetry header
  • Provider reflection sets library to OPEN_FEATURE
  • Thread safety under concurrent writes/reads
  • ./gradlew :confidence:build :Provider:build passes

🤖 Generated with Claude Code

nicklasl and others added 2 commits March 23, 2026 17:35
Track evaluation outcomes and resolve latency via a base64-encoded
protobuf Monitoring message sent on HTTP headers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nicklasl nicklasl marked this pull request as ready for review March 24, 2026 13:45
* fix: align telemetry implementation with Swift SDK for feature parity

- Add missing enum values (CACHED, STATIC, SPLIT, TYPE_MISMATCH, PROVIDER_FATAL)
- Capture library under lock during snapshot to fix race condition
- Always send X-CONFIDENCE-TELEMETRY header (match Swift behavior)
- Fix Long→Int truncation in varint encoding for durationMs
- Omit zero-valued fields in protobuf encoding (canonical wire format)
- Replace reflection-based OpenFeature attribution with direct API call
- Update tests for all changes

Made-with: Cursor

* chore: add telemetry test button to demo app

Adds a "Test Telemetry" button that evaluates both real flags (match)
and nonexistent flags (error), then triggers a fetch to flush the
telemetry header for verification in Grafana.

Made-with: Cursor

* Revert "chore: add telemetry test button to demo app"

This reverts commit 1d9e6de.

* fix: address review feedback — keep header conditional and reflection-based attribution

- Revert encodedHeaderValue() to return String? (don't send header when no traces)
- Restore conditional header logic in RemoteFlagResolver and FlagApplierClientImpl
- Keep setTelemetryLibraryOpenFeature() private, called via reflection from Provider
- Restore corresponding tests to assert null/reflection behavior

Retained from parity work:
- Missing enum values (CACHED, STATIC, SPLIT, TYPE_MISMATCH, PROVIDER_FATAL)
- Library captured under lock during snapshot (race condition fix)
- Long-capable writeVarint (durationMs truncation fix)
- Zero-valued field omission (canonical protobuf encoding)

Made-with: Cursor
@fabriziodemaria
Copy link
Member

Screenshot 2026-03-25 at 09 11 34

Verified manually, with testing evaluations in a demo app

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.

2 participants