Search in sources :

Example 1 with Span

use of com.megaease.easeagent.plugin.api.trace.Span in project easeagent by megaease.

the class MessagingTracingImplTest method producerExtractor.

@Test
public void producerExtractor() {
    Span span = messagingTracing.producerSpan(new MessagingRequestMock().setOperation(operation).setChannelKind(channelKind).setChannelName(channelName));
    MessagingRequestMock messagingRequestMock = new MessagingRequestMock();
    messagingTracing.producerInjector().inject(span, messagingRequestMock);
    Message message = messagingTracing.producerExtractor().extract(messagingRequestMock);
    check(span, message);
    Span span2 = messagingTracing.consumerSpan(new MessagingRequestMock().setOperation(operation).setChannelKind(channelKind).setChannelName(channelName));
    MessagingRequestMock messagingRequestMock2 = new MessagingRequestMock();
    messagingTracing.consumerInjector().inject(span2, messagingRequestMock2);
    Message message2 = messagingTracing.consumerExtractor().extract(messagingRequestMock2);
    check(span2, message2);
}
Also used : Message(com.megaease.easeagent.plugin.api.trace.Message) Span(com.megaease.easeagent.plugin.api.trace.Span) MutableSpan(brave.handler.MutableSpan) MessagingRequestMock(com.megaease.easeagent.zipkin.impl.MessagingRequestMock) Test(org.junit.Test)

Example 2 with Span

use of com.megaease.easeagent.plugin.api.trace.Span in project easeagent by megaease.

the class MessagingTracingImplTest method consumerSpan.

@Test
public void consumerSpan() {
    Span span = messagingTracing.consumerSpan(new MessagingRequestMock().setOperation(operation).setChannelKind(channelKind).setChannelName(channelName));
    assertFalse(span.isNoop());
    MutableSpan state = AgentFieldReflectAccessor.getFieldValue(span.unwrap(), "state");
    assertNotNull(state);
    checkTag(state);
    span = messagingTracing.producerSpan(new MessagingRequestMock().setOperation(operation).setChannelKind(channelKind).setChannelName(channelName));
    MessagingRequestMock messagingRequestMock = new MessagingRequestMock();
    messagingTracing.producerInjector().inject(span, messagingRequestMock);
    MessagingRequestMock request1 = new MessagingRequestMock();
    request1.setHeaders(messagingRequestMock.getHeaders());
    Span newSpan1 = messagingTracing.consumerSpan(request1);
    assertEquals(span.traceIdString(), newSpan1.traceIdString());
    assertNotEquals(span.spanIdString(), newSpan1.spanIdString());
    MessagingRequestMock request2 = new MessagingRequestMock();
    request2.setHeaders(messagingRequestMock.getHeaders());
    Span newSpan2 = messagingTracing.consumerSpan(request1);
    assertEquals(span.traceIdString(), newSpan2.traceIdString());
    assertNotEquals(span.spanIdString(), newSpan2.spanIdString());
    assertNotEquals(newSpan1.spanIdString(), newSpan2.spanIdString());
}
Also used : MutableSpan(brave.handler.MutableSpan) Span(com.megaease.easeagent.plugin.api.trace.Span) MutableSpan(brave.handler.MutableSpan) MessagingRequestMock(com.megaease.easeagent.zipkin.impl.MessagingRequestMock) Test(org.junit.Test)

Example 3 with Span

use of com.megaease.easeagent.plugin.api.trace.Span in project easeagent by megaease.

the class MessagingTracingImplTest method consumerSampler.

@Test
public void consumerSampler() {
    Span span = messagingTracing.consumerSpan(new MessagingRequestMock().setOperation(operation).setChannelKind(channelKind).setChannelName(channelName));
    MessagingRequestMock messagingRequestMock = new MessagingRequestMock();
    messagingTracing.consumerInjector().inject(span, messagingRequestMock);
    assertNull(messagingTracing.consumerSampler().apply(messagingRequestMock));
}
Also used : Span(com.megaease.easeagent.plugin.api.trace.Span) MutableSpan(brave.handler.MutableSpan) MessagingRequestMock(com.megaease.easeagent.zipkin.impl.MessagingRequestMock) Test(org.junit.Test)

