Search in sources :

Example 6 with SpanRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanRecorder in project pinpoint by naver.

the class TProtocolReadMessageEndInterceptor method recordRootSpan.

private void recordRootSpan(final Trace trace, final ThriftRequestProperty parentTraceInfo, Object target) {
    // begin root span
    SpanRecorder recorder = trace.getSpanRecorder();
    recorder.recordServiceType(ThriftConstants.THRIFT_SERVER);
    recorder.recordApi(this.thriftServerEntryMethodDescriptor);
    if (!trace.isRoot()) {
        recordParentInfo(recorder, parentTraceInfo);
    }
    // record connection information here as the socket may be closed by the time the Span is popped in
    // TBaseAsyncProcessorProcessInterceptor's after section.
    TTransport transport = ((TProtocol) target).getTransport();
    recordConnection(recorder, transport);
}
Also used : SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) TProtocol(org.apache.thrift.protocol.TProtocol) TTransport(org.apache.thrift.transport.TTransport)

Example 7 with SpanRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanRecorder in project pinpoint by naver.

the class DefaultSpanRecorderTest method testRecordApiId.

@Test
public void testRecordApiId() throws Exception {
    Span span = new Span(traceRoot);
    SpanRecorder recorder = new DefaultSpanRecorder(span, true, true, stringMetaDataService, sqlMetaDataService, errorHandler);
    final int API_ID = 1000;
    recorder.recordApiId(API_ID);
    Assert.assertEquals("API ID", span.getApiId(), API_ID);
}
Also used : SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) Span(com.navercorp.pinpoint.profiler.context.Span) Test(org.junit.Test)

Example 8 with SpanRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanRecorder in project pinpoint by naver.

the class DefaultSpanRecorderTest method testRecordEndPoint.

@Test
public void testRecordEndPoint() throws Exception {
    when(traceRoot.getShared()).thenReturn(shared);
    Span span = new Span(traceRoot);
    SpanRecorder recorder = new DefaultSpanRecorder(span, true, true, stringMetaDataService, sqlMetaDataService, errorHandler);
    final String endPoint = "endPoint";
    recorder.recordEndPoint(endPoint);
    verify(traceRoot.getShared()).setEndPoint(endPoint);
}
Also used : SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) Span(com.navercorp.pinpoint.profiler.context.Span) Test(org.junit.Test)

Example 9 with SpanRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanRecorder in project pinpoint by naver.

the class RabbitMQConsumerHandleCompleteInboundCommandInterceptor method createTrace.

private Trace createTrace(AMQChannel amqChannel, AMQCommand amqCommand) {
    AMQConnection connection = amqChannel.getConnection();
    if (connection == null) {
        logger.debug("connection is null, skipping trace");
    }
    Method method = amqCommand.getMethod();
    AMQP.Basic.GetOk getOk = (AMQP.Basic.GetOk) method;
    String exchange = getOk.getExchange();
    if (RabbitMQClientPluginConfig.isExchangeExcluded(exchange, excludeExchangeFilter)) {
        if (isDebug) {
            logger.debug("exchange {} is excluded", exchange);
        }
        return null;
    }
    String routingKey = getOk.getRoutingKey();
    Map<String, Object> headers = getHeadersFromContentHeader(amqCommand.getContentHeader());
    // If this transaction is not traceable, mark as disabled.
    if (headers.get(RabbitMQClientConstants.META_SAMPLED) != null) {
        return traceContext.disableSampling();
    }
    final TraceId traceId = populateTraceIdFromRequest(headers);
    // If there's no trasanction id, a new trasaction begins here.
    final Trace trace = traceId == null ? traceContext.newTraceObject() : traceContext.continueTraceObject(traceId);
    if (trace.canSampled()) {
        final SpanRecorder recorder = trace.getSpanRecorder();
        recordRootSpan(recorder, connection, exchange, routingKey, headers);
    }
    return trace;
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) AMQConnection(com.rabbitmq.client.impl.AMQConnection) AMQP(com.rabbitmq.client.AMQP) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) Method(com.rabbitmq.client.impl.Method)

Example 10 with SpanRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanRecorder in project pinpoint by naver.

the class RabbitMQConsumerDispatchInterceptor method createTrace.

private Trace createTrace(Object target, Object[] args) {
    final Channel channel = ((ChannelGetter) target)._$PINPOINT$_getChannel();
    if (channel == null) {
        logger.debug("channel is null, skipping trace");
        return null;
    }
    final Connection connection = channel.getConnection();
    if (connection == null) {
        logger.debug("connection is null, skipping trace");
        return null;
    }
    Envelope envelope = ArrayArgumentUtils.getArgument(args, 2, Envelope.class);
    String exchange = envelope.getExchange();
    if (RabbitMQClientPluginConfig.isExchangeExcluded(exchange, excludeExchangeFilter)) {
        if (isDebug) {
            logger.debug("exchange {} is excluded", exchange);
        }
        return null;
    }
    // args[3] may be null
    AMQP.BasicProperties properties = (AMQP.BasicProperties) args[3];
    Map<String, Object> headers = getHeadersFromBasicProperties(properties);
    // If this transaction is not traceable, mark as disabled.
    if (headers.get(RabbitMQClientConstants.META_SAMPLED) != null) {
        return traceContext.disableSampling();
    }
    final TraceId traceId = populateTraceIdFromRequest(headers);
    // If there's no trasanction id, a new trasaction begins here.
    final Trace trace = traceId == null ? traceContext.newTraceObject() : traceContext.continueTraceObject(traceId);
    if (trace.canSampled()) {
        final SpanRecorder recorder = trace.getSpanRecorder();
        recordRootSpan(recorder, connection, envelope, headers);
    }
    return trace;
}
Also used : Channel(com.rabbitmq.client.Channel) Connection(com.rabbitmq.client.Connection) AMQConnection(com.rabbitmq.client.impl.AMQConnection) Envelope(com.rabbitmq.client.Envelope) Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanRecorder(com.navercorp.pinpoint.bootstrap.context.SpanRecorder) AMQP(com.rabbitmq.client.AMQP) ChannelGetter(com.navercorp.pinpoint.plugin.rabbitmq.client.field.getter.ChannelGetter) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId)

Aggregations

SpanRecorder (com.navercorp.pinpoint.bootstrap.context.SpanRecorder)38 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)23 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)10 Test (org.junit.Test)10 WrappedSpanEventRecorder (com.navercorp.pinpoint.profiler.context.recorder.WrappedSpanEventRecorder)8 Storage (com.navercorp.pinpoint.profiler.context.storage.Storage)8 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)6 TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)4 TraceSampler (com.navercorp.pinpoint.bootstrap.sampler.TraceSampler)4 ActiveTraceHandle (com.navercorp.pinpoint.profiler.context.active.ActiveTraceHandle)4 DefaultSpanRecorder (com.navercorp.pinpoint.profiler.context.recorder.DefaultSpanRecorder)4 Span (com.navercorp.pinpoint.profiler.context.Span)3 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)3 AsyncState (com.navercorp.pinpoint.bootstrap.context.AsyncState)2 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)2 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)2 ListenableAsyncState (com.navercorp.pinpoint.profiler.context.id.ListenableAsyncState)2 AMQP (com.rabbitmq.client.AMQP)2 AMQConnection (com.rabbitmq.client.impl.AMQConnection)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2