Skip to content

Commit

Permalink
Add app start profiling and perfV2 (#133)
Browse files Browse the repository at this point in the history
* added custom ContentProvider to increment app start duration
enabled perfV2 and app start profiling
  • Loading branch information
stefanosiano authored Apr 8, 2024
1 parent ac33eb0 commit 49da0f9
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 4 deletions.
Binary file modified app-debug.apk
Binary file not shown.
Binary file modified app-release.apk
Binary file not shown.
7 changes: 3 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import java.sql.Wrapper
import io.sentry.android.gradle.instrumentation.logcat.LogcatLevel

buildscript {
Expand All @@ -12,7 +11,7 @@ buildscript {
}

plugins {
id "io.sentry.android.gradle" version "3.14.0"
id "io.sentry.android.gradle" version "4.4.0"
}

apply plugin: 'com.android.application'
Expand Down Expand Up @@ -43,8 +42,8 @@ android {
applicationId "com.example.vu.android"
minSdkVersion 21
targetSdkVersion 29
versionCode 43
versionName "2.10.4"
versionCode 44
versionName "2.10.5"

externalNativeBuild {
cmake {
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@
android:name="io.sentry.traces.time-to-full-display.enable"
android:value="true" />

<provider
android:exported="false"
android:authorities="${applicationId}.thirdpartycontentprovider"
android:name=".ThirdPartyContentProvider" />


</application>

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/example/vu/android/MyApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public void onCreate() {
);

options.setAttachThreads(true);
options.setEnableAppStartProfiling(true);
options.setEnablePerformanceV2(true);
options.setBeforeSend((event, hint) -> {

//Remove PII
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.example.vu.android;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class ThirdPartyContentProvider extends ContentProvider {

@Override
public boolean onCreate() {
setup();
return true;
}

private void setup() {
// Even versions will wait 1 second, to make it more obvious the difference between releases
if (BuildConfig.VERSION_CODE % 2 == 0) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
process(38);
}

private int process(int n) {
if (n <= 0) {
return 0;
}
if (n == 1 || n == 2) {
return 1;
}
return process(n-1) + process(n-2);
}

@Nullable
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
return null;
}

@Nullable
@Override
public String getType(@NonNull Uri uri) {
return null;
}

@Nullable
@Override
public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
return null;
}

@Override
public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
return 0;
}

@Override
public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
return 0;
}
}
Binary file modified release/app-release.apk
Binary file not shown.

0 comments on commit 49da0f9

Please sign in to comment.