Search in sources :

Example 11 with TSpanChunk

use of com.navercorp.pinpoint.thrift.dto.TSpanChunk in project pinpoint by naver.

the class ChunkHeaderBufferedTBaseSerializer method addTSpan.

// TSpan = TSpan + TSpanChunk
private void addTSpan(TBase<?, ?> base) throws TException {
    final TSpan span = (TSpan) base;
    if (span.getSpanEventList() == null) {
        write(base);
        return;
    }
    try {
        for (TSpanEvent e : span.getSpanEventList()) {
            eventStream.write(e);
        }
        write(span, FIELD_NAME_SPAN_EVENT_LIST, eventStream.split(chunkSize));
        while (!eventStream.isEmpty()) {
            final TSpanChunk spanChunk = toSpanChunk(span);
            write(spanChunk, FIELD_NAME_SPAN_EVENT_LIST, eventStream.split(chunkSize));
        }
    } finally {
        eventStream.clear();
    }
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent)

Example 12 with TSpanChunk

use of com.navercorp.pinpoint.thrift.dto.TSpanChunk in project pinpoint by naver.

the class ChunkHeaderBufferedTBaseSerializer method toSpanChunk.

TSpanChunk toSpanChunk(TSpan span) {
    // create TSpanChunk
    final TSpanChunk spanChunk = new TSpanChunk();
    spanChunk.setSpanEventList(span.getSpanEventList());
    spanChunk.setSpanEventListIsSet(true);
    spanChunk.setAgentId(span.getAgentId());
    spanChunk.setAgentIdIsSet(true);
    spanChunk.setApplicationName(span.getApplicationName());
    spanChunk.setApplicationNameIsSet(true);
    spanChunk.setAgentStartTime(span.getStartTime());
    spanChunk.setAgentStartTimeIsSet(true);
    spanChunk.setTransactionId(span.getTransactionId());
    spanChunk.setTransactionIdIsSet(true);
    spanChunk.setSpanId(span.getSpanId());
    spanChunk.setSpanIdIsSet(true);
    spanChunk.setEndPoint(span.getEndPoint());
    spanChunk.setEndPointIsSet(true);
    return spanChunk;
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk)

Example 13 with TSpanChunk

use of com.navercorp.pinpoint.thrift.dto.TSpanChunk in project pinpoint by naver.

the class SpanThriftMessageConverter method buildTSpanChunk.

@VisibleForTesting
TSpanChunk buildTSpanChunk(SpanChunk spanChunk) {
    final TSpanChunk tSpanChunk = new TSpanChunk();
    tSpanChunk.setApplicationName(applicationName);
    tSpanChunk.setAgentId(agentId);
    tSpanChunk.setAgentStartTime(agentStartTime);
    tSpanChunk.setApplicationServiceType(applicationServiceType);
    final TraceRoot traceRoot = spanChunk.getTraceRoot();
    final TraceId traceId = traceRoot.getTraceId();
    final ByteBuffer transactionId = transactionIdEncoder.encodeTransactionId(traceId);
    tSpanChunk.setTransactionId(transactionId);
    tSpanChunk.setSpanId(traceId.getSpanId());
    final Shared shared = traceRoot.getShared();
    tSpanChunk.setEndPoint(shared.getEndPoint());
    if (spanChunk instanceof AsyncSpanChunk) {
        final AsyncSpanChunk asyncSpanChunk = (AsyncSpanChunk) spanChunk;
        final LocalAsyncId localAsyncId = asyncSpanChunk.getLocalAsyncId();
        final TLocalAsyncId tLocalAsyncId = new TLocalAsyncId(localAsyncId.getAsyncId(), localAsyncId.getSequence());
        tSpanChunk.setLocalAsyncId(tLocalAsyncId);
    }
    spanPostProcessor.preProcess(spanChunk, tSpanChunk);
    final List<SpanEvent> spanEventList = spanChunk.getSpanEventList();
    if (CollectionUtils.hasLength(spanEventList)) {
        final List<TSpanEvent> tSpanEvents = buildTSpanEventList(spanEventList);
        tSpanChunk.setSpanEventList(tSpanEvents);
    }
    spanPostProcessor.postProcess(spanChunk, tSpanChunk);
    return tSpanChunk;
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) AsyncSpanChunk(com.navercorp.pinpoint.profiler.context.AsyncSpanChunk) TLocalAsyncId(com.navercorp.pinpoint.thrift.dto.TLocalAsyncId) LocalAsyncId(com.navercorp.pinpoint.profiler.context.LocalAsyncId) TLocalAsyncId(com.navercorp.pinpoint.thrift.dto.TLocalAsyncId) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) Shared(com.navercorp.pinpoint.profiler.context.id.Shared) ByteBuffer(java.nio.ByteBuffer) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Example 14 with TSpanChunk

