Skip to content

feat(auto-metrics): Add experimental auto game-metrics collection - #2777

Merged
bitsandfoxes merged 12 commits into
mainfrom
feat/auto-metrics
Aug 5, 2026
Merged

feat(auto-metrics): Add experimental auto game-metrics collection#2777
bitsandfoxes merged 12 commits into
mainfrom
feat/auto-metrics

Conversation

@mujacica

@mujacica mujacica commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Added experimental auto game-metrics. When enabled, the SDK periodically collects common performance metrics and sends them to Sentry via the metrics API.

Screenshot 2026-08-03 at 17 04 57

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor
Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- Add experimental auto game-metrics collection ([#2777](https://github.com/getsentry/sentry-unity/pull/2777))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 6112c98

@bitsandfoxes
bitsandfoxes marked this pull request as ready for review August 5, 2026 07:45
@bitsandfoxes
bitsandfoxes self-requested a review as a code owner August 5, 2026 07:45

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cb420b7. Configure here.

<AppHangTimeout>k__BackingField: 5000
<CaptureFailedRequests>k__BackingField: 1
<FailedRequestStatusCodes>k__BackingField: f401000057020000
<FailedRequestStatusCodes>k__BackingField: f401000057020000i

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Corrupted failed-request status codes

High Severity

FailedRequestStatusCodes gained a stray trailing i in its Unity hex payload (f401000057020000i). That corrupts the serialized List&lt;int&gt; and can break options loading when ranges are rebuilt pairwise during SDK init.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cb420b7. Configure here.

Comment thread samples/unity-of-bugs/Assets/Resources/Sentry/SentryOptions.asset Outdated
return null;
}

return getCurrentRtt.Invoke(transport, new object[] { ServerClientId }) as ulong?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The use of as ulong? to unbox a ulong returned from reflection will always result in null, causing the network ping metric to be silently lost.
Severity: MEDIUM

Suggested Fix

Replace the as ulong? operator with an explicit cast to correctly unbox the value. The line should be changed to return (ulong?)getCurrentRtt.Invoke(transport, new object[] { ServerClientId });.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/Sentry.Unity/Metrics/NetworkMetricsMonitor.cs#L133

Potential issue: In `NetworkMetricsMonitor.cs`, the code uses reflection to get the
current Round-Trip Time (RTT) via `getCurrentRtt.Invoke(...)`. This method returns a
boxed `ulong`. The code then attempts to unbox this value using the `as ulong?`
operator. According to C# semantics, the `as` operator will return `null` when
attempting to unbox a value type to its nullable counterpart, instead of performing the
unboxing conversion. As a result, the check `rtt.HasValue` on the following line will
always be false, and the ping metric will be silently dropped instead of being reported
to Sentry.

Did we get this right? 👍 / 👎 to inform future reviews.

@bitsandfoxes
bitsandfoxes merged commit c8f3683 into main Aug 5, 2026
21 of 22 checks passed
@bitsandfoxes
bitsandfoxes deleted the feat/auto-metrics branch August 5, 2026 07:59
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