Search in sources :

Example 1 with DestinationType

use of com.newrelic.api.agent.DestinationType in project newrelic-java-agent by newrelic.

the class JmsMetricUtil method processSendMessage.

public static void processSendMessage(Message message, Destination dest, TracedMethod tracer) {
    if (message == null) {
        NewRelic.getAgent().getLogger().log(Level.FINER, "JMS processSendMessage(): message is null");
        return;
    }
    try {
        DestinationType destinationType = getDestinationType(dest);
        String destinationName = getDestinationName(dest == null ? message.getJMSDestination() : dest);
        tracer.reportAsExternal(MessageProduceParameters.library("JMS").destinationType(destinationType).destinationName(destinationName).outboundHeaders(new OutboundWrapper(message)).build());
    } catch (JMSException exception) {
        NewRelic.getAgent().getLogger().log(Level.FINE, exception, "Unable to record metrics for JMS message produce.");
    }
}
Also used : JMSException(javax.jms.JMSException) DestinationType(com.newrelic.api.agent.DestinationType)

Example 2 with DestinationType

use of com.newrelic.api.agent.DestinationType in project newrelic-java-agent by newrelic.

the class JmsMetricUtil method processConsume.

public static void processConsume(Message message, TracedMethod tracer) {
    try {
        DestinationType destinationType = getDestinationType(message.getJMSDestination());
        String destinationName = getDestinationName(message.getJMSDestination());
        tracer.reportAsExternal(MessageConsumeParameters.library("JMS").destinationType(destinationType).destinationName(destinationName).inboundHeaders(new InboundWrapper(message)).build());
    } catch (JMSException exception) {
        NewRelic.getAgent().getLogger().log(Level.FINE, exception, "Unable to record metrics for JMS message consume.");
    }
}
Also used : JMSException(javax.jms.JMSException) DestinationType(com.newrelic.api.agent.DestinationType)

Example 3 with DestinationType

use of com.newrelic.api.agent.DestinationType in project newrelic-java-agent by newrelic.

the class JmsMetricUtil method processConsume.

public static void processConsume(Message message, TracedMethod tracer) {
    if (message == null) {
        NewRelic.getAgent().getLogger().log(Level.FINER, "JMS processConsume: message is null");
        return;
    }
    try {
        DestinationType destinationType = getDestinationType(message.getJMSDestination());
        String destinationName = getDestinationName(message.getJMSDestination());
        tracer.reportAsExternal(MessageConsumeParameters.library("JMS").destinationType(destinationType).destinationName(destinationName).inboundHeaders(new InboundWrapper(message)).build());
    } catch (JMSException exception) {
        NewRelic.getAgent().getLogger().log(Level.FINE, exception, "Unable to record metrics for JMS message consume.");
    }
}
Also used : JMSException(javax.jms.JMSException) DestinationType(com.newrelic.api.agent.DestinationType)

Example 4 with DestinationType

use of com.newrelic.api.agent.DestinationType in project newrelic-java-agent by newrelic.

the class DefaultTracer method catForMessaging.

private void catForMessaging(MessageProduceParameters produceParameters) {
    OutboundHeaders outboundHeaders = produceParameters.getOutboundHeaders();
    if (outboundHeaders == null) {
        return;
    }
    // In amqp we don't know if we're sending a request or a response.
    DestinationType destinationType = produceParameters.getDestinationType();
    if (destinationType == DestinationType.EXCHANGE) {
        addOutboundRequestHeaders(outboundHeaders);
    } else // 2. Producing a message to a temporary queue, it is writing a response (outbound response).
    if (destinationType == DestinationType.NAMED_QUEUE || destinationType == DestinationType.NAMED_TOPIC) {
        addOutboundRequestHeaders(outboundHeaders);
    } else if (destinationType == DestinationType.TEMP_QUEUE || destinationType == DestinationType.TEMP_TOPIC) {
        getTransaction().getCrossProcessState().processOutboundResponseHeaders(outboundHeaders, -1);
    } else {
        Agent.LOG.log(Level.FINE, "Unexpected destination type when recording CAT metrics for message produce.");
    }
}
Also used : OutboundHeaders(com.newrelic.api.agent.OutboundHeaders) DestinationType(com.newrelic.api.agent.DestinationType)

Example 5 with DestinationType

use of com.newrelic.api.agent.DestinationType in project newrelic-java-agent by newrelic.

the class DefaultTracer method catForMessaging.

private void catForMessaging(MessageConsumeParameters consumeParameters) {
    InboundHeaders headers = consumeParameters.getInboundHeaders();
    if (headers == null) {
        return;
    }
    // In amqp we don't know if we're sending a request or a response.
    DestinationType destinationType = consumeParameters.getDestinationType();
    if (destinationType == DestinationType.EXCHANGE) {
        getTransaction().provideHeaders(headers);
    } else // 2. Consuming a message from a temporary queue, it is processing a response (inbound response).
    if (destinationType == DestinationType.NAMED_QUEUE || destinationType == DestinationType.NAMED_TOPIC) {
        getTransaction().provideHeaders(headers);
    } else if (destinationType == DestinationType.TEMP_QUEUE || destinationType == DestinationType.TEMP_TOPIC) {
        // Do not replace with recordInboundResponseHeaders.
        // recordInboundResponseHeaders assumes we do CAT request/response in the same tracer.
        Transaction transaction = getTransactionActivity().getTransaction();
        transaction.getCrossProcessState().processInboundResponseHeaders(headers, this, "Unknown", null, true);
    } else {
        Agent.LOG.log(Level.FINE, "Unexpected destination type when reporting external metrics for message consume.");
    }
}
Also used : Transaction(com.newrelic.agent.Transaction) InboundHeaders(com.newrelic.api.agent.InboundHeaders) DestinationType(com.newrelic.api.agent.DestinationType)

Aggregations

DestinationType (com.newrelic.api.agent.DestinationType)5 JMSException (javax.jms.JMSException)3 Transaction (com.newrelic.agent.Transaction)1 InboundHeaders (com.newrelic.api.agent.InboundHeaders)1 OutboundHeaders (com.newrelic.api.agent.OutboundHeaders)1