use of com.navercorp.pinpoint.profiler.monitor.metric.MetricType 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);
}
use of com.navercorp.pinpoint.profiler.monitor.metric.MetricType 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);
}
use of com.navercorp.pinpoint.profiler.monitor.metric.MetricType in project pinpoint by naver.
the class CollectJobTest method run.
@Test
public void run() throws Exception {
AgentStatMetricCollector<AgentStatMetricSnapshot> agentStatMetricCollector = mockAgentStatMetricCollector();
Mockito.when(agentStatMetricCollector.collect()).thenReturn(new AgentStatMetricSnapshot());
DataSender<MetricType> dataSender = mock(DataSender.class);
CollectJob job = new CollectJob(dataSender, "agent", 0, agentStatMetricCollector, 1);
job.run();
Mockito.verify(dataSender).send(any(AgentStatMetricSnapshotBatch.class));
}
use of com.navercorp.pinpoint.profiler.monitor.metric.MetricType in project pinpoint by naver.
the class AgentStatMonitorTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(agentStatCollector.collect()).thenReturn(new AgentStatMetricSnapshot());
this.tBaseRecorder = new TBaseRecorder<>();
ListenableDataSender.Listener<? extends MetricType> recorderAdaptor = new TBaseRecorderAdaptor<>(tBaseRecorder);
ListenableDataSender<MetricType> listenableDataSender = new ListenableDataSender<>("testDataSender");
listenableDataSender.setListener((ListenableDataSender.Listener<MetricType>) recorderAdaptor);
this.dataSender = listenableDataSender;
}
use of com.navercorp.pinpoint.profiler.monitor.metric.MetricType in project pinpoint by naver.
the class StatDataSenderProvider method get.
@Override
public DataSender<MetricType> get() {
if ("TCP".equalsIgnoreCase(transportType)) {
if ("OIO".equalsIgnoreCase(ioType)) {
logger.warn("TCP transport not support OIO type.(only support NIO)");
}
PinpointClientFactory pinpointClientFactory = clientFactoryProvider.get();
MessageSerializer<MetricType, byte[]> messageSerializer = new ThriftMessageSerializer<>(messageConverter);
return new TcpDataSender<>("StatDataSender", ip, port, pinpointClientFactory, messageSerializer, writeQueueSize);
} else {
UdpDataSenderFactory<MetricType> factory = new UdpDataSenderFactory<>(ip, port, UDP_EXECUTOR_NAME, writeQueueSize, timeout, sendBufferSize, messageConverter);
return factory.create(ioType);
}
}
Aggregations