Skip to content

Commit a2b2bc1

Browse files
authored
Merge pull request #5315 from getsentry/ref/queue-instrumentation-kafka-log-failures
ref(kafka): [Queue Instrumentation 20] Log Kafka instrumentation failures
2 parents 741c645 + adf85eb commit a2b2bc1

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

sentry-kafka/src/main/java/io/sentry/kafka/SentryKafkaConsumerTracing.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import io.sentry.ISentryLifecycleToken;
77
import io.sentry.ITransaction;
88
import io.sentry.ScopesAdapter;
9+
import io.sentry.SentryLevel;
910
import io.sentry.SentryTraceHeader;
1011
import io.sentry.SpanDataConvention;
1112
import io.sentry.SpanStatus;
@@ -83,7 +84,11 @@ <K, V, U> U withTracingImpl(
8384
try {
8485
forkedScopes = scopes.forkedRootScopes(CREATOR);
8586
lifecycleToken = forkedScopes.makeCurrent();
86-
} catch (Throwable ignored) {
87+
} catch (Throwable t) {
88+
scopes
89+
.getOptions()
90+
.getLogger()
91+
.log(SentryLevel.ERROR, "Failed to fork scopes for Kafka consumer tracing.", t);
8792
return callable.call();
8893
}
8994

@@ -175,7 +180,11 @@ private boolean isIgnored() {
175180
}
176181

177182
return transaction;
178-
} catch (Throwable ignored) {
183+
} catch (Throwable t) {
184+
scopes
185+
.getOptions()
186+
.getLogger()
187+
.log(SentryLevel.ERROR, "Failed to start Kafka consumer tracing transaction.", t);
179188
return null;
180189
}
181190
}
@@ -194,8 +203,12 @@ private void finishTransaction(
194203
transaction.setThrowable(throwable);
195204
}
196205
transaction.finish();
197-
} catch (Throwable ignored) {
206+
} catch (Throwable t) {
198207
// Instrumentation must never break customer processing.
208+
scopes
209+
.getOptions()
210+
.getLogger()
211+
.log(SentryLevel.ERROR, "Failed to finish Kafka consumer tracing transaction.", t);
199212
}
200213
}
201214

sentry-kafka/src/main/java/io/sentry/kafka/SentryKafkaProducerInterceptor.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import io.sentry.IScopes;
66
import io.sentry.ISpan;
77
import io.sentry.ScopesAdapter;
8+
import io.sentry.SentryLevel;
89
import io.sentry.SentryTraceHeader;
910
import io.sentry.SpanDataConvention;
1011
import io.sentry.SpanOptions;
@@ -71,8 +72,11 @@ public SentryKafkaProducerInterceptor(
7172

7273
span.setStatus(SpanStatus.OK);
7374
span.finish();
74-
} catch (Throwable ignored) {
75-
// Instrumentation must never break the customer's Kafka send.
75+
} catch (Throwable t) {
76+
scopes
77+
.getOptions()
78+
.getLogger()
79+
.log(SentryLevel.ERROR, "Failed to instrument Kafka producer record.", t);
7680
}
7781

7882
return record;

0 commit comments

Comments
 (0)