Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public final class io/sentry/Hub : io/sentry/IHub {
public fun getLastEventId ()Lio/sentry/protocol/SentryId;
public fun getOptions ()Lio/sentry/SentryOptions;
public fun getSpan ()Lio/sentry/ISpan;
public fun getSpanContext (Ljava/lang/Throwable;)Lio/sentry/SpanContext;
public fun isEnabled ()Z
public fun popScope ()V
public fun pushScope ()V
Expand Down Expand Up @@ -158,7 +157,6 @@ public final class io/sentry/HubAdapter : io/sentry/IHub {
public fun getLastEventId ()Lio/sentry/protocol/SentryId;
public fun getOptions ()Lio/sentry/SentryOptions;
public fun getSpan ()Lio/sentry/ISpan;
public fun getSpanContext (Ljava/lang/Throwable;)Lio/sentry/SpanContext;
public fun isEnabled ()Z
public fun popScope ()V
public fun pushScope ()V
Expand Down Expand Up @@ -213,7 +211,6 @@ public abstract interface class io/sentry/IHub {
public abstract fun getLastEventId ()Lio/sentry/protocol/SentryId;
public abstract fun getOptions ()Lio/sentry/SentryOptions;
public abstract fun getSpan ()Lio/sentry/ISpan;
public abstract fun getSpanContext (Ljava/lang/Throwable;)Lio/sentry/SpanContext;
public abstract fun isEnabled ()Z
public abstract fun popScope ()V
public abstract fun pushScope ()V
Expand Down Expand Up @@ -515,6 +512,7 @@ public final class io/sentry/Sentry {
public static fun init (Lio/sentry/Sentry$OptionsConfiguration;)V
public static fun init (Lio/sentry/Sentry$OptionsConfiguration;Z)V
public static fun init (Lio/sentry/SentryOptions;)V
public static fun init (Ljava/lang/String;)V
public static fun isEnabled ()Z
public static fun popScope ()V
public static fun pushScope ()V
Expand Down
6 changes: 3 additions & 3 deletions sentry/src/main/java/io/sentry/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public SentryId captureEnvelope(
private void assignTraceContext(final @NotNull SentryEvent event) {
if (event.getThrowable() != null) {
final ISpan span = throwableToSpan.get(event.getThrowable());
if (span != null && span.getSpanContext() != null) {
if (span != null) {
if (event.getContexts().getTrace() == null) {
event.getContexts().setTrace(span.getSpanContext());
}
Expand Down Expand Up @@ -627,8 +627,8 @@ public void setSpanContext(final @NotNull Throwable throwable, final @NotNull IS
this.throwableToSpan.put(throwable, span);
}

@Override
public @Nullable SpanContext getSpanContext(final @NotNull Throwable throwable) {
@Nullable
SpanContext getSpanContext(final @NotNull Throwable throwable) {
Objects.requireNonNull(throwable, "throwable is required");
final ISpan span = this.throwableToSpan.get(throwable);
if (span != null) {
Expand Down
5 changes: 0 additions & 5 deletions sentry/src/main/java/io/sentry/HubAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,6 @@ public void setSpanContext(final @NotNull Throwable t, final @NotNull ISpan sc)
Sentry.getCurrentHub().setSpanContext(t, sc);
}

@Override
public @Nullable SpanContext getSpanContext(final @NotNull Throwable ex) {
return Sentry.getCurrentHub().getSpanContext(ex);
}

@Override
public @Nullable ISpan getSpan() {
return Sentry.getCurrentHub().getSpan();
Expand Down
11 changes: 0 additions & 11 deletions sentry/src/main/java/io/sentry/IHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,17 +343,6 @@ ITransaction startTransaction(
@ApiStatus.Internal
void setSpanContext(@NotNull Throwable throwable, @NotNull ISpan span);

/**
* Gets the span context for the span that was active while the throwable given by parameter was
* thrown.
*
* @param throwable - the throwable
* @return span context or {@code null} if no corresponding span context found.
*/
@ApiStatus.Internal
@Nullable
SpanContext getSpanContext(Throwable throwable);

/**
* Gets the current active transaction or span.
*
Expand Down
5 changes: 0 additions & 5 deletions sentry/src/main/java/io/sentry/NoOpHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,6 @@ public SentryId captureTransaction(
public void setSpanContext(
final @NotNull Throwable throwable, final @NotNull ISpan spanContext) {}

@Override
public @Nullable SpanContext getSpanContext(final @NotNull Throwable throwable) {
return null;
}

@Override
public @Nullable ISpan getSpan() {
return null;
Expand Down
4 changes: 2 additions & 2 deletions sentry/src/test/java/io/sentry/HubTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ class HubTest {
//region setSpanContext
@Test
fun `associates span context with throwable`() {
val hub = generateHub()
val hub = generateHub() as Hub
val transaction = hub.startTransaction("aTransaction")
val span = transaction.startChild("op")
val exception = RuntimeException()
Expand All @@ -1154,7 +1154,7 @@ class HubTest {

@Test
fun `returns null when no span context associated with throwable`() {
val hub = generateHub()
val hub = generateHub() as Hub
assertNull(hub.getSpanContext(RuntimeException()))
}
// endregion
Expand Down
5 changes: 0 additions & 5 deletions sentry/src/test/java/io/sentry/NoOpHubTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ class NoOpHubTest {
assertNull(sut.span)
}

@Test
fun `getSpanContext returns null`() {
assertNull(sut.getSpanContext(RuntimeException()))
}

@Test
fun `setSpanContext doesnt throw`() = sut.setSpanContext(RuntimeException(), mock())
}