Skip to content

Commit db14f63

Browse files
Remove IHub#getSpanContext from public API. (#1203)
1 parent d6c2ede commit db14f63

File tree

7 files changed

+6
-34
lines changed

7 files changed

+6
-34
lines changed

sentry/api/sentry.api

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ public final class io/sentry/Hub : io/sentry/IHub {
118118
public fun getLastEventId ()Lio/sentry/protocol/SentryId;
119119
public fun getOptions ()Lio/sentry/SentryOptions;
120120
public fun getSpan ()Lio/sentry/ISpan;
121-
public fun getSpanContext (Ljava/lang/Throwable;)Lio/sentry/SpanContext;
122121
public fun isEnabled ()Z
123122
public fun popScope ()V
124123
public fun pushScope ()V
@@ -158,7 +157,6 @@ public final class io/sentry/HubAdapter : io/sentry/IHub {
158157
public fun getLastEventId ()Lio/sentry/protocol/SentryId;
159158
public fun getOptions ()Lio/sentry/SentryOptions;
160159
public fun getSpan ()Lio/sentry/ISpan;
161-
public fun getSpanContext (Ljava/lang/Throwable;)Lio/sentry/SpanContext;
162160
public fun isEnabled ()Z
163161
public fun popScope ()V
164162
public fun pushScope ()V
@@ -213,7 +211,6 @@ public abstract interface class io/sentry/IHub {
213211
public abstract fun getLastEventId ()Lio/sentry/protocol/SentryId;
214212
public abstract fun getOptions ()Lio/sentry/SentryOptions;
215213
public abstract fun getSpan ()Lio/sentry/ISpan;
216-
public abstract fun getSpanContext (Ljava/lang/Throwable;)Lio/sentry/SpanContext;
217214
public abstract fun isEnabled ()Z
218215
public abstract fun popScope ()V
219216
public abstract fun pushScope ()V
@@ -515,6 +512,7 @@ public final class io/sentry/Sentry {
515512
public static fun init (Lio/sentry/Sentry$OptionsConfiguration;)V
516513
public static fun init (Lio/sentry/Sentry$OptionsConfiguration;Z)V
517514
public static fun init (Lio/sentry/SentryOptions;)V
515+
public static fun init (Ljava/lang/String;)V
518516
public static fun isEnabled ()Z
519517
public static fun popScope ()V
520518
public static fun pushScope ()V

sentry/src/main/java/io/sentry/Hub.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public SentryId captureEnvelope(
171171
private void assignTraceContext(final @NotNull SentryEvent event) {
172172
if (event.getThrowable() != null) {
173173
final ISpan span = throwableToSpan.get(event.getThrowable());
174-
if (span != null && span.getSpanContext() != null) {
174+
if (span != null) {
175175
if (event.getContexts().getTrace() == null) {
176176
event.getContexts().setTrace(span.getSpanContext());
177177
}
@@ -627,8 +627,8 @@ public void setSpanContext(final @NotNull Throwable throwable, final @NotNull IS
627627
this.throwableToSpan.put(throwable, span);
628628
}
629629

630-
@Override
631-
public @Nullable SpanContext getSpanContext(final @NotNull Throwable throwable) {
630+
@Nullable
631+
SpanContext getSpanContext(final @NotNull Throwable throwable) {
632632
Objects.requireNonNull(throwable, "throwable is required");
633633
final ISpan span = this.throwableToSpan.get(throwable);
634634
if (span != null) {

sentry/src/main/java/io/sentry/HubAdapter.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,6 @@ public void setSpanContext(final @NotNull Throwable t, final @NotNull ISpan sc)
185185
Sentry.getCurrentHub().setSpanContext(t, sc);
186186
}
187187

188-
@Override
189-
public @Nullable SpanContext getSpanContext(final @NotNull Throwable ex) {
190-
return Sentry.getCurrentHub().getSpanContext(ex);
191-
}
192-
193188
@Override
194189
public @Nullable ISpan getSpan() {
195190
return Sentry.getCurrentHub().getSpan();

sentry/src/main/java/io/sentry/IHub.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -343,17 +343,6 @@ ITransaction startTransaction(
343343
@ApiStatus.Internal
344344
void setSpanContext(@NotNull Throwable throwable, @NotNull ISpan span);
345345

346-
/**
347-
* Gets the span context for the span that was active while the throwable given by parameter was
348-
* thrown.
349-
*
350-
* @param throwable - the throwable
351-
* @return span context or {@code null} if no corresponding span context found.
352-
*/
353-
@ApiStatus.Internal
354-
@Nullable
355-
SpanContext getSpanContext(Throwable throwable);
356-
357346
/**
358347
* Gets the current active transaction or span.
359348
*

sentry/src/main/java/io/sentry/NoOpHub.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@ public SentryId captureTransaction(
137137
public void setSpanContext(
138138
final @NotNull Throwable throwable, final @NotNull ISpan spanContext) {}
139139

140-
@Override
141-
public @Nullable SpanContext getSpanContext(final @NotNull Throwable throwable) {
142-
return null;
143-
}
144-
145140
@Override
146141
public @Nullable ISpan getSpan() {
147142
return null;

sentry/src/test/java/io/sentry/HubTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ class HubTest {
11441144
//region setSpanContext
11451145
@Test
11461146
fun `associates span context with throwable`() {
1147-
val hub = generateHub()
1147+
val hub = generateHub() as Hub
11481148
val transaction = hub.startTransaction("aTransaction")
11491149
val span = transaction.startChild("op")
11501150
val exception = RuntimeException()
@@ -1154,7 +1154,7 @@ class HubTest {
11541154

11551155
@Test
11561156
fun `returns null when no span context associated with throwable`() {
1157-
val hub = generateHub()
1157+
val hub = generateHub() as Hub
11581158
assertNull(hub.getSpanContext(RuntimeException()))
11591159
}
11601160
// endregion

sentry/src/test/java/io/sentry/NoOpHubTest.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ class NoOpHubTest {
8484
assertNull(sut.span)
8585
}
8686

87-
@Test
88-
fun `getSpanContext returns null`() {
89-
assertNull(sut.getSpanContext(RuntimeException()))
90-
}
91-
9287
@Test
9388
fun `setSpanContext doesnt throw`() = sut.setSpanContext(RuntimeException(), mock())
9489
}

0 commit comments

Comments
 (0)