Skip to content

Commit

Permalink
Mitigate against another kafka leak (open-telemetry#6021)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored and RashmiRam committed May 23, 2022
1 parent 2b48cc8 commit 2fe8bad
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ public ConsumerRecord<K, V> next() {
// in case they didn't call hasNext()...
closeScopeAndEndSpan();

// it's important not to suppress consumer span creation here using Instrumenter.shouldStart()
// because this instrumentation can leak the context and so there may be a leaked consumer span
// in the context, in which case it's important to overwrite the leaked span instead of
// suppressing the correct span
// (https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/1947)
ConsumerRecord<K, V> next = delegateIterator.next();
if (next != null
&& consumerProcessInstrumenter().shouldStart(parentContext, next)
&& KafkaClientsConsumerProcessTracing.wrappingEnabled()) {
if (next != null && KafkaClientsConsumerProcessTracing.wrappingEnabled()) {
currentRequest = next;
currentContext = consumerProcessInstrumenter().start(parentContext, currentRequest);
currentScope = currentContext.makeCurrent();
Expand Down

0 comments on commit 2fe8bad

Please sign in to comment.