use of com.nr.instrumentation.kafka.CallbackWrapper in project newrelic-java-agent by newrelic.
the class KafkaProducer_Instrumentation method doSend.
@Trace
private Future<RecordMetadata> doSend(ProducerRecord record, Callback callback) {
if (callback != null) {
// Wrap the callback so we can capture metrics about messages being produced
callback = new CallbackWrapper(callback, record.topic());
}
if (AgentBridge.getAgent().getTransaction(false) != null) {
// use null for headers so we don't try to do CAT
MessageProduceParameters params = MessageProduceParameters.library("Kafka").destinationType(DestinationType.NAMED_TOPIC).destinationName(record.topic()).outboundHeaders(null).build();
NewRelic.getAgent().getTransaction().getTracedMethod().reportAsExternal(params);
}
try {
return Weaver.callOriginal();
} catch (Exception e) {
Map<String, Object> atts = new HashMap<>();
atts.put("topic_name", record.topic());
NewRelic.noticeError(e, atts);
throw e;
}
}
Aggregations