Add Unity server telemetry sample for PlayFab MPS#95
Draft
dgkanatsios wants to merge 3 commits intomainfrom
Draft
Add Unity server telemetry sample for PlayFab MPS#95dgkanatsios wants to merge 3 commits intomainfrom
dgkanatsios wants to merge 3 commits intomainfrom
Conversation
New sample that collects game server metrics (simulation rate, memory, CPU, game state) and sends them to the PlayFab Telemetry API using a telemetry key. Files: - ServerMetricsCollector: collects 17 metrics via ProfilerRecorder, Profiler API, GC, and System.Diagnostics.Process (best-effort) - PlayFabTelemetrySender: sends events to WriteTelemetryEvents API with X-TelemetryKey auth, batching up to 200 events - ServerTelemetryManager: orchestrates collection/sending with configurable intervals, supports MPS managed secrets for the telemetry key (PF_MPS_SECRET_TelemetryKey env var) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a new Unity sample (UnityServerTelemetry/) that collects dedicated server performance/game metrics and ships them to PlayFab’s Telemetry API using a telemetry key (no PlayFab SDK dependency), plus a top-level README entry linking to it.
Changes:
- Introduces a
ServerTelemetryManagerorchestrator for periodic collection + batch sending. - Adds a
ServerMetricsCollectorusing Unity profiling/GC/process APIs to snapshot metrics. - Adds a
PlayFabTelemetrySenderthat posts batches toWriteTelemetryEvents, and documents setup/integration in a new sample README.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| UnityServerTelemetry/Scripts/ServerTelemetryManager.cs | Adds orchestration for collection/sending, config resolution (env/Inspector), buffering, and lifecycle hooks. |
| UnityServerTelemetry/Scripts/ServerMetricsCollector.cs | Implements metrics snapshot collection via ProfilerRecorder/Profiler/GC/Process APIs. |
| UnityServerTelemetry/Scripts/PlayFabTelemetrySender.cs | Implements raw REST batching to WriteTelemetryEvents with X-TelemetryKey auth. |
| UnityServerTelemetry/README.md | Documents setup, metrics, and optional GSDK lifecycle wiring for the new sample. |
| README.md | Adds a repository-level section linking to the new Unity server telemetry sample. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes applied from reviews by Claude Opus 4.6, Sonnet 4, GPT-5.2, Haiku 4.5, and GPT-4.1: - Fix locale-dependent float serialization (use InvariantCulture) - Fix Entity field casing to lowercase (type/id per telemetry docs) - Fix Process.GetCurrentProcess() handle leak (wrap in using) - Fix WaitForSeconds → WaitForSecondsRealtime (timeScale immunity) - Fix division by zero when processorCount is 0 - Fix ProfilerRecorder.StartNew() crash on unsupported platforms - Fix README GSDK example: add Initialize() for deferred config - Add UnityWebRequest timeout (30s) - Add singleton guard to prevent duplicate managers - Add timestamp JSON escaping - Add entity ID truncation to 64 chars (API limit) - Add bounded buffer (500 max, drop-oldest) - Remove broken StopTelemetry flush (coroutine can't complete) - Rename gcAllocatedPerFrameBytes → lastFrameGcAllocBytes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Use _titleId field instead of constructor parameter for URL - Fix 'Not render FPS' grammar in README metrics table Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New
UnityServerTelemetry/sample with 3 drop-in C# scripts that collect game server metrics and send them to the PlayFab Telemetry API.Scripts
WriteTelemetryEventsAPI withX-TelemetryKeyauthPF_MPS_SECRET_TelemetryKey) or InspectorMetrics Collected
Design