Search in sources :

Example 21 with ExpectedTrace

use of com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace in project pinpoint by naver.

the class KafkaClientITBase method verifyConsumerEntryPoint.

private void verifyConsumerEntryPoint(PluginTestVerifier verifier, String topic, String expectedRpc, Class<?> paramType, ExpectedAnnotation... expectedAnnotations) throws NoSuchMethodException {
    Method sendMethod = KafkaProducer.class.getDeclaredMethod("send", ProducerRecord.class, Callback.class);
    ExpectedTrace.Builder eventBuilder = ExpectedTrace.createEventBuilder(KAFKA_CLIENT_SERVICE_TYPE);
    eventBuilder.setMethod(sendMethod);
    eventBuilder.setEndPoint(BROKER_URL);
    eventBuilder.setDestinationId(BROKER_URL);
    eventBuilder.setAnnotations(annotation("kafka.topic", topic));
    ExpectedTrace producerSendExpected = eventBuilder.build();
    ExpectedTrace.Builder rootBuilder = ExpectedTrace.createRootBuilder(KAFKA_CLIENT_SERVICE_TYPE);
    rootBuilder.setMethodSignature("Kafka Consumer Invocation");
    rootBuilder.setRpc(expectedRpc);
    rootBuilder.setRemoteAddr(BROKER_URL);
    rootBuilder.setAnnotations(expectedAnnotations);
    ExpectedTrace consumerEntryPointInvocationExpected = rootBuilder.build();
    Method consumeRecordsMethod = TestConsumerRecordEntryPoint.class.getDeclaredMethod("consumeRecord", paramType);
    ExpectedTrace messageArrivedExpected = event(KAFKA_CLIENT_INTERNAL_SERVICE_TYPE, consumeRecordsMethod);
    verifier.printCache();
    verifier.verifyDiscreteTrace(producerSendExpected, consumerEntryPointInvocationExpected, messageArrivedExpected);
}
Also used : ExpectedTrace(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace) Method(java.lang.reflect.Method)

Example 22 with ExpectedTrace

use of com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace in project pinpoint by naver.

the class PahoMqttV5ClientIT method verifyTrace.

private void verifyTrace(PluginTestVerifier verifier) throws NoSuchMethodException {
    Method publishMethod = MqttAsyncClient.class.getDeclaredMethod("publish", String.class, MqttMessage.class, Object.class, org.eclipse.paho.mqttv5.client.MqttActionListener.class);
    ExpectedTrace publishExpected = event(PAHO_MQTT_CLIENT, publishMethod, annotation("mqtt.broker.uri", container.getBrokerUrl()), annotation("mqtt.topic", TOPIC), annotation("mqtt.message.payload", MESSAGE_PAYLOAD), annotation("mqtt.qos", QOS));
    String expectedRpcName = "mqtt://topic=" + TOPIC + "&qos=" + QOS;
    ExpectedTrace messageArrivedInvocationExpected = root(PAHO_MQTT_CLIENT, "MQTT Message Arrived Invocation", expectedRpcName, null, container.getBrokerUrl(), annotation("mqtt.message.payload", MESSAGE_PAYLOAD));
    Method messageArrivedMethod = CommsCallback.class.getDeclaredMethod("messageArrived", MqttPublish.class);
    ExpectedTrace messageArrivedExpected = event(PAHO_MQTT_CLIENT_INTERNAL, messageArrivedMethod);
    verifier.verifyDiscreteTrace(publishExpected, messageArrivedInvocationExpected, messageArrivedExpected);
}
Also used : ExpectedTrace(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace) Method(java.lang.reflect.Method)

Example 23 with ExpectedTrace

use of com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace in project pinpoint by naver.

the class PahoMqttV3ClientIT method verifyTrace.

