Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into gh-1334
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejwalkowiak committed Jul 19, 2021
2 parents 52a79ab + 5ab8e8d commit d6c30b3
Show file tree
Hide file tree
Showing 21 changed files with 59 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

## Unreleased

* Fix: set min sdk version of sentry-android-fragment to API 14 (#1608)
* Feat: Add request body extraction for Spring MVC integration (#1595)

## 5.1.0-beta.5

* Make SentryAppender non-final for Log4j2 and Logback (#1603)
* Fix: Do not throw IAE when tracing header contain invalid trace id (#1605)

## 5.1.0-beta.4

* Update sentry-native to 0.4.11 (#1591)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Sentry SDK for Java and Android
| sentry-android-ndk | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-ndk/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-ndk) | 16 |
| sentry-android-okhttp | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-okhttp/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-okhttp) | 21 |
| sentry-android-timber | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-timber/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-timber) | 14 |
| sentry-android-fragment | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-fragment/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-fragment) | 21 |
| sentry-android-fragment | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-fragment/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-fragment) | 14 |
| sentry-apache-http-client-5 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apache-http-client-5/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apache-http-client-5) |
| sentry | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry) | 14 |
| sentry-jul | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-jul/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-jul) |
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 @@ -33,7 +33,6 @@ object Config {

val minSdkVersion = 14
val minSdkVersionOkHttp = 21
val minSdkVersionFragment = 21
val minSdkVersionNdk = 16
val targetSdkVersion = sdkVersion
val compileSdkVersion = sdkVersion
Expand Down Expand Up @@ -86,7 +85,7 @@ object Config {

val coroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3"

val fragment = "androidx.fragment:fragment-ktx:1.3.4"
val fragment = "androidx.fragment:fragment-ktx:1.3.5"

val reactorCore = "io.projectreactor:reactor-core:3.4.6"
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=512m -XX:MaxMetaspaceSize=1536m -XX:+H
android.useAndroidX=true

# Release information
buildVersionCode=20074
versionName=5.1.0-beta.5-SNAPSHOT
buildVersionCode=20075
versionName=5.1.0-beta.6-SNAPSHOT

# disable renderscript, it's enabled by default
android.defaults.buildfeatures.renderscript=false
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ case "`uname`" in
Darwin* )
darwin=true
;;
MINGW* )
MSYS* | MINGW* )
msys=true
;;
NONSTOP* )
Expand Down
2 changes: 1 addition & 1 deletion scripts/post-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ sed -i "" -e "s/$VERSION_NAME_PATTERN=.*$/$VERSION_NAME_PATTERN=$new_version-SNA
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
sed -i "" -e "s/$VERSION_CODE_PATTERN=.*$/$VERSION_CODE_PATTERN=$VERSION_NUMBER/g" $GRADLE_FILEPATH

git add .
git commit -m "Prepare $new_version"
Expand Down
3 changes: 3 additions & 0 deletions sentry-android-core/api/sentry-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public final class io/sentry/android/core/AppLifecycleIntegration : io/sentry/In
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
}

public final class io/sentry/android/core/AppStartState {
}

