use of com.newrelic.api.agent.MessageConsumeParameters in project newrelic-java-agent by newrelic.
the class Util method generateExternalConsumeMetrics.
public static MessageConsumeParameters generateExternalConsumeMetrics(String queueUrl) {
String queueName = UNKOWN;
int index = queueUrl.lastIndexOf('/');
if (index > 0) {
queueName = queueUrl.substring(index + 1);
}
MessageConsumeParameters params = MessageConsumeParameters.library(LIBRARY).destinationType(DestinationType.NAMED_QUEUE).destinationName(queueName).inboundHeaders(null).build();
return params;
}
use of com.newrelic.api.agent.MessageConsumeParameters in project newrelic-java-agent by newrelic.
the class AmazonSQS_Instrumentation method receiveMessage.
@Trace
public ReceiveMessageResult receiveMessage(ReceiveMessageRequest receiveMessageRequest) {
MessageConsumeParameters messageConsumeParameters = Util.generateExternalConsumeMetrics(receiveMessageRequest.getQueueUrl());
NewRelic.getAgent().getTracedMethod().reportAsExternal(messageConsumeParameters);
return Weaver.callOriginal();
}
use of com.newrelic.api.agent.MessageConsumeParameters in project newrelic-java-agent by newrelic.
the class KafkaConsumer_Instrumentation method poll.
private ConsumerRecords<K, V> poll(final Timer timer, final boolean includeMetadataInTimeout) {
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 DefaultTracer method reportAsExternal.
@Override
public void reportAsExternal(ExternalParameters externalParameters) {
if (Agent.LOG.isFineEnabled()) {
Agent.LOG.log(Level.FINE, "Setting externalParameters to: " + externalParameters);
}
MetricNames.recordApiSupportabilityMetric(MetricNames.SUPPORTABILITY_API_REPORT_AS_EXTERNAL);
this.externalParameters = externalParameters;
if (this.externalParameters instanceof HttpParameters) {
// URI validity check and logging
HttpParameters httpParameters = (HttpParameters) this.externalParameters;
URI uri = httpParameters.getUri();
if (uri == null || uri.getScheme() == null || uri.getHost() == null || uri.getPort() == -1) {
Agent.LOG.log(Level.FINE, "URI parameter passed to HttpParameters should include a valid scheme, host, and port.");
}
InboundHeaders headers = httpParameters.getInboundResponseHeaders();
if (null != headers) {
readInboundResponseHeaders(headers);
}
} else if (this.externalParameters instanceof MessageProduceParameters) {
catForMessaging(((MessageProduceParameters) this.externalParameters));
} else if (this.externalParameters instanceof MessageConsumeParameters) {
catForMessaging(((MessageConsumeParameters) this.externalParameters));
}
}
Aggregations