Skip to content

Commit

Permalink
fix instrumented type & depth count
Browse files Browse the repository at this point in the history
  • Loading branch information
vandonr committed Nov 16, 2023
1 parent 619cb0f commit d7b4f5c
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,18 @@

@AutoService(Instrumenter.class)
public final class KafkaProducerInstrumentation extends Instrumenter.Tracing
implements Instrumenter.ForSingleType {
implements Instrumenter.ForKnownTypes {

public KafkaProducerInstrumentation() {
super("kafka");
}

@Override
public String instrumentedType() {
return "org.apache.kafka.clients.producer.KafkaProducer";
public String[] knownMatchingTypes() {
return new String[] {
"org.apache.kafka.clients.producer.KafkaProducer",
"org.apache.kafka.common.record.AbstractRecords"
};
}

@Override
Expand Down Expand Up @@ -131,6 +134,9 @@ record =
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void stopSpan(
@Advice.Enter final AgentScope scope, @Advice.Thrown final Throwable throwable) {
// reset depth count for EstimateSizeAdvice
CallDepthThreadLocalMap.reset(AbstractRecords.class);

PRODUCER_DECORATE.onError(scope, throwable);
PRODUCER_DECORATE.beforeFinish(scope);
scope.close();
Expand Down

0 comments on commit d7b4f5c

Please sign in to comment.