Skip to content

feat(unity): add telemetry to Unity SDK#39

Draft
nicklasl wants to merge 1 commit intomainfrom
nicklasl/add-unity-telemetry
Draft

feat(unity): add telemetry to Unity SDK#39
nicklasl wants to merge 1 commit intomainfrom
nicklasl/add-unity-telemetry

Conversation

@nicklasl
Copy link
Copy Markdown
Member

Summary

  • Add SDK telemetry to the Unity SDK, tracking resolve latency and evaluation outcomes
  • Sent via X-CONFIDENCE-TELEMETRY header on resolve requests using manual protobuf encoding
  • Thread-safe trace accumulation with snapshot-and-clear, capped at 100 traces per type
  • All telemetry code guarded with try/catch — telemetry errors never affect SDK functionality
  • Mirrors the telemetry implementation from the main .NET SDK (PR feat: add telemetry to .NET SDK #38)

Changes

  • New: Runtime/Telemetry/TelemetryEnums.cs — protobuf enum types
  • New: Runtime/Telemetry/ProtobufEncoder.cs — manual wire-format encoder
  • New: Runtime/Telemetry/Telemetry.cs — trace accumulation, encoding, reason mapping
  • Modified: ConfidenceApiClient.cs — attach header on resolve, track latency via Stopwatch
  • Modified: ConfidenceProvider.cs — track evaluation outcomes in ResolveObjectValue

Test plan

  • Unity build test passes (build-test.sh)
  • Resolve requests include X-CONFIDENCE-TELEMETRY header after first call
  • Event/apply requests do NOT include telemetry header
  • Telemetry errors do not propagate to callers

🤖 Generated with Claude Code

Track resolve latency and evaluation outcomes, sent via
X-CONFIDENCE-TELEMETRY header on resolve requests. Manual
protobuf encoding, all call sites guarded with try/catch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
// Add the client as a component
ConfidenceApiClient client = clientGO.AddComponent<ConfidenceApiClient>();
client.clientSecret = clientSecret;
client.Telemetry = new Telemetry.Telemetry(Platform.DotNet, client.sdkVersion);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be unity?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!

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