use of com.newrelic.api.agent.MessageProduceParameters 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;
}
}
use of com.newrelic.api.agent.MessageProduceParameters in project newrelic-java-agent by newrelic.
the class AmazonSNSAsync_Instrumentation method startSegment.
private Segment startSegment(PublishRequest publishRequest, Transaction transaction) {
final Segment segment = transaction.startSegment("SNS");
MessageProduceParameters params = SNSInstrumentationHelper.makeMessageProducerParameters(publishRequest);
segment.reportAsExternal(params);
return segment;
}
use of com.newrelic.api.agent.MessageProduceParameters in project newrelic-java-agent by newrelic.
the class SNSInstrumentationHelperTest method testPhoneNumberBasedMessage.
@Test
public void testPhoneNumberBasedMessage() throws Exception {
PublishRequest publishRequest = new PublishRequest(null, "message", "VERY IMPORTANT");
publishRequest.setPhoneNumber("8675309er");
MessageProduceParameters result = SNSInstrumentationHelper.makeMessageProducerParameters(publishRequest);
assertEquals("SNS", result.getLibrary());
assertEquals("PhoneNumber", result.getDestinationName());
assertEquals(DestinationType.NAMED_TOPIC, result.getDestinationType());
}
use of com.newrelic.api.agent.MessageProduceParameters in project newrelic-java-agent by newrelic.
the class SNSInstrumentationHelperTest method testTopicArnBasedMessage.
@Test
public void testTopicArnBasedMessage() throws Exception {
PublishRequest publishRequest = new PublishRequest("userSpecifiedTopicArn", "message", "VERY IMPORTANT");
MessageProduceParameters result = SNSInstrumentationHelper.makeMessageProducerParameters(publishRequest);
assertEquals("SNS", result.getLibrary());
assertEquals("userSpecifiedTopicArn", result.getDestinationName());
assertEquals(DestinationType.NAMED_TOPIC, result.getDestinationType());
}
use of com.newrelic.api.agent.MessageProduceParameters in project newrelic-java-agent by newrelic.
the class SnsClientInstrumentationHelperTest method testPhoneNumberBasedMessage.
@Test
public void testPhoneNumberBasedMessage() throws Exception {
PublishRequest publishRequest = PublishRequest.builder().message("message").phoneNumber("8675309er").subject("VERY IMPORTANT").build();
MessageProduceParameters result = SnsClientInstrumentationHelper.makeMessageProducerParameters(publishRequest);
assertEquals("SNS", result.getLibrary());
assertEquals("PhoneNumber", result.getDestinationName());
assertEquals(DestinationType.NAMED_TOPIC, result.getDestinationType());
}
Aggregations