Skip to content

feat: add two-dimensional evaluation telemetry schema#351

Closed
fabriziodemaria wants to merge 3 commits intomainfrom
fdema/evaluation-telemetry-schema
Closed

feat: add two-dimensional evaluation telemetry schema#351
fabriziodemaria wants to merge 3 commits intomainfrom
fdema/evaluation-telemetry-schema

Conversation

@fabriziodemaria
Copy link
Copy Markdown
Member

Summary

  • Adds EvaluationReason and EvaluationErrorCode enums to TelemetryData, aligned with the remote SDK telemetry header schema (confidence.telemetry.v1.EvaluationTrace)
  • Introduces repeated EvaluationRate evaluation_rate = 9 as a new field carrying two-dimensional (reason, error_code) counters, replacing the flat ResolveReason-based resolve_rate
  • The legacy resolve_rate field (tag 5) is deprecated but still populated for backward compatibility
  • Implements map_resolve_reason() in Rust to translate ResolveReason(EvaluationReason, EvaluationErrorCode) with the same mapping logic used in the Java/Swift/JS remote SDKs

Mapping

ResolveReason EvaluationReason EvaluationErrorCode
MATCH TARGETING_MATCH UNSPECIFIED
NO_SEGMENT_MATCH / NO_TREATMENT_MATCH DEFAULT UNSPECIFIED
FLAG_ARCHIVED DISABLED UNSPECIFIED
TARGETING_KEY_ERROR ERROR TARGETING_KEY_MISSING
ERROR ERROR GENERAL
UNRECOGNIZED_TARGETING_RULE ERROR GENERAL
MATERIALIZATION_NOT_SUPPORTED ERROR GENERAL

Why

This enables unified telemetry metrics across local resolvers (WASM/native) and remote SDKs (Java, Swift, JS), which all use the same (EvaluationReason, EvaluationErrorCode) dimensions. The backend ConfidenceSdkTelemetryInterceptor already processes these dimensions from the X-CONFIDENCE-TELEMETRY header — this change brings the local resolver's WriteFlagLogs telemetry in line.

Not included (future work)

  • Provider-side client errors (TYPE_MISMATCH, FLAG_NOT_FOUND from path traversal) are not yet pushed into the WASM. The new EvaluationErrorCode enum already has the values for this; a new WASM guest function will be added in a follow-up.

Test plan

  • All 16 telemetry unit tests pass (cargo test -- telemetry)
  • New test map_resolve_reason_coverage validates all ResolveReason(EvaluationReason, EvaluationErrorCode) mappings
  • New test telemetry_mark_resolve_error_reasons validates error-specific counters
  • Existing delta/snapshot tests updated to verify both legacy resolve_rate and new evaluation_rate fields
  • CI (WASM build + full test suite)

Made with Cursor

Replace the flat ResolveReason-based resolve_rate counters with a
two-dimensional (EvaluationReason, EvaluationErrorCode) model that
aligns with the remote SDK telemetry header schema
(confidence.telemetry.v1.EvaluationTrace).

This enables unified metrics across local and remote resolvers:
- MATCH → TARGETING_MATCH
- NO_SEGMENT_MATCH / NO_TREATMENT_MATCH → DEFAULT
- FLAG_ARCHIVED → DISABLED
- TARGETING_KEY_ERROR → ERROR + TARGETING_KEY_MISSING
- ERROR / UNRECOGNIZED_TARGETING_RULE / MATERIALIZATION_NOT_SUPPORTED → ERROR + GENERAL

The legacy resolve_rate field is deprecated but still populated for
backward compatibility. The new evaluation_rate field (tag 9) carries
the same data mapped through the two-dimensional model.

Made-with: Cursor
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