Skip to content

Commit 0c58628

Browse files
authored
Merge branch 'main' into lcian/feat/ktor-client
2 parents 7d8dcd1 + 0f37c1d commit 0c58628

Some content is hidden

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

42 files changed

+596
-324
lines changed

.craft.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ targets:
66
gradleCliPath: ./gradlew
77
mavenCliPath: scripts/mvnw
88
mavenSettingsPath: scripts/settings.xml
9-
mavenRepoId: ossrh
10-
mavenRepoUrl: https://oss.sonatype.org/service/local/staging/deploy/maven2/
9+
mavenRepoId: ossrh-staging-api
10+
mavenRepoUrl: https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/
1111
android:
1212
distDirRegex: /^(sentry-android-|.*-android).*$/
1313
fileReplaceeRegex: /\d+\.\d+\.\d+(-\w+(\.\d+)?)?(-SNAPSHOT)?/

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
3737

3838
- name: Initialize CodeQL
39-
uses: github/codeql-action/init@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # pin@v2
39+
uses: github/codeql-action/init@39edc492dbe16b1465b0cafca41432d857bdb31a # pin@v2
4040
with:
4141
languages: 'java'
4242

@@ -45,4 +45,4 @@ jobs:
4545
./gradlew buildForCodeQL --no-build-cache
4646
4747
- name: Perform CodeQL Analysis
48-
uses: github/codeql-action/analyze@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # pin@v2
48+
uses: github/codeql-action/analyze@39edc492dbe16b1465b0cafca41432d857bdb31a # pin@v2

