Search in sources :

Example 1 with SpanType

use of com.navercorp.pinpoint.profiler.context.SpanType 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 2 with SpanType

use of com.navercorp.pinpoint.profiler.context.SpanType in project pinpoint by naver.

the class OrderedSpanRecorderTest method testOrderingWithSameEventTime.

@Test
public void testOrderingWithSameEventTime() {
    // given
    final long startTime = 100;
    final long spanId = 1L;
    TraceId traceId = new DefaultTraceId(agentId, startTime, 0, -1L, spanId, (short) 0);
    final TraceRoot traceRoot = new DefaultTraceRoot(traceId, agentId, startTime, 0);
    Span span = createSpan(traceRoot, startTime);
    SpanChunk event = wrapSpanChunk(traceRoot, createSpanEvent(traceRoot, 0, 0));
    SpanChunk event1 = wrapSpanChunk(traceRoot, createSpanEvent(traceRoot, 0, 1));
    SpanChunk event2 = wrapSpanChunk(traceRoot, createSpanEvent(traceRoot, 0, 2));
    SpanChunk asyncEvent1_1 = wrapSpanChunk(traceRoot, createAsyncSpanEvent(traceRoot, 0, 0), new DefaultLocalAsyncId(1, (short) 1));
    SpanChunk asyncEvent1_2 = wrapSpanChunk(traceRoot, createAsyncSpanEvent(traceRoot, 0, 1), new DefaultLocalAsyncId(1, (short) 1));
    SpanChunk asyncEvent2 = wrapSpanChunk(traceRoot, createAsyncSpanEvent(traceRoot, 0, 0), new DefaultLocalAsyncId(2, (short) 1));
    final List<SpanType> expectedOrder = Arrays.asList(span, event, event1, event2, asyncEvent1_1, asyncEvent1_2, asyncEvent2);
    // when
    final List<SpanType> listToBeHandled = Arrays.asList(span, event, event1, event2, asyncEvent1_1, asyncEvent1_2, asyncEvent2);
    Collections.shuffle(listToBeHandled);
    for (SpanType base : listToBeHandled) {
        this.recorder.handleSend(base);
    }
    // then
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    this.recorder.print(new PrintStream(baos));
    this.logger.debug(baos.toString());
    for (SpanType expectedBase : expectedOrder) {
        SpanType actualBase = this.recorder.pop();
        assertSame(expectedBase, actualBase);
    }
    assertNull(this.recorder.pop());
}
Also used : PrintStream(java.io.PrintStream) SpanType(com.navercorp.pinpoint.profiler.context.SpanType) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) DefaultSpanChunk(com.navercorp.pinpoint.profiler.context.DefaultSpanChunk) SpanChunk(com.navercorp.pinpoint.profiler.context.SpanChunk) DefaultAsyncSpanChunk(com.navercorp.pinpoint.profiler.context.DefaultAsyncSpanChunk) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultLocalAsyncId(com.navercorp.pinpoint.profiler.context.DefaultLocalAsyncId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Span(com.navercorp.pinpoint.profiler.context.Span) Test(org.junit.Test)

Example 3 with SpanType

use of com.navercorp.pinpoint.profiler.context.SpanType in project pinpoint by naver.

the class OrderedSpanRecorderTest method testMultipleSpanOrdering.

@Test
public void testMultipleSpanOrdering() {
    // given
    final long startTime1 = 100;
    final long spanId1 = 1L;
    final TraceId traceId1 = new DefaultTraceId(agentId, startTime1, 0, -1L, spanId1, (short) 0);
    final TraceRoot traceRoot1 = new DefaultTraceRoot(traceId1, agentId, startTime1, 0);
    final long startTime2 = startTime1 + 10L;
    final long spanId2 = 2L;
    final TraceId traceId2 = new DefaultTraceId(agentId, startTime2, 0, -1L, spanId2, (short) 0);
    final TraceRoot traceRoot2 = new DefaultTraceRoot(traceId2, agentId, startTime2, 0);
    Span span1 = createSpan(traceRoot1, startTime1);
    SpanChunk event1_0 = wrapSpanChunk(traceRoot1, createSpanEvent(traceRoot1, 1, 0));
    SpanChunk event1_1 = wrapSpanChunk(traceRoot1, createSpanEvent(traceRoot1, 2, 1));
    SpanChunk asyncEvent1_0 = wrapSpanChunk(traceRoot1, createAsyncSpanEvent(traceRoot1, 1, 0), new DefaultLocalAsyncId(1, (short) 1));
    SpanChunk asyncEvent1_1 = wrapSpanChunk(traceRoot1, createAsyncSpanEvent(traceRoot1, 2, 1), new DefaultLocalAsyncId(1, (short) 1));
    Span span2 = createSpan(traceRoot2, startTime2);
    SpanChunk event2_0 = wrapSpanChunk(traceRoot2, createSpanEvent(traceRoot2, 0, 0));
    SpanChunk event2_1 = wrapSpanChunk(traceRoot2, createSpanEvent(traceRoot2, 1, 1));
    SpanChunk asyncEvent2_0 = wrapSpanChunk(traceRoot2, createAsyncSpanEvent(traceRoot2, 0, 0), new DefaultLocalAsyncId(2, (short) 1));
    final List<SpanType> expectedOrder = Arrays.asList(span1, event1_0, event1_1, span2, event2_0, event2_1, asyncEvent1_0, asyncEvent1_1, asyncEvent2_0);
    // when
    final List<SpanType> listToBeHandled = Arrays.asList(span1, event1_0, event1_1, span2, event2_0, event2_1, asyncEvent1_0, asyncEvent1_1, asyncEvent2_0);
    Collections.shuffle(listToBeHandled);
    for (SpanType base : listToBeHandled) {
        this.recorder.handleSend(base);
    }
    // then
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    this.recorder.print(new PrintStream(baos));
    this.logger.debug(baos.toString());
    for (SpanType expectedBase : expectedOrder) {
        SpanType actualBase = this.recorder.pop();
        assertSame(expectedBase, actualBase);
    }
    assertNull(this.recorder.pop());
}
Also used : PrintStream(java.io.PrintStream) SpanType(com.navercorp.pinpoint.profiler.context.SpanType) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) DefaultSpanChunk(com.navercorp.pinpoint.profiler.context.DefaultSpanChunk) SpanChunk(com.navercorp.pinpoint.profiler.context.SpanChunk) DefaultAsyncSpanChunk(com.navercorp.pinpoint.profiler.context.DefaultAsyncSpanChunk) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) DefaultTraceId(com.navercorp.pinpoint.profiler.context.id.DefaultTraceId) DefaultLocalAsyncId(com.navercorp.pinpoint.profiler.context.DefaultLocalAsyncId) DefaultTraceRoot(com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Span(com.navercorp.pinpoint.profiler.context.Span) Test(org.junit.Test)

Example 4 with SpanType

use of com.navercorp.pinpoint.profiler.context.SpanType in project pinpoint by naver.

the class OrderedSpanRecorder method insertSpan.

private void insertSpan(Span span) {
    long startTime = span.getStartTime();
    TraceRoot traceRoot = span.getTraceRoot();
    Item<SpanType> item = new Item<SpanType>(span, startTime, traceRoot, ROOT_SEQUENCE);
    insertItem(item);
}
Also used : SpanType(com.navercorp.pinpoint.profiler.context.SpanType) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot)

