Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into gh-1331
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejwalkowiak committed Sep 15, 2021
2 parents dca2176 + 28ed730 commit ed3d254
Show file tree
Hide file tree
Showing 39 changed files with 256 additions and 98 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
# TODO: windows-latest
os: [ubuntu-latest, macos-latest]
# Zulu Community distribution of OpenJDK
java: [ '8', '11' ]
java: [ '11' ]

steps:
- name: Git checkout
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:

- name: Archive packages
# We need artifacts from only one the builds
if: runner.os == 'Linux' && matrix.java == '8'
if: runner.os == 'Linux' && matrix.java == '11'
uses: actions/upload-artifact@v2
with:
name: ${{ github.sha }}
Expand All @@ -61,7 +61,7 @@ jobs:
- name: Upload coverage to Codecov
# We need coverage data from only one the builds
if: runner.os == 'Linux' && matrix.java == '8'
if: runner.os == 'Linux' && matrix.java == '11'
uses: codecov/codecov-action@v1
with:
name: sentry-java
4 changes: 2 additions & 2 deletions .github/workflows/check-formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
- name: set up JDK 1.8
- name: set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'
java-version: '11'

- name: Cache Gradle packages
uses: actions/cache@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/generate-javadocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
- name: set up JDK 1.8
- name: set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'
java-version: '11'

- name: Cache Gradle packages
uses: actions/cache@v2
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## Unreleased

