feat: metrics by jpnurmi · Pull Request #1498 · getsentry/sentry-native
and others added 3 commits
January 29, 2026 16:01
jpnurmi
changed the title
feat: metrics
WIP: feat: metrics
Per the Sentry metrics specification, counter metrics should use 64-bit signed integers. This is consistent with sentry_value_new_int64 / sentry_value_as_int64 in sentry.h. Also refactored internal record_metric to pass sentry_value_t instead of double, allowing proper type preservation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The value parameter was not being decremented when metrics were disabled, causing a memory leak. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Per the developer docs, units are only used for distribution and gauge metrics, not counters. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Split blocking shutdown and force_flush operations into begin (non-blocking trigger) and wait (blocking completion) phases. This allows logs and metrics operations to run in parallel in sentry_flush() and sentry_close(). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add metrics integration tests to match the existing logs test coverage: - test_metrics_threaded: concurrent metrics from 50 threads - test_metrics_global_and_local_attributes_merge: global + local attributes - test_metrics_discarded_on_crash_no_backend: metrics discarded without backend - test_metrics_on_crash: parameterized test for inproc/breakpad backends Also refactor thread creation in example.c into a shared run_threads() helper function used by both logs-threads and metrics-threads commands. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Allow reusing attribute objects across multiple log calls, as documented. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
jpnurmi
marked this pull request as ready for review
jpnurmi
changed the title
WIP: feat: metrics
feat: metrics
The split of force_flush into _begin() + _wait() introduced a race where _begin() wakes the batcher thread, but _wait() could return early if the batcher thread wins the race to acquire the flushing lock. This could cause sentry_flush() to return before data was actually sent. Fix by making sentry__batcher_flush return bool indicating success, and loop in _wait() until a flush actually completes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
jpnurmi
deleted the
jpnurmi/feat/metrics
branch
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