private void verifyTrace(PluginTestVerifier verifier) throws NoSuchMethodException {
    Method publishMethod = MqttAsyncClient.class.getDeclaredMethod("publish", String.class, MqttMessage.class, Object.class, org.eclipse.paho.client.mqttv3.IMqttActionListener.class);
    ExpectedTrace publishExpected = event(PAHO_MQTT_CLIENT, publishMethod, annotation("mqtt.broker.uri", container.getBrokerUrl()), annotation("mqtt.topic", TOPIC), annotation("mqtt.message.payload", MESSAGE_PAYLOAD), annotation("mqtt.qos", QOS));
    String expectedRpcName = "mqtt://topic=" + TOPIC + "&qos=" + QOS;
    ExpectedTrace messageArrivedInvocationExpected = root(PAHO_MQTT_CLIENT, "MQTT Message Arrived Invocation", expectedRpcName, null, container.getBrokerUrl(), annotation("mqtt.message.payload", MESSAGE_PAYLOAD));
    Method messageArrivedMethod = CommsCallback.class.getDeclaredMethod("messageArrived", MqttPublish.class);
    ExpectedTrace messageArrivedExpected = event(PAHO_MQTT_CLIENT_INTERNAL, messageArrivedMethod);
    verifier.verifyDiscreteTrace(publishExpected, messageArrivedInvocationExpected, messageArrivedExpected);
}
Also used : ExpectedTrace(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace) Method(java.lang.reflect.Method)

Example 24 with ExpectedTrace

use of com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace in project pinpoint by naver.

the class ProcessIT method test1.

@Test
public void test1() throws Exception {
    Process process = Runtime.getRuntime().exec(CMD);
    long pid = getPid(process);
    process.destroy();
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    ExpectedTrace event = event("PROCESS", ProcessBuilder.class.getMethod("start"), processAnnotations(pid));
    verifier.verifyTrace(event);
}
Also used : ExpectedTrace(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 25 with ExpectedTrace

use of com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace in project pinpoint by naver.

the class ProcessIT method test0.

@Test
public void test0() throws Exception {
    ProcessBuilder pb = new ProcessBuilder(CMD);
    Process process = pb.start();
    long pid = getPid(process);
    process.destroy();
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    ExpectedTrace event = event("PROCESS", ProcessBuilder.class.getMethod("start"), processAnnotations(pid));
    verifier.verifyTrace(event);
}
Also used : ExpectedTrace(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Aggregations

ExpectedTrace (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace)40 Method (java.lang.reflect.Method)33 PluginTestVerifier (com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)28 Test (org.junit.Test)24 PropagationMarker (com.navercorp.test.pinpoint.plugin.rabbitmq.PropagationMarker)21 AMQP (com.rabbitmq.client.AMQP)21 ExpectedAnnotation (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation)3 SpanType (com.navercorp.pinpoint.profiler.context.SpanType)2 AssertionErrorBuilder (com.navercorp.pinpoint.test.util.AssertionErrorBuilder)2 ActualTrace (com.navercorp.pinpoint.test.wrapper.ActualTrace)2 Channel (com.rabbitmq.client.Channel)2 Connection (com.rabbitmq.client.Connection)2 Constructor (java.lang.reflect.Constructor)2 MessageConsumerBuilder (com.navercorp.pinpoint.plugin.activemq.client.util.MessageConsumerBuilder)1 MessageProducerBuilder (com.navercorp.pinpoint.plugin.activemq.client.util.MessageProducerBuilder)1 MessageReceiveHandler (com.navercorp.test.pinpoint.plugin.activemq.MessageReceiveHandler)1 PollingMessageReceiver (com.navercorp.test.pinpoint.plugin.activemq.PollingMessageReceiver)1 TestConsumer (com.navercorp.test.pinpoint.plugin.rabbitmq.TestConsumer)1 TestMessagePuller (com.navercorp.test.pinpoint.plugin.rabbitmq.TestMessagePuller)1 InetSocketAddress (java.net.InetSocketAddress)1