Example 4 with Span

use of com.megaease.easeagent.plugin.api.trace.Span in project easeagent by megaease.

the class MessagingTracingImplTest method consumerInjector.

@Test
public void consumerInjector() {
    Span span = messagingTracing.consumerSpan(new MessagingRequestMock().setOperation(operation).setChannelKind(channelKind).setChannelName(channelName));
    MessagingRequestMock messagingRequestMock = new MessagingRequestMock();
    messagingTracing.consumerInjector().inject(span, messagingRequestMock);
    assertTrue(messagingRequestMock.getHeaders().size() > 0);
    assertEquals(1, messagingRequestMock.getHeaders().size());
    assertNotNull(messagingRequestMock.header(MESSAGE_B3_HEADER_NAME));
    assertTrue(messagingRequestMock.header(MESSAGE_B3_HEADER_NAME).contains(span.traceIdString()));
}
Also used : Span(com.megaease.easeagent.plugin.api.trace.Span) MutableSpan(brave.handler.MutableSpan) MessagingRequestMock(com.megaease.easeagent.zipkin.impl.MessagingRequestMock) Test(org.junit.Test)

Example 5 with Span

use of com.megaease.easeagent.plugin.api.trace.Span in project easeagent by megaease.

the class MessagingTracingImplTest method consumerExtractor.

@Test
public void consumerExtractor() {
    Span span = messagingTracing.consumerSpan(new MessagingRequestMock().setOperation(operation).setChannelKind(channelKind).setChannelName(channelName));
    MessagingRequestMock messagingRequestMock = new MessagingRequestMock();
    messagingTracing.consumerInjector().inject(span, messagingRequestMock);
    Message message = messagingTracing.consumerExtractor().extract(messagingRequestMock);
    check(span, message);
}
Also used : Message(com.megaease.easeagent.plugin.api.trace.Message) Span(com.megaease.easeagent.plugin.api.trace.Span) MutableSpan(brave.handler.MutableSpan) MessagingRequestMock(com.megaease.easeagent.zipkin.impl.MessagingRequestMock) Test(org.junit.Test)

Aggregations

Span (com.megaease.easeagent.plugin.api.trace.Span)87 Test (org.junit.Test)58 ReportSpan (com.megaease.easeagent.plugin.report.tracing.ReportSpan)44 Context (com.megaease.easeagent.plugin.api.Context)31 MutableSpan (brave.handler.MutableSpan)23 MethodInfo (com.megaease.easeagent.plugin.interceptor.MethodInfo)22 Scope (com.megaease.easeagent.plugin.api.trace.Scope)21 MessagingRequestMock (com.megaease.easeagent.zipkin.impl.MessagingRequestMock)8 RequestContext (com.megaease.easeagent.plugin.api.context.RequestContext)6 AMQP (com.rabbitmq.client.AMQP)4 MockEaseAgent (com.megaease.easeagent.mock.plugin.api.MockEaseAgent)2 EaseAgentJunit4ClassRunner (com.megaease.easeagent.mock.plugin.api.junit.EaseAgentJunit4ClassRunner)2 Message (com.megaease.easeagent.plugin.api.trace.Message)2 MessagingRequest (com.megaease.easeagent.plugin.api.trace.MessagingRequest)2 EaseAgent (com.megaease.easeagent.plugin.bridge.EaseAgent)2 JdbcTracingPlugin (com.megaease.easeagent.plugin.jdbc.JdbcTracingPlugin)2 SqlInfo (com.megaease.easeagent.plugin.jdbc.common.SqlInfo)2 RequestInfo (com.megaease.easeagent.plugin.tools.metrics.RequestInfo)2 HttpRequest (com.megaease.easeagent.plugin.tools.trace.HttpRequest)2 Envelope (com.rabbitmq.client.Envelope)2