use of com.navercorp.pinpoint.thrift.dto.TSpanChunk in project pinpoint by naver.

the class ThriftModule method configure.

@Override
protected void configure() {
    logger.info("configure {}", this.getClass().getSimpleName());
    ThriftTransportConfig thriftTransportConfig = loadThriftTransportConfig();
    bind(ThriftTransportConfig.class).toInstance(thriftTransportConfig);
    bind(TransactionIdEncoder.class).to(DefaultTransactionIdEncoder.class).in(Scopes.SINGLETON);
    Key<CommandDispatcher> commandDispatcher = Key.get(CommandDispatcher.class);
    bind(commandDispatcher).toProvider(CommandDispatcherProvider.class).in(Scopes.SINGLETON);
    // expose(commandDispatcher);
    TypeLiteral<SpanProcessor<TSpan, TSpanChunk>> spanPostProcessorType = new TypeLiteral<SpanProcessor<TSpan, TSpanChunk>>() {
    };
    bind(spanPostProcessorType).toProvider(SpanProcessorProvider.class).in(Scopes.SINGLETON);
    bind(ConnectionFactoryProvider.class).toProvider(ConnectionFactoryProviderProvider.class).in(Scopes.SINGLETON);
    Key<PinpointClientFactory> pinpointClientFactory = Key.get(PinpointClientFactory.class, DefaultClientFactory.class);
    bind(pinpointClientFactory).toProvider(PinpointClientFactoryProvider.class).in(Scopes.SINGLETON);
    // expose(pinpointClientFactory);
    bind(HeaderTBaseSerializer.class).toProvider(HeaderTBaseSerializerProvider.class).in(Scopes.SINGLETON);
    // EnhancedDataSender
    TypeLiteral<EnhancedDataSender<MetaDataType>> dataSenderTypeLiteral = new TypeLiteral<EnhancedDataSender<MetaDataType>>() {
    };
    bind(dataSenderTypeLiteral).toProvider(TcpDataSenderProvider.class).in(Scopes.SINGLETON);
    expose(dataSenderTypeLiteral);
    // Bind AgentDataSender to EnhancedDataSender
    Key<EnhancedDataSender<MetaDataType>> agentDataSender = Key.get(dataSenderTypeLiteral, AgentDataSender.class);
    bind(agentDataSender).to(dataSenderTypeLiteral).in(Scopes.SINGLETON);
    expose(agentDataSender);
    // Bind MetadataDataSender to EnhancedDataSender
    Key<EnhancedDataSender<MetaDataType>> metadataDataSender = Key.get(dataSenderTypeLiteral, MetadataDataSender.class);
    bind(metadataDataSender).to(dataSenderTypeLiteral).in(Scopes.SINGLETON);
    expose(metadataDataSender);
    Key<Timer> spanStatConnectTimer = Key.get(Timer.class, SpanStatChannelFactory.class);
    bind(spanStatConnectTimer).toProvider(SpanStatConnectTimerProvider.class).in(Scopes.SINGLETON);
    Key<ChannelFactory> spanStatChannelFactory = Key.get(ChannelFactory.class, SpanStatChannelFactory.class);
    bind(spanStatChannelFactory).toProvider(SpanStatChannelFactoryProvider.class).in(Scopes.SINGLETON);
    Key<PinpointClientFactory> spanClientFactory = Key.get(PinpointClientFactory.class, SpanDataSender.class);
    bind(spanClientFactory).toProvider(SpanClientFactoryProvider.class).in(Scopes.SINGLETON);
    Key<PinpointClientFactory> statClientFactory = Key.get(PinpointClientFactory.class, StatDataSender.class);
    bind(statClientFactory).toProvider(StatClientFactoryProvider.class).in(Scopes.SINGLETON);
    TypeLiteral<MessageConverter<SpanType, TBase<?, ?>>> thriftMessageConverter = new TypeLiteral<MessageConverter<SpanType, TBase<?, ?>>>() {
    };
    Key<MessageConverter<SpanType, TBase<?, ?>>> spanMessageConverterKey = Key.get(thriftMessageConverter, SpanDataSender.class);
    bind(spanMessageConverterKey).toProvider(SpanThriftMessageConverterProvider.class).in(Scopes.SINGLETON);
    // expose(spanMessageConverterKey);
    TypeLiteral<MessageConverter<MetaDataType, TBase<?, ?>>> metadataMessageConverter = new TypeLiteral<MessageConverter<MetaDataType, TBase<?, ?>>>() {
    };
    Key<MessageConverter<MetaDataType, TBase<?, ?>>> metadataMessageConverterKey = Key.get(metadataMessageConverter, MetadataDataSender.class);
    bind(metadataMessageConverterKey).toProvider(MetadataMessageConverterProvider.class).in(Scopes.SINGLETON);
    // expose(metadataMessageConverterKey);
    // Stat Thrift Converter
    TypeLiteral<MessageConverter<MetricType, TBase<?, ?>>> statMessageConverter = new TypeLiteral<MessageConverter<MetricType, TBase<?, ?>>>() {
    };
    Key<MessageConverter<MetricType, TBase<?, ?>>> statMessageConverterKey = Key.get(statMessageConverter, StatDataSender.class);
    bind(statMessageConverterKey).toProvider(StatThriftMessageConverterProvider.class).in(Scopes.SINGLETON);
    TypeLiteral<DataSender<SpanType>> spanDataSenderType = new TypeLiteral<DataSender<SpanType>>() {
    };
    Key<DataSender<SpanType>> spanDataSender = Key.get(spanDataSenderType, SpanDataSender.class);
    bind(spanDataSender).toProvider(SpanDataSenderProvider.class).in(Scopes.SINGLETON);
    expose(spanDataSender);
    TypeLiteral<DataSender<MetricType>> statDataSenderType = new TypeLiteral<DataSender<MetricType>>() {
    };
    Key<DataSender<MetricType>> statDataSender = Key.get(statDataSenderType, StatDataSender.class);
    bind(statDataSender).toProvider(StatDataSenderProvider.class).in(Scopes.SINGLETON);
    expose(statDataSender);
    // For AgentInfoSender
    // TypeLiteral<AgentInfoFactory> agentInfoFactoryTypeLiteral = new TypeLiteral<AgentInfoFactory>() {};
    // bind(agentInfoFactoryTypeLiteral).toProvider(AgentInfoFactoryProvider.class).in(Scopes.SINGLETON);
    // expose(agentInfoFactoryTypeLiteral);
    TypeLiteral<MessageConverter<Object, ResultResponse>> resultMessageConverter = new TypeLiteral<MessageConverter<Object, ResultResponse>>() {
    };
    Key<MessageConverter<Object, ResultResponse>> resultMessageConverterKey = Key.get(resultMessageConverter, ResultConverter.class);
    bind(resultMessageConverterKey).toProvider(ThriftMessageToResultConverterProvider.class).in(Scopes.SINGLETON);
    expose(resultMessageConverterKey);
    Key<ModuleLifeCycle> rpcModuleLifeCycleKey = Key.get(ModuleLifeCycle.class, Names.named("RPC-MODULE"));
    bind(rpcModuleLifeCycleKey).to(ThriftModuleLifeCycle.class).in(Scopes.SINGLETON);
    expose(rpcModuleLifeCycleKey);
}
Also used : MetadataMessageConverterProvider(com.navercorp.pinpoint.profiler.context.provider.thrift.MetadataMessageConverterProvider) ResultResponse(com.navercorp.pinpoint.profiler.sender.ResultResponse) DefaultTransactionIdEncoder(com.navercorp.pinpoint.profiler.context.thrift.DefaultTransactionIdEncoder) PinpointClientFactoryProvider(com.navercorp.pinpoint.profiler.context.provider.thrift.PinpointClientFactoryProvider) EnhancedDataSender(com.navercorp.pinpoint.profiler.sender.EnhancedDataSender) DataSender(com.navercorp.pinpoint.profiler.sender.DataSender) EnhancedDataSender(com.navercorp.pinpoint.profiler.sender.EnhancedDataSender) ConnectionFactoryProviderProvider(com.navercorp.pinpoint.profiler.context.provider.thrift.ConnectionFactoryProviderProvider) SpanThriftMessageConverterProvider(com.navercorp.pinpoint.profiler.context.thrift.SpanThriftMessageConverterProvider) CommandDispatcherProvider(com.navercorp.pinpoint.profiler.context.provider.CommandDispatcherProvider) MetaDataType(com.navercorp.pinpoint.profiler.metadata.MetaDataType) SpanStatChannelFactoryProvider(com.navercorp.pinpoint.profiler.context.provider.thrift.SpanStatChannelFactoryProvider) ChannelFactory(org.jboss.netty.channel.ChannelFactory) MessageConverter(com.navercorp.pinpoint.profiler.context.thrift.MessageConverter) SpanType(com.navercorp.pinpoint.profiler.context.SpanType) HeaderTBaseSerializerProvider(com.navercorp.pinpoint.profiler.context.provider.thrift.HeaderTBaseSerializerProvider) StatClientFactoryProvider(com.navercorp.pinpoint.profiler.context.provider.thrift.StatClientFactoryProvider) ThriftMessageToResultConverterProvider(com.navercorp.pinpoint.profiler.context.thrift.ThriftMessageToResultConverterProvider) DefaultThriftTransportConfig(com.navercorp.pinpoint.profiler.context.thrift.config.DefaultThriftTransportConfig) ThriftTransportConfig(com.navercorp.pinpoint.profiler.context.thrift.config.ThriftTransportConfig) StatThriftMessageConverterProvider(com.navercorp.pinpoint.profiler.context.thrift.StatThriftMessageConverterProvider) SpanDataSenderProvider(com.navercorp.pinpoint.profiler.context.provider.thrift.SpanDataSenderProvider) MetricType(com.navercorp.pinpoint.profiler.monitor.metric.MetricType) SpanStatConnectTimerProvider(com.navercorp.pinpoint.profiler.context.provider.thrift.SpanStatConnectTimerProvider) TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) TcpDataSenderProvider(com.navercorp.pinpoint.profiler.context.provider.thrift.TcpDataSenderProvider) SpanProcessor(com.navercorp.pinpoint.profiler.context.compress.SpanProcessor) SpanClientFactoryProvider(com.navercorp.pinpoint.profiler.context.provider.thrift.SpanClientFactoryProvider) TypeLiteral(com.google.inject.TypeLiteral) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) CommandDispatcher(com.navercorp.pinpoint.profiler.receiver.CommandDispatcher) StatDataSenderProvider(com.navercorp.pinpoint.profiler.context.provider.thrift.StatDataSenderProvider) Timer(org.jboss.netty.util.Timer) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) SpanProcessorProvider(com.navercorp.pinpoint.profiler.context.provider.thrift.SpanProcessorProvider) TBase(org.apache.thrift.TBase)

