use of com.newrelic.api.agent.MessageConsumeParameters in project newrelic-java-agent by newrelic.
the class KafkaConsumer_Instrumentation method poll.
public ConsumerRecords<K, V> poll(Duration timeout) {
final ConsumerRecords<K, V> records;
try {
records = Weaver.callOriginal();
} catch (Exception e) {
// Specifically ignore WakeupExceptions because they are common in non-error use cases
if (!(e instanceof WakeupException)) {
NewRelic.noticeError(e);
}
throw e;
}
for (ConsumerRecord record : records) {
if (AgentBridge.getAgent().getTransaction(false) != null) {
MessageConsumeParameters params = MessageConsumeParameters.library("Kafka").destinationType(DestinationType.NAMED_TOPIC).destinationName(record.topic()).inboundHeaders(null).build();
NewRelic.getAgent().getTransaction().getTracedMethod().reportAsExternal(params);
}
break;
}
return records;
}
use of com.newrelic.api.agent.MessageConsumeParameters in project newrelic-java-agent by newrelic.
the class KafkaConsumer_Instrumentation method poll.
public ConsumerRecords<K, V> poll(long timeout) {
final ConsumerRecords<K, V> records;
try {
records = Weaver.callOriginal();
} catch (Exception e) {
// Specifically ignore WakeupExceptions because they are common in non-error use cases
if (!(e instanceof WakeupException)) {
NewRelic.noticeError(e);
}
throw e;
}
for (ConsumerRecord record : records) {
if (AgentBridge.getAgent().getTransaction(false) != null) {
MessageConsumeParameters params = MessageConsumeParameters.library("Kafka").destinationType(DestinationType.NAMED_TOPIC).destinationName(record.topic()).inboundHeaders(null).build();
NewRelic.getAgent().getTransaction().getTracedMethod().reportAsExternal(params);
}
break;
}
return records;
}
use of com.newrelic.api.agent.MessageConsumeParameters in project newrelic-java-agent by newrelic.
the class SqsClient_Instrumentation method receiveMessage.
@Trace
public ReceiveMessageResponse receiveMessage(ReceiveMessageRequest receiveMessageRequest) {
MessageConsumeParameters messageConsumeParameters = Util.generateExternalConsumeMetrics(receiveMessageRequest.queueUrl());
NewRelic.getAgent().getTracedMethod().reportAsExternal(messageConsumeParameters);
return Weaver.callOriginal();
}
use of com.newrelic.api.agent.MessageConsumeParameters in project newrelic-java-agent by newrelic.
the class UtilTest method testGenerateConsumeMetricsGoodQueueName.
@Test
public void testGenerateConsumeMetricsGoodQueueName() {
MessageConsumeParameters messageConsumeParameters = Util.generateExternalConsumeMetrics("path/myQueue");
Assert.assertEquals("SQS", messageConsumeParameters.getLibrary());
Assert.assertEquals("myQueue", messageConsumeParameters.getDestinationName());
Assert.assertEquals(DestinationType.NAMED_QUEUE, messageConsumeParameters.getDestinationType());
}
use of com.newrelic.api.agent.MessageConsumeParameters in project newrelic-java-agent by newrelic.
the class UtilTest method testGenerateConsumeMetricsBadQueueName.
@Test
public void testGenerateConsumeMetricsBadQueueName() {
MessageConsumeParameters messageConsumeParameters = Util.generateExternalConsumeMetrics("path");
Assert.assertEquals("SQS", messageConsumeParameters.getLibrary());
Assert.assertEquals("unknown", messageConsumeParameters.getDestinationName());
Assert.assertEquals(DestinationType.NAMED_QUEUE, messageConsumeParameters.getDestinationType());
}
Aggregations