public final class io/sentry/android/core/BuildConfig {
public static final field BUILD_TYPE Ljava/lang/String;
public static final field DEBUG Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import android.os.SystemClock;
import java.util.Date;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;

/** AppStartState holds the state of the App Start metric and appStartTime */
final class AppStartState {
@ApiStatus.Internal
public final class AppStartState {

private static @NotNull AppStartState instance = new AppStartState();

Expand Down
2 changes: 1 addition & 1 deletion sentry-android-fragment/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ android {

defaultConfig {
targetSdkVersion(Config.Android.targetSdkVersion)
minSdkVersion(Config.Android.minSdkVersionFragment)
minSdkVersion(Config.Android.minSdkVersion)

versionName = project.version.toString()
versionCode = project.properties[Config.Sentry.buildVersionCodeProp].toString().toInt()
Expand Down
4 changes: 3 additions & 1 deletion sentry-log4j2/api/sentry-log4j2.api
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ public final class io/sentry/log4j2/BuildConfig {
public static final field VERSION_NAME Ljava/lang/String;
}

public final class io/sentry/log4j2/SentryAppender : org/apache/logging/log4j/core/appender/AbstractAppender {
public class io/sentry/log4j2/SentryAppender : org/apache/logging/log4j/core/appender/AbstractAppender {
public fun <init> (Ljava/lang/String;Lorg/apache/logging/log4j/core/Filter;Ljava/lang/String;Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Level;Ljava/lang/Boolean;Lio/sentry/ITransportFactory;Lio/sentry/IHub;)V
public fun append (Lorg/apache/logging/log4j/core/LogEvent;)V
public static fun createAppender (Ljava/lang/String;Lorg/apache/logging/log4j/Level;Lorg/apache/logging/log4j/Level;Ljava/lang/String;Ljava/lang/Boolean;Lorg/apache/logging/log4j/core/Filter;)Lio/sentry/log4j2/SentryAppender;
protected fun createBreadcrumb (Lorg/apache/logging/log4j/core/LogEvent;)Lio/sentry/Breadcrumb;
protected fun createEvent (Lorg/apache/logging/log4j/core/LogEvent;)Lio/sentry/SentryEvent;
public fun start ()V
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.sentry.log4j2;

import com.jakewharton.nopen.annotation.Open;
import io.sentry.Breadcrumb;
import io.sentry.DateUtils;
import io.sentry.HubAdapter;
Expand Down Expand Up @@ -33,7 +34,8 @@

/** Appender for Log4j2 in charge of sending the logged events to a Sentry server. */
@Plugin(name = "Sentry", category = "Core", elementType = "appender", printObject = true)
public final class SentryAppender extends AbstractAppender {
@Open
public class SentryAppender extends AbstractAppender {
private final @Nullable String dsn;
private final @Nullable ITransportFactory transportFactory;
private @NotNull Level minimumBreadcrumbLevel = Level.INFO;
Expand Down Expand Up @@ -136,7 +138,7 @@ public void append(final @NotNull LogEvent eventObject) {
*/
// for the Android compatibility we must use old Java Date class
@SuppressWarnings("JdkObsolete")
final @NotNull SentryEvent createEvent(final @NotNull LogEvent loggingEvent) {
protected @NotNull SentryEvent createEvent(final @NotNull LogEvent loggingEvent) {
final SentryEvent event = new SentryEvent(DateUtils.getDateTime(loggingEvent.getTimeMillis()));
final Message message = new Message();
message.setMessage(loggingEvent.getMessage().getFormat());
Expand Down Expand Up @@ -186,7 +188,7 @@ public void append(final @NotNull LogEvent eventObject) {
* @param loggingEvent the log4j2 event
* @return the sentry breadcrumb
*/
private @NotNull Breadcrumb createBreadcrumb(final @NotNull LogEvent loggingEvent) {
protected @NotNull Breadcrumb createBreadcrumb(final @NotNull LogEvent loggingEvent) {
final Breadcrumb breadcrumb = new Breadcrumb();
breadcrumb.setLevel(formatLevel(loggingEvent.getLevel()));
breadcrumb.setCategory(loggingEvent.getLoggerName());
Expand Down
6 changes: 5 additions & 1 deletion sentry-logback/api/sentry-logback.api
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ public final class io/sentry/logback/BuildConfig {
public static final field VERSION_NAME Ljava/lang/String;
}

public final class io/sentry/logback/SentryAppender : ch/qos/logback/core/UnsynchronizedAppenderBase {
public class io/sentry/logback/SentryAppender : ch/qos/logback/core/UnsynchronizedAppenderBase {
public fun <init> ()V
protected fun append (Lch/qos/logback/classic/spi/ILoggingEvent;)V
protected synthetic fun append (Ljava/lang/Object;)V
protected fun createBreadcrumb (Lch/qos/logback/classic/spi/ILoggingEvent;)Lio/sentry/Breadcrumb;
protected fun createEvent (Lch/qos/logback/classic/spi/ILoggingEvent;)Lio/sentry/SentryEvent;
public fun getMinimumBreadcrumbLevel ()Lch/qos/logback/classic/Level;
public fun getMinimumEventLevel ()Lch/qos/logback/classic/Level;
public fun setMinimumBreadcrumbLevel (Lch/qos/logback/classic/Level;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.ThrowableProxy;
import ch.qos.logback.core.UnsynchronizedAppenderBase;
import com.jakewharton.nopen.annotation.Open;
import io.sentry.Breadcrumb;
import io.sentry.DateUtils;
import io.sentry.ITransportFactory;
Expand All @@ -26,7 +27,8 @@
import org.jetbrains.annotations.Nullable;

/** Appender for logback in charge of sending the logged events to a Sentry server. */
public final class SentryAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
@Open
public class SentryAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
private @NotNull SentryOptions options = new SentryOptions();
private @Nullable ITransportFactory transportFactory;
private @NotNull Level minimumBreadcrumbLevel = Level.INFO;
Expand Down Expand Up @@ -72,7 +74,7 @@ protected void append(@NotNull ILoggingEvent eventObject) {
*/
// for the Android compatibility we must use old Java Date class
@SuppressWarnings("JdkObsolete")
final @NotNull SentryEvent createEvent(@NotNull ILoggingEvent loggingEvent) {
protected @NotNull SentryEvent createEvent(@NotNull ILoggingEvent loggingEvent) {
final SentryEvent event = new SentryEvent(DateUtils.getDateTime(loggingEvent.getTimeStamp()));
final Message message = new Message();
message.setMessage(loggingEvent.getMessage());
Expand Down Expand Up @@ -123,7 +125,7 @@ protected void append(@NotNull ILoggingEvent eventObject) {
* @param loggingEvent the logback event
* @return the sentry breadcrumb
*/
private @NotNull Breadcrumb createBreadcrumb(final @NotNull ILoggingEvent loggingEvent) {
protected @NotNull Breadcrumb createBreadcrumb(final @NotNull ILoggingEvent loggingEvent) {
final Breadcrumb breadcrumb = new Breadcrumb();
breadcrumb.setLevel(formatLevel(loggingEvent.getLevel()));
breadcrumb.setCategory(loggingEvent.getLoggerName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private ITransaction startTransaction(
} catch (InvalidSentryTraceHeaderException e) {
hub.getOptions()
.getLogger()
.log(SentryLevel.DEBUG, "Failed to parse Sentry trace header: %s", e.getMessage());
.log(SentryLevel.DEBUG, e, "Failed to parse Sentry trace header: %s", e.getMessage());
}
}
return hub.startTransaction(name, "http.server", customSamplingContext, true);
Expand Down
1 change: 1 addition & 0 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,7 @@ public final class io/sentry/exception/ExceptionMechanismException : java/lang/R

public final class io/sentry/exception/InvalidSentryTraceHeaderException : java/lang/Exception {
public fun <init> (Ljava/lang/String;)V
public fun <init> (Ljava/lang/String;Ljava/lang/Throwable;)V
public fun getSentryTraceHeader ()Ljava/lang/String;
}

Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/ISpan.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ISpan startChild(
ISpan startChild(@NotNull String operation, @Nullable String description);

/**
* Returns a string that could be sent as a sentry-trace header.
* Returns the trace information that could be sent as a sentry-trace header.
*
* @return SentryTraceHeader.
*/
Expand Down
8 changes: 6 additions & 2 deletions sentry/src/main/java/io/sentry/SentryTraceHeader.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ public SentryTraceHeader(final @NotNull String value) throws InvalidSentryTraceH
} else {
this.sampled = null;
}
this.traceId = new SentryId(parts[0]);
this.spanId = new SpanId(parts[1]);
try {
this.traceId = new SentryId(parts[0]);
this.spanId = new SpanId(parts[1]);
} catch (Exception e) {
throw new InvalidSentryTraceHeaderException(value, e);
}
}

public @NotNull String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.sentry.SentryTraceHeader;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* Thrown when {@link SentryTraceHeader} fails to create because of the invalid value of the
Expand All @@ -12,7 +13,12 @@ public final class InvalidSentryTraceHeaderException extends Exception {
private final @NotNull String sentryTraceHeader;

public InvalidSentryTraceHeaderException(final @NotNull String sentryTraceHeader) {
super("sentry-trace header does not conform to expected format: " + sentryTraceHeader);
this(sentryTraceHeader, null);
}

public InvalidSentryTraceHeaderException(
final @NotNull String sentryTraceHeader, final @Nullable Throwable cause) {
super("sentry-trace header does not conform to expected format: " + sentryTraceHeader, cause);
this.sentryTraceHeader = sentryTraceHeader;
}

Expand Down
5 changes: 5 additions & 0 deletions sentry/src/test/java/io/sentry/SentryTraceHeaderTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@ class SentryTraceHeaderTest {
val header = SentryTraceHeader("$sentryId-$spanId-0")
assertEquals("$sentryId-$spanId-0", header.value)
}

@Test
fun `throws InvalidSentryTraceHeaderException when traceId has invalid value`() {
assertFailsWith<InvalidSentryTraceHeaderException> { SentryTraceHeader("xxx-${SpanId()}-0") }
}
}

0 comments on commit d6c30b3

Please sign in to comment.