Example 15 with TSpanChunk

use of com.navercorp.pinpoint.thrift.dto.TSpanChunk in project pinpoint by naver.

the class SpanPostProcessorTest method postProcess1.

@Test
public void postProcess1() {
    SpanProcessor<TSpan, TSpanChunk> spanChunkPostProcessor = new SpanProcessorV1();
    TraceRoot internalTraceId = newInternalTraceId();
    TSpanChunk tSpanChunk = new TSpanChunk();
    try {
        SpanChunk spanChunk = new DefaultSpanChunk(internalTraceId, new ArrayList<SpanEvent>());
        spanChunkPostProcessor.postProcess(spanChunk, tSpanChunk);
        Assert.fail();
    } catch (Exception ignored) {
    }
}
Also used : TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) DefaultSpanChunk(com.navercorp.pinpoint.profiler.context.DefaultSpanChunk) SpanChunk(com.navercorp.pinpoint.profiler.context.SpanChunk) TSpanChunk(com.navercorp.pinpoint.thrift.dto.TSpanChunk) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) DefaultSpanChunk(com.navercorp.pinpoint.profiler.context.DefaultSpanChunk) Test(org.junit.Test)

Aggregations

TSpanChunk (com.navercorp.pinpoint.thrift.dto.TSpanChunk)26 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)14 Test (org.junit.Test)13 TSpan (com.navercorp.pinpoint.thrift.dto.TSpan)5 SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)4 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)4 DefaultSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultSpanChunk)3 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)3 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)3 LocalAsyncIdBo (com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo)2 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)2 ArrayList (java.util.ArrayList)2 TBase (org.apache.thrift.TBase)2 TypeLiteral (com.google.inject.TypeLiteral)1 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)1 VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)1 Message (com.navercorp.pinpoint.io.request.Message)1 AsyncSpanChunk (com.navercorp.pinpoint.profiler.context.AsyncSpanChunk)1 LocalAsyncId (com.navercorp.pinpoint.profiler.context.LocalAsyncId)1 SpanType (com.navercorp.pinpoint.profiler.context.SpanType)1