CHANGELOG.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,58 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixes
6+
7+
- Optimize scope when maxBreadcrumb is 0 ([#4504](https://github.com/getsentry/sentry-java/pull/4504))
8+
- Fix javadoc on TransportResult ([#4528](https://github.com/getsentry/sentry-java/pull/4528))
9+
10+
### Internal
11+
12+
- Flattened PerformanceCollectionData ([#4505](https://github.com/getsentry/sentry-java/pull/4505))
13+
14+
## 8.16.0
15+
16+
### Features
17+
18+
- Send JUL logs to Sentry as logs ([#4518](https://github.com/getsentry/sentry-java/pull/4518))
19+
- You need to enable the logs feature, either in `sentry.properties`:
20+
```properties
21+
logs.enabled=true
22+
```
23+
- Or, if you manually initialize Sentry, you may also enable logs on `Sentry.init`:
24+
```java
25+
Sentry.init(options -> {
26+
...
27+
options.getLogs().setEnabled(true);
28+
});
29+
```
30+
- It is also possible to set the `minimumLevel` in `logging.properties`, meaning any log message >= the configured level will be sent to Sentry and show up under Logs:
31+
```properties
32+
io.sentry.jul.SentryHandler.minimumLevel=CONFIG
33+
```
34+
- Send Log4j2 logs to Sentry as logs ([#4517](https://github.com/getsentry/sentry-java/pull/4517))
35+
- You need to enable the logs feature either in `sentry.properties`:
36+
```properties
37+
logs.enabled=true
38+
```
39+
- If you manually initialize Sentry, you may also enable logs on `Sentry.init`:
40+
```java
41+
Sentry.init(options -> {
42+
...
43+
options.getLogs().setEnabled(true);
44+
});
45+
```
46+
- It is also possible to set the `minimumLevel` in `log4j2.xml`, meaning any log message >= the configured level will be sent to Sentry and show up under Logs:
47+
```xml
48+
<Sentry name="Sentry"
49+
dsn="your DSN"
50+
minimumBreadcrumbLevel="DEBUG"
51+
minimumEventLevel="WARN"
52+
minimumLevel="DEBUG"
53+
/>
54+
```
55+
356
## 8.15.1
457

558
### Fixes

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
1111
android.useAndroidX=true
1212

1313
# Release information
14-
versionName=8.15.1
14+
versionName=8.16.0
1515

1616
# Override the SDK name on native crashes on Android
1717
sentryAndroidSdkName=sentry.native.android

scripts/settings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
https://maven.apache.org/xsd/settings-1.0.0.xsd">
55
<servers>
66
<server>
7-
<id>ossrh</id>
7+
<id>ossrh-staging-api</id>
88
<username>${env.OSSRH_USERNAME}</username>
99
<password>${env.OSSRH_PASSWORD}</password>
1010
</server>

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
import android.os.SystemClock;
44
import android.system.Os;
55
import android.system.OsConstants;
6-
import io.sentry.CpuCollectionData;
76
import io.sentry.ILogger;
87
import io.sentry.IPerformanceSnapshotCollector;
98
import io.sentry.PerformanceCollectionData;
109
import io.sentry.SentryLevel;
11-
import io.sentry.SentryNanotimeDate;
1210
import io.sentry.util.FileUtils;
1311
import io.sentry.util.Objects;
1412
import java.io.File;
@@ -72,11 +70,8 @@ public void collect(final @NotNull PerformanceCollectionData performanceCollecti
7270
// number from 0 to 100, so we are going to multiply it by 100
7371
final double cpuUsagePercentage = cpuNanosDiff / (double) realTimeNanosDiff;
7472

75-
CpuCollectionData cpuData =
76-
new CpuCollectionData(
77-
(cpuUsagePercentage / (double) numCores) * 100.0, new SentryNanotimeDate());
78-
79-
performanceCollectionData.addCpuData(cpuData);
73+
performanceCollectionData.setCpuUsagePercentage(
74+
(cpuUsagePercentage / (double) numCores) * 100.0);
8075
}
8176

8277
/** Read the /proc/self/stat file and parses the result. */

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
import android.os.Debug;
44
import io.sentry.IPerformanceSnapshotCollector;
5-
import io.sentry.MemoryCollectionData;
65
import io.sentry.PerformanceCollectionData;
7-
import io.sentry.SentryNanotimeDate;
86
import org.jetbrains.annotations.ApiStatus;
97
import org.jetbrains.annotations.NotNull;
108

@@ -18,8 +16,7 @@ public void setup() {}
1816
public void collect(final @NotNull PerformanceCollectionData performanceCollectionData) {
1917
long usedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
2018
long usedNativeMemory = Debug.getNativeHeapSize() - Debug.getNativeHeapFreeSize();
21-
MemoryCollectionData memoryData =
22-
new MemoryCollectionData(usedMemory, usedNativeMemory, new SentryNanotimeDate());
23-
performanceCollectionData.addMemoryData(memoryData);
19+
performanceCollectionData.setUsedHeapMemory(usedMemory);
20+
performanceCollectionData.setUsedNativeMemory(usedNativeMemory);
2421
}
2522
}

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

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44
import android.os.Debug;
55
import android.os.Process;
66
import android.os.SystemClock;
7-
import io.sentry.CpuCollectionData;
87
import io.sentry.DateUtils;
98
import io.sentry.ILogger;
109
import io.sentry.ISentryExecutorService;
1110
import io.sentry.ISentryLifecycleToken;
12-
import io.sentry.MemoryCollectionData;
1311
import io.sentry.PerformanceCollectionData;
14-
import io.sentry.SentryDate;
1512
import io.sentry.SentryLevel;
1613
import io.sentry.SentryNanotimeDate;
1714
import io.sentry.SentryUUID;
@@ -156,7 +153,7 @@ public void onFrameMetricCollected(
156153
// profileStartNanos is calculated through SystemClock.elapsedRealtimeNanos(),
157154
// but frameEndNanos uses System.nanotime(), so we convert it to get the timestamp
158155
// relative to profileStartNanos
159-
final SentryDate timestamp = new SentryNanotimeDate();
156+
final long timestampNanos = new SentryNanotimeDate().nanoTimestamp();
160157
final long frameTimestampRelativeNanos =
161158
frameEndNanos
162159
- System.nanoTime()
@@ -171,17 +168,17 @@ public void onFrameMetricCollected(
171168
if (isFrozen) {
172169
frozenFrameRenderMeasurements.addLast(
173170
new ProfileMeasurementValue(
174-
frameTimestampRelativeNanos, durationNanos, timestamp));
171+
frameTimestampRelativeNanos, durationNanos, timestampNanos));
175172
} else if (isSlow) {
176173
slowFrameRenderMeasurements.addLast(
177174
new ProfileMeasurementValue(
178-
frameTimestampRelativeNanos, durationNanos, timestamp));
175+
frameTimestampRelativeNanos, durationNanos, timestampNanos));
179176
}
180177
if (refreshRate != lastRefreshRate) {
181178
lastRefreshRate = refreshRate;
182179
screenFrameRateMeasurements.addLast(
183180
new ProfileMeasurementValue(
184-
frameTimestampRelativeNanos, refreshRate, timestamp));
181+
frameTimestampRelativeNanos, refreshRate, timestampNanos));
185182
}
186183
}
187184
});
@@ -318,32 +315,28 @@ private void putPerformanceCollectionDataInMeasurements(
318315
new ArrayDeque<>(performanceCollectionData.size());
319316

320317
synchronized (performanceCollectionData) {
321-
for (PerformanceCollectionData performanceData : performanceCollectionData) {
322-
CpuCollectionData cpuData = performanceData.getCpuData();
323-
MemoryCollectionData memoryData = performanceData.getMemoryData();
324-
if (cpuData != null) {
318+
for (final @NotNull PerformanceCollectionData data : performanceCollectionData) {
319+
final long nanoTimestamp = data.getNanoTimestamp();
320+
final long relativeStartNs = nanoTimestamp + timestampDiff;
321+
final @Nullable Double cpuUsagePercentage = data.getCpuUsagePercentage();
322+
final @Nullable Long usedHeapMemory = data.getUsedHeapMemory();
323+
final @Nullable Long usedNativeMemory = data.getUsedNativeMemory();
324+
325+
if (cpuUsagePercentage != null) {
325326
cpuUsageMeasurements.add(
326-
new ProfileMeasurementValue(
327-
cpuData.getTimestamp().nanoTimestamp() + timestampDiff,
328-
cpuData.getCpuUsagePercentage(),
329-
cpuData.getTimestamp()));
327+
new ProfileMeasurementValue(relativeStartNs, cpuUsagePercentage, nanoTimestamp));
330328
}
331-
if (memoryData != null && memoryData.getUsedHeapMemory() > -1) {
329+
if (usedHeapMemory != null) {
332330
memoryUsageMeasurements.add(
333-
new ProfileMeasurementValue(
334-
memoryData.getTimestamp().nanoTimestamp() + timestampDiff,
335-
memoryData.getUsedHeapMemory(),
336-
memoryData.getTimestamp()));
331+
new ProfileMeasurementValue(relativeStartNs, usedHeapMemory, nanoTimestamp));
337332
}
338-
if (memoryData != null && memoryData.getUsedNativeMemory() > -1) {
333+
if (usedNativeMemory != null) {
339334
nativeMemoryUsageMeasurements.add(
340-
new ProfileMeasurementValue(
341-
memoryData.getTimestamp().nanoTimestamp() + timestampDiff,
342-
memoryData.getUsedNativeMemory(),
343-
memoryData.getTimestamp()));
335+
new ProfileMeasurementValue(relativeStartNs, usedNativeMemory, nanoTimestamp));
344336
}
345337
}
346338
}
339+
347340
if (!cpuUsageMeasurements.isEmpty()) {
348341
measurementsMap.put(
349342
ProfileMeasurement.ID_CPU_USAGE,

sentry-android-core/src/test/java/io/sentry/android/core/AndroidContinuousProfilerTest.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@ import android.os.Build
55
import androidx.test.core.app.ApplicationProvider
66
import androidx.test.ext.junit.runners.AndroidJUnit4
77
import io.sentry.CompositePerformanceCollector
8-
import io.sentry.CpuCollectionData
98
import io.sentry.DataCategory
109
import io.sentry.IConnectionStatusProvider
1110
import io.sentry.ILogger
1211
import io.sentry.IScopes
13-
import io.sentry.MemoryCollectionData
1412
import io.sentry.PerformanceCollectionData
1513
import io.sentry.ProfileLifecycle
1614
import io.sentry.Sentry
1715
import io.sentry.SentryLevel
18-
import io.sentry.SentryNanotimeDate
1916
import io.sentry.SentryTracer
2017
import io.sentry.TracesSampler
2118
import io.sentry.TransactionContext
@@ -427,10 +424,11 @@ class AndroidContinuousProfilerTest {
427424
@Test
428425
fun `profiler sends chunk with measurements`() {
429426
val performanceCollector = mock<CompositePerformanceCollector>()
430-
val collectionData = PerformanceCollectionData()
427+
val collectionData = PerformanceCollectionData(10)
431428

432-
collectionData.addMemoryData(MemoryCollectionData(2, 3, SentryNanotimeDate()))
433-
collectionData.addCpuData(CpuCollectionData(3.0, SentryNanotimeDate()))
429+
collectionData.usedHeapMemory = 2
430+
collectionData.usedNativeMemory = 3
431+
collectionData.cpuUsagePercentage = 3.0
434432
whenever(performanceCollector.stop(any<String>())).thenReturn(listOf(collectionData))
435433

436434
fixture.options.compositePerformanceCollector = performanceCollector

sentry-android-core/src/test/java/io/sentry/android/core/AndroidCpuCollectorTest.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,19 @@ class AndroidCpuCollectorTest {
2828

2929
@Test
3030
fun `collect works only after setup`() {
31-
val data = PerformanceCollectionData()
31+
val data = PerformanceCollectionData(10)
3232
fixture.getSut().collect(data)
33-
assertNull(data.cpuData)
33+
assertNull(data.cpuUsagePercentage)
3434
}
3535

3636
@Test
3737
fun `when collect cpu is collected`() {
38-
val data = PerformanceCollectionData()
38+
val data = PerformanceCollectionData(10)
3939
val collector = fixture.getSut()
4040
collector.setup()
4141
collector.collect(data)
42-
val cpuData = data.cpuData
42+
val cpuData = data.cpuUsagePercentage
4343
assertNotNull(cpuData)
44-
assertNotEquals(0.0, cpuData.cpuUsagePercentage)
45-
assertNotEquals(0, cpuData.timestamp.nanoTimestamp())
44+
assertNotEquals(0.0, cpuData)
4645
}
4746
}

0 commit comments

Comments
 (0)