Skip to content

Commit

Permalink
Merge branch '8.x.x' into feat/potel-21-drop-internal-sentry-spans
Browse files Browse the repository at this point in the history
  • Loading branch information
adinauer authored Jun 24, 2024
2 parents 0c7b917 + d90e0f9 commit 0c0c76c
Show file tree
Hide file tree
Showing 139 changed files with 2,385 additions and 1,374 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ jobs:
run: make preMerge

- name: Upload coverage to Codecov
uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # pin@v3
uses: codecov/codecov-action@5ecb98a3c6b747ed38dc09f787459979aebb39be # pin@v4
with:
name: sentry-java
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload test results
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
native:
uses: getsentry/github-workflows/.github/workflows/updater.yml@v2
with:
path: sentry-android-ndk/sentry-native
path: scripts/update-sentry-native-ndk.sh
name: Native SDK
secrets:
# If a custom token is used instead, a CI would be triggered on a created PR.
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "sentry-android-ndk/sentry-native"]
path = sentry-android-ndk/sentry-native
url = https://github.com/getsentry/sentry-native
144 changes: 144 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,153 @@

## Unreleased

### Behavioural Changes

- (Android) The JNI layer for sentry-native has now been moved from sentry-java to sentry-native ([#3189](https://github.com/getsentry/sentry-java/pull/3189))
- This now includes prefab support for sentry-native, allowing you to link and access the sentry-native API within your native app code
- Checkout the `sentry-samples/sentry-samples-android` example on how to configure CMake and consume `sentry.h`

### Features

- Our `sentry-opentelemetry-agent` has been completely reworked and now plays nicely with the rest of the Java SDK
- NOTE: Not all features have been implemented yet for the OpenTelemetry agent.
- You can add `sentry-opentelemetry-agent` to your setup by downloading the latest release and using it when starting up your application
- `SENTRY_PROPERTIES_FILE=sentry.properties java -javaagent:sentry-opentelemetry-agent-x.x.x.jar -jar your-application.jar`
- Please use `sentry.properties` or environment variables to configure the SDK as the agent is now in charge of initializing the SDK and options coming from things like logging integrations or our Spring Boot integration will not take effect.
- You may find the [docs page](https://docs.sentry.io/platforms/java/tracing/instrumentation/opentelemetry/#using-sentry-opentelemetry-agent-with-auto-initialization) useful. While we haven't updated it yet to reflect the changes described here, the section about using the agent with auto init should still be vaild.
- What's new about the Agent
- When the OpenTelemetry Agent is used, Sentry API creates OpenTelemetry spans under the hood, handing back a wrapper object which bridges the gap between traditional Sentry API and OpenTelemetry. We might be replacing some of the Sentry performance API in the future.
- This is achieved by configuring the SDK to use `OtelSpanFactory` instead of `DefaultSpanFactory` which is done automatically by the auto init of the Java Agent.
- OpenTelemetry spans are now only turned into Sentry spans when they are finished so they can be sent to the Sentry server.
- Now registers an OpenTelemetry `Sampler` which uses Sentry sampling configuration
- Other Performance integrations automatically stop creating spans to avoid duplicate spans
- The Sentry SDK now makes use of OpenTelemetry `Context` for storing Sentry `Scopes` (which is similar to what used to be called `Hub`) and thus relies on OpenTelemetry for `Context` propagation.
- Classes used for the previous version of our OpenTelemetry support have been deprecated but can still be used manually. We're not planning to keep the old agent around in favor of less complexity in the SDK.
- Add `ignoredSpanOrigins` option for ignoring spans coming from certain integrations
- We pre-configure this to ignore Performance instrumentation for Spring and other integrations when using our OpenTelemetry Agent to avoid duplicate spans
- Add data fetching environment hint to breadcrumb for GraphQL (#3413) ([#3431](https://github.com/getsentry/sentry-java/pull/3431))

### Fixes

- `TracesSampler` is now only created once in `SentryOptions` instead of creating a new one for every `Hub` (which is now `Scopes`). This means we're now creating fewwer `SecureRandom` instances.
- Move onFinishCallback before span or transaction is finished ([#3459](https://github.com/getsentry/sentry-java/pull/3459))
- Add timestamp when a profile starts ([#3442](https://github.com/getsentry/sentry-java/pull/3442))
- Move fragment auto span finish to onFragmentStarted ([#3424](https://github.com/getsentry/sentry-java/pull/3424))
- Remove profiling timeout logic and disable profiling on API 21 ([#3478](https://github.com/getsentry/sentry-java/pull/3478))
- Properly reset metric flush flag on metric emission ([#3493](https://github.com/getsentry/sentry-java/pull/3493))


### Dependencies

- Bump Native SDK from v0.7.0 to v0.7.5 ([#3441](https://github.com/getsentry/sentry-java/pull/3189))
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#075)
- [diff](https://github.com/getsentry/sentry-native/compare/0.7.0...0.7.5)

## 8.0.0-alpha.1

Version 8 of the Sentry Android/Java SDK brings a variety of features and fixes. The most notable changes are:

- New `Scope` types have been introduced, see "Behavioural Changes" for more details.
- Lifecycle tokens have been introduced to manage `Scope` lifecycle, see "Behavioural Changes" for more details.
- `Hub` has been replaced by `Scopes`

### Behavioural Changes

- We're introducing some new `Scope` types in the SDK, allowing for better control over what data is attached where. Previously there was a stack of scopes that was pushed and popped. Instead we now fork scopes for a given lifecycle and then restore the previous scopes. Since `Hub` is gone, it is also never cloned anymore. Separation of data now happens through the different scope types while making it easier to manipulate exactly what you need without having to attach data at the right time to have it apply where wanted.
- Global scope is attached to all events created by the SDK. It can also be modified before `Sentry.init` has been called. It can be manipulated using `Sentry.configureScope(ScopeType.GLOBAL, (scope) -> { ... })`.
- Isolation scope can be used e.g. to attach data to all events that come up while handling an incoming request. It can also be used for other isolation purposes. It can be manipulated using `Sentry.configureScope(ScopeType.ISOLATION, (scope) -> { ... })`. The SDK automatically forks isolation scope in certain cases like incoming requests, CRON jobs, Spring `@Async` and more.
- Current scope is forked often and data added to it is only added to events that are created while this scope is active. Data is also passed on to newly forked child scopes but not to parents.
- `Sentry.popScope` has been deprecated, please call `.close()` on the token returned by `Sentry.pushScope` instead or use it in a way described in more detail in "Migration Guide".
- We have chosen a default scope that is used for `Sentry.configureScope()` as well as API like `Sentry.setTag()`
- For Android the type defaults to `CURRENT` scope
- For Backend and other JVM applicatons it defaults to `ISOLATION` scope
- Event processors on `Scope` can now be ordered by overriding the `getOrder` method on implementations of `EventProcessor`. NOTE: This order only applies to event processors on `Scope` but not `SentryOptions` at the moment. Feel free to request this if you need it.
- `Hub` is deprecated in favor of `Scopes`, alongside some `Hub` relevant APIs. More details can be found in the "Migration Guide" section.

### Breaking Changes

- `Contexts` no longer extends `ConcurrentHashMap`, instead we offer a selected set of methods.

### Migration Guide / Deprecations

- `Hub` has been deprecated, we're replacing the following:
- `IHub` has been replaced by `IScopes`, however you should be able to simply pass `IHub` instances to code expecting `IScopes`, allowing for an easier migration.
- `HubAdapter.getInstance()` has been replaced by `ScopesAdapter.getInstance()`
- The `.clone()` method on `IHub`/`IScopes` has been deprecated, please use `.pushScope()` or `.pushIsolationScope()` instead
- Some internal methods like `.getCurrentHub()` and `.setCurrentHub()` have also been replaced.
- `Sentry.popScope` has been replaced by calling `.close()` on the token returned by `Sentry.pushScope()` and `Sentry.pushIsolationScope()`. The token can also be used in a `try` block like this:

```
try (final @NotNull ISentryLifecycleToken ignored = Sentry.pushScope()) {
// this block has its separate current scope
}
```

as well as:


```
try (final @NotNull ISentryLifecycleToken ignored = Sentry.pushIsolationScope()) {
// this block has its separate isolation scope
}
```

You may also use `LifecycleHelper.close(token)`, e.g. in case you need to pass the token around for closing later.

### Features

- Report exceptions returned by Throwable.getSuppressed() to Sentry as exception groups ([#3396] https://github.com/getsentry/sentry-java/pull/3396)

## 7.10.0

### Features

- Publish Gradle module metadata ([#3422](https://github.com/getsentry/sentry-java/pull/3422))

### Fixes

- Fix faulty `span.frame_delay` calculation for early app start spans ([#3427](https://github.com/getsentry/sentry-java/pull/3427))
- Fix crash when installing `ShutdownHookIntegration` and the VM is shutting down ([#3456](https://github.com/getsentry/sentry-java/pull/3456))

## 7.9.0

### Features

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

### Fixes

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

## 7.8.0

### Features

- Add description to OkHttp spans ([#3320](https://github.com/getsentry/sentry-java/pull/3320))
- Enable backpressure management by default ([#3284](https://github.com/getsentry/sentry-java/pull/3284))

### Fixes

- Add rate limit to Metrics ([#3334](https://github.com/getsentry/sentry-java/pull/3334))
- Fix java.lang.ClassNotFoundException: org.springframework.web.servlet.HandlerMapping in Spring Boot Servlet mode without WebMVC ([#3336](https://github.com/getsentry/sentry-java/pull/3336))
- Fix normalization of metrics keys, tags and values ([#3332](https://github.com/getsentry/sentry-java/pull/3332))

## 7.7.0

### Features

- Add support for Spring Rest Client ([#3199](https://github.com/getsentry/sentry-java/pull/3199))
- Extend Proxy options with proxy type ([#3326](https://github.com/getsentry/sentry-java/pull/3326))

### Fixes

- Fixed default deadline timeout to 30s instead of 300s ([#3322](https://github.com/getsentry/sentry-java/pull/3322))
- Fixed `Fix java.lang.ClassNotFoundException: org.springframework.web.servlet.HandlerExceptionResolver` in Spring Boot Servlet mode without WebMVC ([#3333](https://github.com/getsentry/sentry-java/pull/3333))

## 7.6.0

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Sentry
Copyright (c) 2019-2024 Sentry
Copyright (c) 2015 Salomon BRYS for Android ANRWatchDog

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
16 changes: 2 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ buildscript {
classpath(Config.QualityPlugins.errorpronePlugin)
classpath(Config.QualityPlugins.gradleVersionsPlugin)

// add classpath of androidNativeBundle
// com.ydq.android.gradle.build.tool:nativeBundle:{version}}
classpath(Config.NativePlugins.nativeBundlePlugin)

// add classpath of sentry android gradle plugin
// classpath("io.sentry:sentry-android-gradle-plugin:{version}")

Expand Down Expand Up @@ -78,6 +74,7 @@ allprojects {
repositories {
google()
mavenCentral()
mavenLocal()
}
group = Config.Sentry.group
version = properties[Config.Sentry.versionNameProp].toString()
Expand Down Expand Up @@ -160,16 +157,7 @@ subprojects {
if (this@subprojects.name.contains("-compose")) {
this.configureForMultiplatform(this@subprojects)
} else {
this.getByName("main").contents {
// non android modules
from("build${sep}libs")
from("build${sep}publications${sep}maven")
// android modules
from("build${sep}outputs${sep}aar") {
include("*-release*")
}
from("build${sep}publications${sep}release")
}
this.configureForJvm(this@subprojects)
}
// craft only uses zip archives
this.forEach { dist ->
Expand Down
5 changes: 0 additions & 5 deletions buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,4 @@ object Config {
val errorprone = "com.google.errorprone:error_prone_core:2.11.0"
val errorProneNullAway = "com.uber.nullaway:nullaway:0.9.5"
}

object NativePlugins {
val nativeBundlePlugin = "io.github.howardpang:androidNativeBundle:1.1.1"
val nativeBundleExport = "com.ydq.android.gradle.native-aar.export"
}
}
43 changes: 40 additions & 3 deletions buildSrc/src/main/java/Publication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ private object Consts {
// configure distZip tasks for multiplatform
fun DistributionContainer.configureForMultiplatform(project: Project) {
val sep = File.separator
val version = project.properties["versionName"].toString()

this.maybeCreate("android").contents {
from("build${sep}publications${sep}androidRelease")
from("build${sep}publications${sep}androidRelease") {
renameModule(project.name, "android", version = version)
}
from("build${sep}outputs${sep}aar") {
include("*-release*")
rename {
Expand All @@ -25,7 +28,9 @@ fun DistributionContainer.configureForMultiplatform(project: Project) {
}
}
this.getByName("main").contents {
from("build${sep}publications${sep}kotlinMultiplatform")
from("build${sep}publications${sep}kotlinMultiplatform") {
renameModule(project.name, version = version)
}
from("build${sep}kotlinToolingMetadata")
from("build${sep}libs") {
include("*compose-kotlin*")
Expand All @@ -39,7 +44,9 @@ fun DistributionContainer.configureForMultiplatform(project: Project) {
}
this.maybeCreate("desktop").contents {
// kotlin multiplatform modules
from("build${sep}publications${sep}desktop")
from("build${sep}publications${sep}desktop") {
renameModule(project.name, "desktop", version = version)
}
from("build${sep}libs") {
include("*desktop*")
withJavadoc(renameTo = "compose-desktop")
Expand All @@ -53,6 +60,26 @@ fun DistributionContainer.configureForMultiplatform(project: Project) {
project.tasks.getByName("distZip").finalizedBy(*platformDists)
}

fun DistributionContainer.configureForJvm(project: Project) {
val sep = File.separator
val version = project.properties["versionName"].toString()

this.getByName("main").contents {
// non android modules
from("build${sep}libs")
from("build${sep}publications${sep}maven") {
renameModule(project.name, version = version)
}
// android modules
from("build${sep}outputs${sep}aar") {
include("*-release*")
}
from("build${sep}publications${sep}release") {
renameModule(project.name, version = version)
}
}
}

private fun CopySpec.withJavadoc(renameTo: String = "compose") {
include("*javadoc*")
rename {
Expand All @@ -63,3 +90,13 @@ private fun CopySpec.withJavadoc(renameTo: String = "compose") {
}
}
}

private fun CopySpec.renameModule(projectName: String, renameTo: String = "", version: String) {
var target = ""
if (renameTo.isNotEmpty()) {
target = "-$renameTo"
}
rename {
it.replace("module.json", "$projectName$target-$version.module")
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android.useAndroidX=true
android.defaults.buildfeatures.buildconfig=true

# Release information
versionName=7.6.0
versionName=8.0.0-alpha.1

# Override the SDK name on native crashes on Android
sentryAndroidSdkName=sentry.native.android
Expand Down
35 changes: 35 additions & 0 deletions scripts/update-sentry-native-ndk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -euo pipefail

cd $(dirname "$0")/../
GRADLE_NDK_FILEPATH=sentry-android-ndk/build.gradle.kts
GRADLE_SAMPLE_FILEPATH=sentry-samples/sentry-samples-android/build.gradle.kts

case $1 in
get-version)
version=$(perl -ne 'print "$1\n" if ( m/io\.sentry:sentry-native-ndk:([0-9.]+)+/ )' $GRADLE_NDK_FILEPATH)

echo "v$version"
;;
get-repo)
echo "https://github.com/getsentry/sentry-native.git"
;;
set-version)
version=$2

# Remove leading "v"
if [[ "$version" == v* ]]; then
version="${version:1}"
fi

echo "Setting sentry-native-ndk version to '$version'"

PATTERN="io\.sentry:sentry-native-ndk:([0-9.]+)+"
perl -pi -e "s/$PATTERN/io.sentry:sentry-native-ndk:$version/g" $GRADLE_NDK_FILEPATH
perl -pi -e "s/$PATTERN/io.sentry:sentry-native-ndk:$version/g" $GRADLE_SAMPLE_FILEPATH
;;
*)
echo "Unknown argument $1"
exit 1
;;
esac
4 changes: 3 additions & 1 deletion sentry-android-core/api/sentry-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public class io/sentry/android/core/AndroidProfiler$ProfileEndData {
public class io/sentry/android/core/AndroidProfiler$ProfileStartData {
public final field startCpuMillis J
public final field startNanos J
public fun <init> (JJ)V
public final field startTimestamp Ljava/util/Date;
public fun <init> (JJLjava/util/Date;)V
}

public final class io/sentry/android/core/AnrIntegration : io/sentry/Integration, java/io/Closeable {
Expand Down Expand Up @@ -205,6 +206,7 @@ public abstract interface class io/sentry/android/core/IDebugImagesLoader {
public final class io/sentry/android/core/InternalSentrySdk {
public fun <init> ()V
public static fun captureEnvelope ([B)Lio/sentry/protocol/SentryId;
public static fun getAppStartMeasurement ()Ljava/util/Map;
public static fun getCurrentScope ()Lio/sentry/IScope;
public static fun serializeScope (Landroid/content/Context;Lio/sentry/android/core/SentryAndroidOptions;Lio/sentry/IScope;)Ljava/util/Map;
}
Expand Down
1 change: 1 addition & 0 deletions sentry-android-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ dependencies {
compileOnly(projects.sentryAndroidFragment)
compileOnly(projects.sentryAndroidTimber)
compileOnly(projects.sentryCompose)
compileOnly(projects.sentryComposeHelper)

// lifecycle processor, session tracking
implementation(Config.Libs.lifecycleProcess)
Expand Down
Loading

0 comments on commit 0c0c76c

Please sign in to comment.