Repository navigation
Conversation
The metrics API always stamps a metric with the current time, so SDK integrations cannot report a metric for a moment in the past. MetricKit metric payloads describe a reporting interval of up to a day before they are delivered. Add internal count, distribution and gauge overloads that take a timestamp. They are not part of the public SentryMetricsApiProtocol. The SDK sends the timestamp as is and leaves the accepted age to Relay, which rejects trace metrics older than the retention period. Fixes #9268
Size Analysis1 component analyzed iOS Builds
|
📲 Install BuildsiOS
|
This branch has not been deployed
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.
Let SDK integrations record a metric for a moment in the past. The metrics API always stamped metrics with the current time, but MetricKit metric payloads (#9269) describe a reporting interval of up to a day before they are delivered.
Internal overloads
SentryMetricsApi+Internal.swiftaddscount,distributionandgaugeoverloads that take atimestamp: Date. They live on the internalSentryMetricsApistruct, not on the publicSentryMetricsApiProtocolthatSentrySDK.metricsis typed as, so the public API and its snapshots are unchanged. Metrics recorded without a timestamp keep using the current date.Timestamp age
The SDK sends the timestamp as is. Relay rejects trace metrics older than the organization's trace metric retention and corrects timestamps for client clock drift (
relay-server/src/processing/utils/normalize.rs), so ingestion owns the limit and a day-old MetricKit payload is well within it.The trace ID is still taken from the scope when the metric is recorded. Whether past metrics should carry it is left to #9269.
Fixes #9268
#skip-changelog