Skip to content

Commit

Permalink
Merge branch 'main' into feat/opt-out-of-pretty-print
Browse files Browse the repository at this point in the history
  • Loading branch information
adinauer authored Aug 17, 2023
2 parents 841eb43 + 3f6f636 commit 263df12
Show file tree
Hide file tree
Showing 36 changed files with 663 additions and 63 deletions.
4 changes: 2 additions & 2 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ targets:
maven:io.sentry:sentry:
maven:io.sentry:sentry-spring:
maven:io.sentry:sentry-spring-jakarta:
#maven:io.sentry:sentry-spring-boot:
#maven:io.sentry:sentry-spring-boot-jakarta:
maven:io.sentry:sentry-spring-boot:
maven:io.sentry:sentry-spring-boot-jakarta:
maven:io.sentry:sentry-spring-boot-starter:
maven:io.sentry:sentry-spring-boot-starter-jakarta:
maven:io.sentry:sentry-servlet:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration-tests-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: make stop

- name: Run All Tests in SauceLab
uses: saucelabs/saucectl-run-action@f401339df4c4b84945783f16b45fd545ac52a2eb # pin@v3
uses: saucelabs/saucectl-run-action@1c751bae46d3bf910cd10140e5a4e8259acd9fac # pin@v3
if: github.event_name != 'pull_request' && env.SAUCE_USERNAME != null
env:
GITHUB_TOKEN: ${{ github.token }}
Expand All @@ -51,7 +51,7 @@ jobs:
config-file: .sauce/sentry-uitest-android-benchmark.yml

