diff --git a/CHANGELOG.md b/CHANGELOG.md index c9ee298ca8..1d96e5c82d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Fixes +- Updated ProfileMeasurementValue types ([#2412](https://github.com/getsentry/sentry-java/pull/2412)) - Clear window reference only on activity stop in profileMeasurements collector ([#2407](https://github.com/getsentry/sentry-java/pull/2407)) - No longer disable OpenTelemetry exporters in default Java Agent config ([#2408](https://github.com/getsentry/sentry-java/pull/2408)) - Fix `ClassNotFoundException` for `io.sentry.spring.SentrySpringServletContainerInitializer` in `sentry-spring-jakarta` ([#2411](https://github.com/getsentry/sentry-java/issues/2411)) diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/AndroidTransactionProfiler.java b/sentry-android-core/src/main/java/io/sentry/android/core/AndroidTransactionProfiler.java index 42897816f1..065c541db9 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/AndroidTransactionProfiler.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/AndroidTransactionProfiler.java @@ -198,6 +198,12 @@ public void onFrameMetricCollected( @NotNull FrameMetrics frameMetrics, float refreshRate) { long frameTimestampRelativeNanos = SystemClock.elapsedRealtimeNanos() - transactionStartNanos; + + // We don't allow negative relative timestamps. + // So we add a check, even if this should never happen. + if (frameTimestampRelativeNanos < 0) { + return; + } long durationNanos = frameMetrics.getMetric(FrameMetrics.TOTAL_DURATION); // Most frames take just a few nanoseconds longer than the optimal calculated // duration. diff --git a/sentry/src/main/java/io/sentry/profilemeasurements/ProfileMeasurementValue.java b/sentry/src/main/java/io/sentry/profilemeasurements/ProfileMeasurementValue.java index 22d48b4a38..79f7a4306a 100644 --- a/sentry/src/main/java/io/sentry/profilemeasurements/ProfileMeasurementValue.java +++ b/sentry/src/main/java/io/sentry/profilemeasurements/ProfileMeasurementValue.java @@ -19,16 +19,16 @@ public final class ProfileMeasurementValue implements JsonUnknown, JsonSerializable { private @Nullable Map unknown; - private @NotNull Long relativeStartNs; // timestamp in nanoseconds this frame was started - private @NotNull String value; // frame duration in nanoseconds + private @NotNull String relativeStartNs; // timestamp in nanoseconds this frame was started + private double value; // frame duration in nanoseconds public ProfileMeasurementValue() { this(0L, 0); } public ProfileMeasurementValue(final @NotNull Long relativeStartNs, final @NotNull Number value) { - this.relativeStartNs = relativeStartNs; - this.value = value.toString(); + this.relativeStartNs = relativeStartNs.toString(); + this.value = value.doubleValue(); } @Override @@ -38,7 +38,7 @@ public boolean equals(Object o) { ProfileMeasurementValue that = (ProfileMeasurementValue) o; return Objects.equals(unknown, that.unknown) && relativeStartNs.equals(that.relativeStartNs) - && value.equals(that.value); + && value == that.value; } @Override @@ -93,13 +93,13 @@ public static final class Deserializer implements JsonDeserializer