Example 5 with SpanType

use of com.navercorp.pinpoint.profiler.context.SpanType in project pinpoint by naver.

the class PluginApplicationContextModule method configure.

@Override
protected void configure() {
    logger.info("configure {}", this.getClass().getSimpleName());
    final DataSender<SpanType> spanDataSender = newUdpSpanDataSender();
    logger.debug("spanDataSender:{}", spanDataSender);
    TypeLiteral<DataSender<SpanType>> spanDataSenderType = new TypeLiteral<DataSender<SpanType>>() {
    };
    Key<DataSender<SpanType>> spanDataSenderKey = Key.get(spanDataSenderType, SpanDataSender.class);
    bind(spanDataSenderKey).toInstance(spanDataSender);
    final DataSender<MetricType> statDataSender = newUdpStatDataSender();
    logger.debug("statDataSender:{}", statDataSender);
    TypeLiteral<DataSender<MetricType>> statDataSenderType = new TypeLiteral<DataSender<MetricType>>() {
    };
    Key<DataSender<MetricType>> statDataSenderKey = Key.get(statDataSenderType, StatDataSender.class);
    bind(statDataSenderKey).toInstance(statDataSender);
    bind(StorageFactory.class).to(TestSpanStorageFactory.class);
    bind(PinpointClientFactory.class).toProvider(Providers.of((PinpointClientFactory) null));
    EnhancedDataSender<MetaDataType> enhancedDataSender = newTcpDataSender();
    logger.debug("enhancedDataSender:{}", enhancedDataSender);
    TypeLiteral<EnhancedDataSender<MetaDataType>> dataSenderTypeLiteral = new TypeLiteral<EnhancedDataSender<MetaDataType>>() {
    };
    bind(dataSenderTypeLiteral).toInstance(enhancedDataSender);
    ServerMetaDataRegistryService serverMetaDataRegistryService = newServerMetaDataRegistryService();
    bind(ServerMetaDataRegistryService.class).toInstance(serverMetaDataRegistryService);
    bind(ApiMetaDataService.class).toProvider(MockApiMetaDataServiceProvider.class).in(Scopes.SINGLETON);
}
Also used : SpanDataSender(com.navercorp.pinpoint.profiler.context.module.SpanDataSender) StatDataSender(com.navercorp.pinpoint.profiler.context.module.StatDataSender) EnhancedDataSender(com.navercorp.pinpoint.profiler.sender.EnhancedDataSender) DataSender(com.navercorp.pinpoint.profiler.sender.DataSender) MetricType(com.navercorp.pinpoint.profiler.monitor.metric.MetricType) EnhancedDataSender(com.navercorp.pinpoint.profiler.sender.EnhancedDataSender) SpanType(com.navercorp.pinpoint.profiler.context.SpanType) StorageFactory(com.navercorp.pinpoint.profiler.context.storage.StorageFactory) TypeLiteral(com.google.inject.TypeLiteral) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) MetaDataType(com.navercorp.pinpoint.profiler.metadata.MetaDataType) DefaultServerMetaDataRegistryService(com.navercorp.pinpoint.profiler.context.DefaultServerMetaDataRegistryService) ServerMetaDataRegistryService(com.navercorp.pinpoint.profiler.context.ServerMetaDataRegistryService)

Aggregations

SpanType (com.navercorp.pinpoint.profiler.context.SpanType)15 SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)5 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)5 Span (com.navercorp.pinpoint.profiler.context.Span)4 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)3 DefaultAsyncSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultAsyncSpanChunk)3 DefaultLocalAsyncId (com.navercorp.pinpoint.profiler.context.DefaultLocalAsyncId)3 DefaultSpanChunk (com.navercorp.pinpoint.profiler.context.DefaultSpanChunk)3 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)3 DefaultTraceId (com.navercorp.pinpoint.profiler.context.id.DefaultTraceId)3 DefaultTraceRoot (com.navercorp.pinpoint.profiler.context.id.DefaultTraceRoot)3 PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)3 ActualTrace (com.navercorp.pinpoint.test.wrapper.ActualTrace)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 PrintStream (java.io.PrintStream)3 Test (org.junit.Test)3 TypeLiteral (com.google.inject.TypeLiteral)2 ExpectedTrace (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace)2 ServerMetaDataRegistryService (com.navercorp.pinpoint.profiler.context.ServerMetaDataRegistryService)2 MetaDataType (com.navercorp.pinpoint.profiler.metadata.MetaDataType)2