- name: Run one test in SauceLab
uses: saucelabs/saucectl-run-action@f401339df4c4b84945783f16b45fd545ac52a2eb # pin@v3
uses: saucelabs/saucectl-run-action@1c751bae46d3bf910cd10140e5a4e8259acd9fac # pin@v3
if: github.event_name == 'pull_request' && env.SAUCE_USERNAME != null
env:
GITHUB_TOKEN: ${{ github.token }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: make stop

- name: Run Tests in SauceLab
uses: saucelabs/saucectl-run-action@f401339df4c4b84945783f16b45fd545ac52a2eb # pin@v3
uses: saucelabs/saucectl-run-action@1c751bae46d3bf910cd10140e5a4e8259acd9fac # pin@v3
env:
GITHUB_TOKEN: ${{ github.token }}
with:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Features

- Send `db.system` and `db.name` in span data ([#2894](https://github.com/getsentry/sentry-java/pull/2894))
- Send `http.request.method` in span data ([#2896](https://github.com/getsentry/sentry-java/pull/2896))
- Add `enablePrettySerializationOutput` option for opting out of pretty print ([#2871](https://github.com/getsentry/sentry-java/pull/2871))

## 6.28.0
Expand All @@ -15,6 +17,7 @@
- Improve server side GraphQL support for spring-graphql and Nextflix DGS ([#2856](https://github.com/getsentry/sentry-java/pull/2856))
- If you have already been using `SentryDataFetcherExceptionHandler` that still works but has been deprecated. Please use `SentryGenericDataFetcherExceptionHandler` combined with `SentryInstrumentation` instead for better error reporting.
- More exceptions and errors caught and reported to Sentry by also looking at the `ExecutionResult` (more specifically its `errors`)
- You may want to filter out certain errors, please see [docs on filtering](https://docs.sentry.io/platforms/java/configuration/filtering/)
- More details for Sentry events: query, variables and response (where possible)
- Breadcrumbs for operation (query, mutation, subscription), data fetchers and data loaders (Spring only)
- Better hub propagation by using `GraphQLContext`
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all clean compile javadocs dryRelease update stop checkFormat format api assembleBenchmarkTestRelease assembleUiTestRelease
.PHONY: all clean compile javadocs dryRelease update stop checkFormat format api assembleBenchmarkTestRelease assembleUiTestRelease createCoverageReports

all: stop clean javadocs compile
all: stop clean javadocs compile createCoverageReports
assembleBenchmarks: stop clean assembleBenchmarkTestRelease
assembleUiTests: stop clean assembleUiTestRelease

Expand Down Expand Up @@ -50,3 +50,10 @@ assembleBenchmarkTestRelease:
assembleUiTestRelease:
./gradlew :sentry-android-integration-tests:sentry-uitest-android:assembleRelease
./gradlew :sentry-android-integration-tests:sentry-uitest-android:assembleAndroidTest -DtestBuildType=release

# Create coverage reports
# - Jacoco for Java & Android modules
# - Kover for KMP modules e.g sentry-compose
createCoverageReports:
./gradlew jacocoTestReport
./gradlew koverXmlReportRelease
41 changes: 41 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.vanniktech.maven.publish.MavenPublishPlugin
import com.vanniktech.maven.publish.MavenPublishPluginExtension
import groovy.util.Node
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import kotlinx.kover.gradle.plugin.dsl.KoverReportExtension
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

Expand All @@ -14,6 +15,8 @@ plugins {
id(Config.QualityPlugins.detekt) version Config.QualityPlugins.detektVersion
`maven-publish`
id(Config.QualityPlugins.binaryCompatibilityValidator) version Config.QualityPlugins.binaryCompatibilityValidatorVersion
id(Config.QualityPlugins.jacocoAndroid) version Config.QualityPlugins.jacocoAndroidVersion apply false
id(Config.QualityPlugins.kover) version Config.QualityPlugins.koverVersion apply false
}

buildscript {
Expand Down Expand Up @@ -97,6 +100,44 @@ allprojects {
}

subprojects {
val jacocoAndroidModules = listOf(
"sentry-android-core",
"sentry-android-fragment",
"sentry-android-navigation",
"sentry-android-ndk",
"sentry-android-okhttp",
"sentry-android-sqlite",
"sentry-android-timber"
)
if (jacocoAndroidModules.contains(name)) {
afterEvaluate {
jacoco {
toolVersion = "0.8.10"
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = true
excludes = listOf("jdk.internal.*")
}
}
}
}

val koverKmpModules = listOf("sentry-compose")
if (koverKmpModules.contains(name)) {
afterEvaluate {
configure<KoverReportExtension> {
androidReports("release") {
xml {
// Change the report file name so the Codecov Github action can find it
setReportFile(file("$buildDir/reports/kover/report.xml"))
}
}
}
}
}

plugins.withId(Config.QualityPlugins.detektPlugin) {
configure<DetektExtension> {
buildUponDefaultConfig = true
Expand Down
5 changes: 5 additions & 0 deletions buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import java.math.BigDecimal

object Config {
Expand Down Expand Up @@ -205,6 +206,10 @@ object Config {
val binaryCompatibilityValidatorVersion = "0.13.0"
val binaryCompatibilityValidatorPlugin = "org.jetbrains.kotlinx:binary-compatibility-validator:$binaryCompatibilityValidatorVersion"
val binaryCompatibilityValidator = "org.jetbrains.kotlinx.binary-compatibility-validator"
val jacocoAndroid = "com.mxalbert.gradle.jacoco-android"
val jacocoAndroidVersion = "0.2.0"
val kover = "org.jetbrains.kotlinx.kover"
val koverVersion = "0.7.3"
}

object Sentry {
Expand Down
7 changes: 1 addition & 6 deletions sentry-android-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id("com.android.library")
kotlin("android")
jacoco
id(Config.QualityPlugins.jacocoAndroid)
id(Config.QualityPlugins.errorProne)
id(Config.QualityPlugins.gradleVersions)
}
Expand Down Expand Up @@ -64,12 +65,6 @@ android {
}
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

tasks.withType<JavaCompile>().configureEach {
options.errorprone {
check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.ERROR)
Expand Down
7 changes: 1 addition & 6 deletions sentry-android-fragment/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id("com.android.library")
kotlin("android")
jacoco
id(Config.QualityPlugins.jacocoAndroid)
id(Config.QualityPlugins.gradleVersions)
id(Config.QualityPlugins.detektPlugin)
}
Expand Down Expand Up @@ -54,12 +55,6 @@ android {
}
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

kotlin {
explicitApi()
}
Expand Down
7 changes: 1 addition & 6 deletions sentry-android-navigation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id("com.android.library")
kotlin("android")
jacoco
id(Config.QualityPlugins.jacocoAndroid)
id(Config.QualityPlugins.gradleVersions)
id(Config.QualityPlugins.detektPlugin)
}
Expand Down Expand Up @@ -55,12 +56,6 @@ android {
}
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

kotlin {
explicitApi()
}
Expand Down
7 changes: 1 addition & 6 deletions sentry-android-ndk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id("com.android.library")
kotlin("android")
jacoco
id(Config.QualityPlugins.jacocoAndroid)
id(Config.NativePlugins.nativeBundleExport)
id(Config.QualityPlugins.gradleVersions)
}
Expand Down Expand Up @@ -96,12 +97,6 @@ android {
}
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

dependencies {
api(projects.sentry)
api(projects.sentryAndroidCore)
Expand Down
7 changes: 1 addition & 6 deletions sentry-android-okhttp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id("com.android.library")
kotlin("android")
jacoco
id(Config.QualityPlugins.jacocoAndroid)
id(Config.QualityPlugins.gradleVersions)
id(Config.QualityPlugins.detektPlugin)
}
Expand Down Expand Up @@ -56,12 +57,6 @@ android {
}
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

kotlin {
explicitApi()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import io.sentry.android.okhttp.SentryOkHttpEventListener.Companion.SECURE_CONNE
import io.sentry.util.UrlUtils
import okhttp3.Request
import okhttp3.Response
import java.util.Locale
import java.util.concurrent.ConcurrentHashMap

private const val PROTOCOL_KEY = "protocol"
Expand Down Expand Up @@ -50,7 +51,7 @@ internal class SentryOkHttpEvent(private val hub: IHub, private val request: Req
callRootSpan?.setData("url", url)
callRootSpan?.setData("host", host)
callRootSpan?.setData("path", encodedPath)
callRootSpan?.setData(SpanDataConvention.HTTP_METHOD_KEY, method)
callRootSpan?.setData(SpanDataConvention.HTTP_METHOD_KEY, method.toUpperCase(Locale.ROOT))
}

/**
Expand Down
7 changes: 1 addition & 6 deletions sentry-android-sqlite/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id("com.android.library")
kotlin("android")
jacoco
id(Config.QualityPlugins.jacocoAndroid)
id(Config.QualityPlugins.gradleVersions)
id(Config.QualityPlugins.detektPlugin)
}
Expand Down Expand Up @@ -56,12 +57,6 @@ android {
}
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

kotlin {
explicitApi()
}
Expand Down
7 changes: 1 addition & 6 deletions sentry-android-timber/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id("com.android.library")
kotlin("android")
jacoco
id(Config.QualityPlugins.jacocoAndroid)
id(Config.QualityPlugins.gradleVersions)
id(Config.QualityPlugins.detektPlugin)
}
Expand Down Expand Up @@ -59,12 +60,6 @@ android {
}
}

tasks.withType<Test> {
configure<JacocoTaskExtension> {
isIncludeNoLocationClasses = false
}
}

kotlin {
explicitApi()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import io.sentry.SentryIntegrationPackageStorage
import io.sentry.SentryLevel
import io.sentry.SentryOptions.DEFAULT_PROPAGATION_TARGETS
import io.sentry.SpanDataConvention
import io.sentry.SpanDataConvention.HTTP_METHOD_KEY
import io.sentry.SpanStatus
import io.sentry.TypeCheckHint.APOLLO_REQUEST
import io.sentry.TypeCheckHint.APOLLO_RESPONSE
Expand All @@ -34,6 +35,7 @@ import io.sentry.util.UrlUtils
import io.sentry.vendor.Base64
import okio.Buffer
import org.jetbrains.annotations.ApiStatus
import java.util.Locale

private const val TRACE_ORIGIN = "auto.graphql.apollo3"

Expand Down Expand Up @@ -171,7 +173,7 @@ class SentryApollo3HttpInterceptor @JvmOverloads constructor(
variables?.let {
setData("variables", it)
}
setData("http.method", method)
setData(HTTP_METHOD_KEY, method.toUpperCase(Locale.ROOT))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import io.sentry.SentryOptions.DEFAULT_PROPAGATION_TARGETS
import io.sentry.SentryTraceHeader
import io.sentry.SentryTracer
import io.sentry.SpanDataConvention
import io.sentry.SpanDataConvention.HTTP_METHOD_KEY
import io.sentry.SpanStatus
import io.sentry.TraceContext
import io.sentry.TracesSamplingDecision
Expand Down Expand Up @@ -154,6 +155,7 @@ class SentryApollo3InterceptorTest {
verify(fixture.hub).captureTransaction(
check {
assertTransactionDetails(it, httpStatusCode = 404, contentLength = null)
assertEquals("POST", it.spans.first().data?.get(SpanDataConvention.HTTP_METHOD_KEY))
assertEquals(404, it.spans.first().data?.get(SpanDataConvention.HTTP_STATUS_CODE_KEY))
assertEquals(SpanStatus.NOT_FOUND, it.spans.first().status)
},
Expand Down Expand Up @@ -314,7 +316,7 @@ class SentryApollo3InterceptorTest {
assertTrue { httpClientSpan.description?.startsWith("Post LaunchDetails") == true }
assertNotNull(httpClientSpan.data) {
assertNotNull(it["operationId"])
assertEquals("Post", it["http.method"])
assertEquals("POST", it[HTTP_METHOD_KEY])
httpStatusCode?.let { code ->
assertEquals(code, it[SpanDataConvention.HTTP_STATUS_CODE_KEY])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import io.sentry.SpanStatus
import io.sentry.TypeCheckHint.APOLLO_REQUEST
import io.sentry.TypeCheckHint.APOLLO_RESPONSE
import io.sentry.util.TracingUtils
import java.util.Locale
import java.util.concurrent.Executor

private const val TRACE_ORIGIN = "auto.graphql.apollo"
Expand Down Expand Up @@ -72,6 +73,12 @@ class SentryApolloInterceptor(
} else {
span.status = SpanStatus.UNKNOWN
}
response.httpResponse.map { it.request().method() }.orNull()?.let {
span.setData(
SpanDataConvention.HTTP_METHOD_KEY,
it.toUpperCase(Locale.ROOT)
)
}

finish(span, requestWithHeader, response)
callBack.onResponse(response)
Expand Down
Loading

0 comments on commit 263df12

Please sign in to comment.