Skip to content

Commit 5b412ae

Browse files
committed
Merge branch 'main' into rz/feat/session-replay
2 parents e3623e5 + 2e90ac7 commit 5b412ae

File tree

46 files changed

+938
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+938
-206
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ jobs:
3535
run: make preMerge
3636

3737
- name: Upload coverage to Codecov
38-
uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # pin@v3
38+
uses: codecov/codecov-action@5ecb98a3c6b747ed38dc09f787459979aebb39be # pin@v4
3939
with:
4040
name: sentry-java
4141
fail_ci_if_error: false
42+
token: ${{ secrets.CODECOV_TOKEN }}
4243

4344
- name: Upload test results
4445
if: always()

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,39 @@
66

77
We released our second Alpha version of the SDK with support. To get access, it requires adding your Sentry org to our feature flag. Please let us know on the [waitlist](https://sentry.io/lp/mobile-replay-beta/) if you're interested
88

9+
### Fixes
10+
11+
- Move onFinishCallback before span or transaction is finished ([#3459](https://github.com/getsentry/sentry-java/pull/3459))
12+
- Add timestamp when a profile starts ([#3442](https://github.com/getsentry/sentry-java/pull/3442))
13+
- Move fragment auto span finish to onFragmentStarted ([#3424](https://github.com/getsentry/sentry-java/pull/3424))
14+
- Remove profiling timeout logic and disable profiling on API 21 ([#3478](https://github.com/getsentry/sentry-java/pull/3478))
15+
- Properly reset metric flush flag on metric emission ([#3493](https://github.com/getsentry/sentry-java/pull/3493))
16+
17+
## 7.10.0
18+
19+
### Features
20+
21+
- Publish Gradle module metadata ([#3422](https://github.com/getsentry/sentry-java/pull/3422))
22+
23+
### Fixes
24+
25+
- Fix faulty `span.frame_delay` calculation for early app start spans ([#3427](https://github.com/getsentry/sentry-java/pull/3427))
26+
- Fix crash when installing `ShutdownHookIntegration` and the VM is shutting down ([#3456](https://github.com/getsentry/sentry-java/pull/3456))
27+
28+
## 7.9.0
29+
930
### Features
1031

1132
- Add start_type to app context ([#3379](https://github.com/getsentry/sentry-java/pull/3379))
33+
- Add ttid/ttfd contribution flags ([#3386](https://github.com/getsentry/sentry-java/pull/3386))
1234

1335
### Fixes
1436

37+
- (Internal) Metrics code cleanup ([#3403](https://github.com/getsentry/sentry-java/pull/3403))
1538
- Fix Frame measurements in app start transactions ([#3382](https://github.com/getsentry/sentry-java/pull/3382))
1639
- Fix timing metric value different from span duration ([#3368](https://github.com/getsentry/sentry-java/pull/3368))
40+
- Do not always write startup crash marker ([#3409](https://github.com/getsentry/sentry-java/pull/3409))
41+
- This may have been causing the SDK init logic to block the main thread
1742

1843
## 7.8.0
1944

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Sentry
3+
Copyright (c) 2019-2024 Sentry
44
Copyright (c) 2015 Salomon BRYS for Android ANRWatchDog
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy

build.gradle.kts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,7 @@ subprojects {
161161
if (this@subprojects.name.contains("-compose")) {
162162
this.configureForMultiplatform(this@subprojects)
163163
} else {
164-
this.getByName("main").contents {
165-
// non android modules
166-
from("build${sep}libs")
167-
from("build${sep}publications${sep}maven")
168-
// android modules
169-
from("build${sep}outputs${sep}aar") {
170-
include("*-release*")
171-
}
172-
from("build${sep}publications${sep}release")
173-
}
164+
this.configureForJvm(this@subprojects)
174165
}
175166
// craft only uses zip archives
176167
this.forEach { dist ->

buildSrc/src/main/java/Publication.kt

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ private object Consts {
1010
// configure distZip tasks for multiplatform
1111
fun DistributionContainer.configureForMultiplatform(project: Project) {
1212
val sep = File.separator
13+
val version = project.properties["versionName"].toString()
1314

1415
this.maybeCreate("android").contents {
15-
from("build${sep}publications${sep}androidRelease")
16+
from("build${sep}publications${sep}androidRelease") {
17+
renameModule(project.name, "android", version = version)
18+
}
1619
from("build${sep}outputs${sep}aar") {
1720
include("*-release*")
1821
rename {
@@ -25,7 +28,9 @@ fun DistributionContainer.configureForMultiplatform(project: Project) {
2528
}
2629
}
2730
this.getByName("main").contents {
28-
from("build${sep}publications${sep}kotlinMultiplatform")
31+
from("build${sep}publications${sep}kotlinMultiplatform") {
32+
renameModule(project.name, version = version)
33+
}
2934
from("build${sep}kotlinToolingMetadata")
3035
from("build${sep}libs") {
3136
include("*compose-kotlin*")
@@ -39,7 +44,9 @@ fun DistributionContainer.configureForMultiplatform(project: Project) {
3944
}
4045
this.maybeCreate("desktop").contents {
4146
// kotlin multiplatform modules
42-
from("build${sep}publications${sep}desktop")
47+
from("build${sep}publications${sep}desktop") {
48+
renameModule(project.name, "desktop", version = version)
49+
}
4350
from("build${sep}libs") {
4451
include("*desktop*")
4552
withJavadoc(renameTo = "compose-desktop")
@@ -53,6 +60,26 @@ fun DistributionContainer.configureForMultiplatform(project: Project) {
5360
project.tasks.getByName("distZip").finalizedBy(*platformDists)
5461
}
5562

63+
fun DistributionContainer.configureForJvm(project: Project) {
64+
val sep = File.separator
65+
val version = project.properties["versionName"].toString()
66+
67+
this.getByName("main").contents {
68+
// non android modules
69+
from("build${sep}libs")
70+
from("build${sep}publications${sep}maven") {
71+
renameModule(project.name, version = version)
72+
}
73+
// android modules
74+
from("build${sep}outputs${sep}aar") {
75+
include("*-release*")
76+
}
77+
from("build${sep}publications${sep}release") {
78+
renameModule(project.name, version = version)
79+
}
80+
}
81+
}
82+
5683
private fun CopySpec.withJavadoc(renameTo: String = "compose") {
5784
include("*javadoc*")
5885
rename {
@@ -63,3 +90,13 @@ private fun CopySpec.withJavadoc(renameTo: String = "compose") {
6390
}
6491
}
6592
}
93+
94+
private fun CopySpec.renameModule(projectName: String, renameTo: String = "", version: String) {
95+
var target = ""
96+
if (renameTo.isNotEmpty()) {
97+
target = "-$renameTo"
98+
}
99+
rename {
100+
it.replace("module.json", "$projectName$target-$version.module")
101+
}
102+
}

sentry-android-core/api/sentry-android-core.api

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ public class io/sentry/android/core/AndroidProfiler$ProfileEndData {
8181
public class io/sentry/android/core/AndroidProfiler$ProfileStartData {
8282
public final field startCpuMillis J
8383
public final field startNanos J
84-
public fun <init> (JJ)V
84+
public final field startTimestamp Ljava/util/Date;
85+
public fun <init> (JJLjava/util/Date;)V
8586
}
8687

8788
public final class io/sentry/android/core/AnrIntegration : io/sentry/Integration, java/io/Closeable {
@@ -206,6 +207,7 @@ public abstract interface class io/sentry/android/core/IDebugImagesLoader {
206207
public final class io/sentry/android/core/InternalSentrySdk {
207208
public fun <init> ()V
208209
public static fun captureEnvelope ([B)Lio/sentry/protocol/SentryId;
210+
public static fun getAppStartMeasurement ()Ljava/util/Map;
209211
public static fun getCurrentScope ()Lio/sentry/IScope;
210212
public static fun serializeScope (Landroid/content/Context;Lio/sentry/android/core/SentryAndroidOptions;Lio/sentry/IScope;)Ljava/util/Map;
211213
}

sentry-android-core/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ dependencies {
7878
compileOnly(projects.sentryAndroidTimber)
7979
compileOnly(projects.sentryAndroidReplay)
8080
compileOnly(projects.sentryCompose)
81+
compileOnly(projects.sentryComposeHelper)
8182

8283
// lifecycle processor, session tracking
8384
implementation(Config.Libs.lifecycleProcess)

sentry-android-core/src/main/java/io/sentry/android/core/AndroidProfiler.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.os.Process;
77
import android.os.SystemClock;
88
import io.sentry.CpuCollectionData;
9+
import io.sentry.DateUtils;
910
import io.sentry.ILogger;
1011
import io.sentry.ISentryExecutorService;
1112
import io.sentry.MemoryCollectionData;
@@ -17,6 +18,7 @@
1718
import io.sentry.util.Objects;
1819
import java.io.File;
1920
import java.util.ArrayDeque;
21+
import java.util.Date;
2022
import java.util.HashMap;
2123
import java.util.List;
2224
import java.util.Map;
@@ -33,10 +35,13 @@ public class AndroidProfiler {
3335
public static class ProfileStartData {
3436
public final long startNanos;
3537
public final long startCpuMillis;
38+
public final @NotNull Date startTimestamp;
3639

37-
public ProfileStartData(final long startNanos, final long startCpuMillis) {
40+
public ProfileStartData(
41+
final long startNanos, final long startCpuMillis, final @NotNull Date startTimestamp) {
3842
this.startNanos = startNanos;
3943
this.startCpuMillis = startCpuMillis;
44+
this.startTimestamp = startTimestamp;
4045
}
4146
}
4247

@@ -79,7 +84,6 @@ public ProfileEndData(
7984
private @Nullable Future<?> scheduledFinish = null;
8085
private @Nullable File traceFile = null;
8186
private @Nullable String frameMetricsCollectorId;
82-
private volatile @Nullable ProfileEndData timedOutProfilingData = null;
8387
private final @NotNull SentryFrameMetricsCollector frameMetricsCollector;
8488
private final @NotNull ArrayDeque<ProfileMeasurementValue> screenFrameRateMeasurements =
8589
new ArrayDeque<>();
@@ -182,8 +186,7 @@ public void onFrameMetricCollected(
182186
// We stop profiling after a timeout to avoid huge profiles to be sent
183187
try {
184188
scheduledFinish =
185-
executorService.schedule(
186-
() -> timedOutProfilingData = endAndCollect(true, null), PROFILING_TIMEOUT_MILLIS);
189+
executorService.schedule(() -> endAndCollect(true, null), PROFILING_TIMEOUT_MILLIS);
187190
} catch (RejectedExecutionException e) {
188191
logger.log(
189192
SentryLevel.ERROR,
@@ -192,6 +195,7 @@ public void onFrameMetricCollected(
192195
}
193196

194197
profileStartNanos = SystemClock.elapsedRealtimeNanos();
198+
final @NotNull Date profileStartTimestamp = DateUtils.getCurrentDateTime();
195199
long profileStartCpuMillis = Process.getElapsedCpuTime();
196200

197201
// We don't make any check on the file existence or writeable state, because we don't want to
@@ -203,7 +207,7 @@ public void onFrameMetricCollected(
203207
// tests)
204208
Debug.startMethodTracingSampling(traceFile.getPath(), BUFFER_SIZE_BYTES, intervalUs);
205209
isRunning = true;
206-
return new ProfileStartData(profileStartNanos, profileStartCpuMillis);
210+
return new ProfileStartData(profileStartNanos, profileStartCpuMillis, profileStartTimestamp);
207211
} catch (Throwable e) {
208212
endAndCollect(false, null);
209213
logger.log(SentryLevel.ERROR, "Unable to start a profile: ", e);
@@ -216,10 +220,6 @@ public void onFrameMetricCollected(
216220
public synchronized @Nullable ProfileEndData endAndCollect(
217221
final boolean isTimeout,
218222
final @Nullable List<PerformanceCollectionData> performanceCollectionData) {
219-
// check if profiling timed out
220-
if (timedOutProfilingData != null) {
221-
return timedOutProfilingData;
222-
}
223223

224224
if (!isRunning) {
225225
logger.log(SentryLevel.WARNING, "Profiler not running");

sentry-android-core/src/main/java/io/sentry/android/core/AndroidTransactionProfiler.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import android.os.Build;
1010
import android.os.Process;
1111
import android.os.SystemClock;
12+
import io.sentry.DateUtils;
1213
import io.sentry.HubAdapter;
1314
import io.sentry.IHub;
1415
import io.sentry.ILogger;
@@ -24,6 +25,7 @@
2425
import io.sentry.android.core.internal.util.SentryFrameMetricsCollector;
2526
import io.sentry.util.Objects;
2627
import java.util.ArrayList;
28+
import java.util.Date;
2729
import java.util.List;
2830
import org.jetbrains.annotations.NotNull;
2931
import org.jetbrains.annotations.Nullable;
@@ -44,6 +46,7 @@ final class AndroidTransactionProfiler implements ITransactionProfiler {
4446
private @Nullable AndroidProfiler profiler = null;
4547
private long profileStartNanos;
4648
private long profileStartCpuMillis;
49+
private @NotNull Date profileStartTimestamp;
4750

4851
/**
4952
* @deprecated please use a constructor that doesn't takes a {@link IHub} instead, as it would be
@@ -95,6 +98,7 @@ public AndroidTransactionProfiler(
9598
this.profilingTracesHz = profilingTracesHz;
9699
this.executorService =
97100
Objects.requireNonNull(executorService, "The ISentryExecutorService is required.");
101+
this.profileStartTimestamp = DateUtils.getCurrentDateTime();
98102
}
99103

100104
private void init() {
@@ -133,8 +137,9 @@ private void init() {
133137

134138
@Override
135139
public synchronized void start() {
136-
// Debug.startMethodTracingSampling() is only available since Lollipop
137-
if (buildInfoProvider.getSdkInfoVersion() < Build.VERSION_CODES.LOLLIPOP) return;
140+
// Debug.startMethodTracingSampling() is only available since Lollipop, but Android Profiler
141+
// causes crashes on api 21 -> https://github.com/getsentry/sentry-java/issues/3392
142+
if (buildInfoProvider.getSdkInfoVersion() < Build.VERSION_CODES.LOLLIPOP_MR1) return;
138143

139144
// Let's initialize trace folder and profiling interval
140145
init();
@@ -164,6 +169,7 @@ private boolean onFirstStart() {
164169
}
165170
profileStartNanos = startData.startNanos;
166171
profileStartCpuMillis = startData.startCpuMillis;
172+
profileStartTimestamp = startData.startTimestamp;
167173
return true;
168174
}
169175

@@ -204,9 +210,9 @@ public synchronized void bindTransaction(final @NotNull ITransaction transaction
204210
return null;
205211
}
206212

207-
// onTransactionStart() is only available since Lollipop
213+
// onTransactionStart() is only available since Lollipop_MR1
208214
// and SystemClock.elapsedRealtimeNanos() since Jelly Bean
209-
if (buildInfoProvider.getSdkInfoVersion() < Build.VERSION_CODES.LOLLIPOP) return null;
215+
if (buildInfoProvider.getSdkInfoVersion() < Build.VERSION_CODES.LOLLIPOP_MR1) return null;
210216

211217
// Transaction finished, but it's not in the current profile
212218
if (currentProfilingTransactionData == null
@@ -274,6 +280,7 @@ public synchronized void bindTransaction(final @NotNull ITransaction transaction
274280
// done in the background when the trace file is read
275281
return new ProfilingTraceData(
276282
endData.traceFile,
283+
profileStartTimestamp,
277284
transactionList,
278285
transactionName,
279286
transactionId,

0 commit comments

Comments
 (0)