Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate frame delay on a span level #3197

Merged
merged 11 commits into from
Feb 16, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Add new threshold parameters to monitor config ([#3181](https://github.com/getsentry/sentry-java/pull/3181))
- Report process init time as a span for app start performance ([#3159](https://github.com/getsentry/sentry-java/pull/3159))
- (perf-v2): Calculate frame delay on a span level ([#3197](https://github.com/getsentry/sentry-java/pull/3197))

### Fixes

Expand Down
2 changes: 1 addition & 1 deletion sentry-android-core/api/sentry-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public final class io/sentry/android/core/SentryPerformanceProvider {
}

public class io/sentry/android/core/SpanFrameMetricsCollector : io/sentry/IPerformanceContinuousCollector, io/sentry/android/core/internal/util/SentryFrameMetricsCollector$FrameMetricsCollectorListener {
public fun <init> (Lio/sentry/android/core/SentryAndroidOptions;)V
public fun <init> (Lio/sentry/android/core/SentryAndroidOptions;Lio/sentry/android/core/internal/util/SentryFrameMetricsCollector;)V
public fun clear ()V
public fun onFrameMetricCollected (JJJJZZF)V
public fun onSpanFinished (Lio/sentry/ISpan;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,12 @@ static void initializeIntegrationsAndProcessors(
new AndroidCpuCollector(options.getLogger(), buildInfoProvider));

if (options.isEnablePerformanceV2()) {
options.addPerformanceCollector(new SpanFrameMetricsCollector(options));
options.addPerformanceCollector(
new SpanFrameMetricsCollector(
options,
Objects.requireNonNull(
options.getFrameMetricsCollector(),
"options.getFrameMetricsCollector is required")));
}
}
options.setTransactionPerformanceCollector(new DefaultTransactionPerformanceCollector(options));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public SentryFrameMetrics(
final int frozenFrameCount,
final long frozenFrameDelayNanos,
final long totalDurationNanos) {

this.normalFrameCount = normalFrameCount;

this.slowFrameCount = slowFrameCount;
Expand All @@ -34,21 +35,21 @@ public SentryFrameMetrics(
this.totalDurationNanos = totalDurationNanos;
}

public void addSlowFrame(final long durationNanos, final long delayNanos) {
totalDurationNanos += durationNanos;
slowFrameDelayNanos += delayNanos;
slowFrameCount++;
}

public void addFrozenFrame(final long durationNanos, final long delayNanos) {
totalDurationNanos += durationNanos;
frozenFrameDelayNanos += delayNanos;
frozenFrameCount++;
}

public void addNormalFrame(final long durationNanos) {
public void addFrame(
final long durationNanos,
final long delayNanos,
final boolean isSlow,
final boolean isFrozen) {
totalDurationNanos += durationNanos;
normalFrameCount++;
if (isFrozen) {
frozenFrameDelayNanos += delayNanos;
frozenFrameCount += 1;
} else if (isSlow) {
slowFrameDelayNanos += delayNanos;
slowFrameCount += 1;
} else {
normalFrameCount += 1;
}
}

public int getNormalFrameCount() {
Expand Down
Loading
Loading