* Feat: Add "data" to spans (#1717)
* Fix: Should not capture unfinished transaction (#1719)

## 5.2.0-beta.2

* Bump AGP to 7.0.2 (#1650)
* Fix: drop spans in BeforeSpanCallback. (#1713)

## 5.2.0-beta.1

* Feat: Add tracestate HTTP header support (#1683)
* Feat: Add option to filter which origins receive tracing headers (#1698)
* Feat: Include unfinished spans in transaction (#1699)
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,21 @@ Sentry Android Gradle Plugin repo [sits on another repo](https://github.com/gets

# Blog posts

[New Android SDK How-to](https://blog.sentry.io/2019/12/10/new-android-sdk-how-to).
[Mobile Vitals - Four Metrics Every Mobile Developer Should Care About](https://blog.sentry.io/2021/08/23/mobile-vitals-four-metrics-every-mobile-developer-should-care-about/).

[Adding Native support to our Android SDK](https://blog.sentry.io/2019/11/25/adding-native-support-to-our-android-sdk).
[Supporting Native Android Libraries Loaded From APKs](https://blog.sentry.io/2021/05/13/supporting-native-android-libraries-loaded-from-apks).

[How to use Sentry Attachments with Mobile Applications](https://blog.sentry.io/2021/02/03/how-to-use-sentry-attachments-with-mobile-applications).
[A Sanity Listicle for Mobile Developers](https://blog.sentry.io/2021/03/30/a-sanity-listicle-for-mobile-developers/).

[Performance Monitoring for Android Applications](https://blog.sentry.io/2021/03/18/performance-monitoring-for-android-applications).

[Close the Loop with User Feedback](https://blog.sentry.io/2021/02/16/close-the-loop-with-user-feedback).

[A Sanity Listicle for Mobile Developers](https://blog.sentry.io/2021/03/30/a-sanity-listicle-for-mobile-developers/).
[How to use Sentry Attachments with Mobile Applications](https://blog.sentry.io/2021/02/03/how-to-use-sentry-attachments-with-mobile-applications).

[Supporting Native Android Libraries Loaded From APKs](https://blog.sentry.io/2021/05/13/supporting-native-android-libraries-loaded-from-apks).
[Adding Native support to our Android SDK](https://blog.sentry.io/2019/11/25/adding-native-support-to-our-android-sdk).

[New Android SDK How-to](https://blog.sentry.io/2019/12/10/new-android-sdk-how-to).

# Samples

Expand Down
3 changes: 1 addition & 2 deletions buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object Config {
val springKotlinCompatibleLanguageVersion = "1.3"

object BuildPlugins {
val androidGradle = "com.android.tools.build:gradle:4.2.2"
val androidGradle = "com.android.tools.build:gradle:7.0.2"
val kotlinGradlePlugin = "gradle-plugin"
val buildConfig = "com.github.gmazzo.buildconfig"
val buildConfigVersion = "3.0.0"
Expand Down Expand Up @@ -152,7 +152,6 @@ object Config {
val group = "io.sentry"
val description = "SDK for sentry.io"
val versionNameProp = "versionName"
val buildVersionCodeProp = "buildVersionCode"
}

object CompileOnly {
Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=512m -XX:MaxMetaspaceSize=1536m -XX:+H
android.useAndroidX=true

# Release information
buildVersionCode=20081
versionName=5.1.3-SNAPSHOT
versionName=5.2.0-beta.3-SNAPSHOT

# disable renderscript, it's enabled by default
android.defaults.buildfeatures.renderscript=false
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 0 additions & 3 deletions scripts/bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,3 @@ GRADLE_FILEPATH="gradle.properties"
# Replace `versionName` with the given version
VERSION_NAME_PATTERN="versionName"
sed -i "" -e "s/$VERSION_NAME_PATTERN=.*$/$VERSION_NAME_PATTERN=$NEW_VERSION/g" $GRADLE_FILEPATH

# Don't bump `buildVersionCode` since it's bumped after doing the release.
# See comments in `post-release.sh`.
9 changes: 0 additions & 9 deletions scripts/post-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ version_digit_to_bump="$( awk "/$VERSION_NAME_PATTERN/" $GRADLE_FILEPATH | egrep
new_version="$( echo $version | sed "s/[0-9]*$/$version_digit_to_bump/g" )"
sed -i "" -e "s/$VERSION_NAME_PATTERN=.*$/$VERSION_NAME_PATTERN=$new_version-SNAPSHOT/g" $GRADLE_FILEPATH

# Increment `buildVersionCode`
# After having incremented the version name (see comments above), the new version
# still has the version code of the version in production. This must be
# incremented to align with the new version.
VERSION_CODE_PATTERN="buildVersionCode"
VERSION_NUMBER="$( awk "/$VERSION_CODE_PATTERN/" $GRADLE_FILEPATH | grep -o '[0-9]\+' )"
((VERSION_NUMBER++))
sed -i "" -e "s/$VERSION_CODE_PATTERN=.*$/$VERSION_CODE_PATTERN=$VERSION_NUMBER/g" $GRADLE_FILEPATH

git add .
git commit -m "Prepare $new_version"
git push
5 changes: 1 addition & 4 deletions sentry-android-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ android {

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

versionName = project.version.toString()
versionCode = project.properties[Config.Sentry.buildVersionCodeProp].toString().toInt()

buildConfigField("String", "SENTRY_ANDROID_SDK_NAME", "\"${Config.Sentry.SENTRY_ANDROID_SDK_NAME}\"")

// for AGP 4.1
buildConfigField("String", "VERSION_NAME", "\"$versionName\"")
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PerformanceAndroidEventProcessorTest {
val options = SentryAndroidOptions()

val hub = mock<IHub>()
val context = TransactionContext("name", "op")
val context = TransactionContext("name", "op", true)
val tracer = SentryTracer(context, hub)
val activityFramesTracker = mock<ActivityFramesTracker>()

Expand Down
5 changes: 1 addition & 4 deletions sentry-android-fragment/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ android {
targetSdkVersion(Config.Android.targetSdkVersion)
minSdkVersion(Config.Android.minSdkVersion)

versionName = project.version.toString()
versionCode = project.properties[Config.Sentry.buildVersionCodeProp].toString().toInt()

// for AGP 4.1
buildConfigField("String", "VERSION_NAME", "\"$versionName\"")
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
}

buildTypes {
Expand Down
5 changes: 1 addition & 4 deletions sentry-android-ndk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ android {

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

versionName = project.version.toString()
versionCode = project.properties[Config.Sentry.buildVersionCodeProp].toString().toInt()

externalNativeBuild {
cmake {
arguments.add(0, "-DANDROID_STL=c++_static")
Expand All @@ -41,7 +38,7 @@ android {
}

// for AGP 4.1
buildConfigField("String", "VERSION_NAME", "\"$versionName\"")
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
}

// we use the default NDK and CMake versions based on the AGP's version
Expand Down
5 changes: 1 addition & 4 deletions sentry-android-okhttp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ android {
targetSdkVersion(Config.Android.targetSdkVersion)
minSdkVersion(Config.Android.minSdkVersionOkHttp)

versionName = project.version.toString()
versionCode = project.properties[Config.Sentry.buildVersionCodeProp].toString().toInt()

// for AGP 4.1
buildConfigField("String", "VERSION_NAME", "\"$versionName\"")
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SentryOkHttpInterceptor(
val method = request.method

// read transaction from the bound scope
var span = hub.span?.startChild("http.client", "$method $url")
val span = hub.span?.startChild("http.client", "$method $url")

var response: Response? = null

Expand All @@ -53,12 +53,8 @@ class SentryOkHttpInterceptor(
}
throw e
} finally {
if (span != null) {
if (beforeSpan != null) {
span = beforeSpan.execute(span, request, response)
}
span?.finish()
}
finishSpan(span, request, response)

val breadcrumb = Breadcrumb.http(request.url.toString(), request.method, code)
request.body?.contentLength().ifHasValidLength {
breadcrumb.setData("request_body_size", it)
Expand All @@ -70,6 +66,22 @@ class SentryOkHttpInterceptor(
}
}

private fun finishSpan(span: ISpan?, request: Request, response: Response?) {
if (span != null) {
if (beforeSpan != null) {
val result = beforeSpan.execute(span, request, response)
if (result == null) {
// span is dropped
span.spanContext.sampled = false
} else {
span.finish()
}
} else {
span.finish()
}
}
}

private fun Long?.ifHasValidLength(fn: (Long) -> Unit) {
if (this != null && this != -1L) {
fn.invoke(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class SentryOkHttpInterceptorTest {
assertEquals(1, fixture.sentryTracer.children.size)
val httpClientSpan = fixture.sentryTracer.children.first()
assertEquals("overwritten description", httpClientSpan.description)
assertTrue(httpClientSpan.isFinished)
}

@Test
Expand All @@ -227,6 +228,8 @@ class SentryOkHttpInterceptorTest {
} })
sut.newCall(getRequest()).execute()
val httpClientSpan = fixture.sentryTracer.children.first()
assertFalse(httpClientSpan.isFinished)
assertNotNull(httpClientSpan.spanContext.sampled) {
assertFalse(it)
}
}
}
5 changes: 1 addition & 4 deletions sentry-android-timber/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ android {

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

versionName = project.version.toString()
versionCode = project.properties[Config.Sentry.buildVersionCodeProp].toString().toInt()

// for AGP 4.1
buildConfigField("String", "VERSION_NAME", "\"$versionName\"")
buildConfigField("String", "VERSION_NAME", "\"${project.version}\"")
buildConfigField("String", "SENTRY_TIMBER_SDK_NAME", "\"${Config.Sentry.SENTRY_TIMBER_SDK_NAME}\"")
}

Expand Down
3 changes: 0 additions & 3 deletions sentry-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ android {
defaultConfig {
targetSdkVersion(Config.Android.targetSdkVersion)
minSdkVersion(Config.Android.minSdkVersionNdk)

versionName = project.version.toString()
versionCode = project.properties[Config.Sentry.buildVersionCodeProp].toString().toInt()
}

buildFeatures {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,15 @@ public Response execute(final @NotNull Request request, final @NotNull Request.O
throw e;
} finally {
if (beforeSpan != null) {
span = beforeSpan.execute(span, request, response);
}
if (span != null) {
final ISpan result = beforeSpan.execute(span, request, response);

if (result == null) {
// span is dropped
span.getSpanContext().setSampled(false);
} else {
span.finish();
}
} else {
span.finish();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ class SentryFeignClientTest {
val sut = fixture.getSut { _, _, _ -> null }
sut.getOk()
val httpClientSpan = fixture.sentryTracer.children.first()
assertFalse(httpClientSpan.isFinished)
assertNotNull(httpClientSpan.spanContext.sampled) {
assertFalse(it)
}
}

interface MockApi {
Expand Down
1 change: 1 addition & 0 deletions sentry-samples/sentry-samples-servlet/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
group = "io.sentry.sample.servlet"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
java.targetCompatibility = JavaVersion.VERSION_1_8

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ plugins {
group = "io.sentry.sample.spring-boot"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
java.targetCompatibility = JavaVersion.VERSION_1_8

repositories {
mavenCentral()
Expand Down
1 change: 1 addition & 0 deletions sentry-samples/sentry-samples-spring-boot/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ plugins {
group = "io.sentry.sample.spring-boot"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
java.targetCompatibility = JavaVersion.VERSION_1_8

repositories {
mavenCentral()
Expand Down
1 change: 1 addition & 0 deletions sentry-samples/sentry-samples-spring/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ plugins {
group = "io.sentry.sample.spring"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
java.targetCompatibility = JavaVersion.VERSION_1_8

repositories {
mavenCentral()
Expand Down
5 changes: 2 additions & 3 deletions sentry.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# how a sentry.properties looks like
defaults.project=android
defaults.org=man
defaults.project=sentry-android
defaults.org=sentry-sdks
auth.token=
Loading

0 comments on commit ed3d254

Please sign in to comment.