use of org.apache.skywalking.oap.server.core.analysis.meter.MeterSystem in project incubator-skywalking by apache.
the class MeterProcessService method start.
public void start(List<MeterConfig> configs) {
final MeterSystem meterSystem = manager.find(CoreModule.NAME).provider().getService(MeterSystem.class);
this.metricConverts = configs.stream().map(c -> new MetricConvert(c, meterSystem)).collect(Collectors.toList());
}
use of org.apache.skywalking.oap.server.core.analysis.meter.MeterSystem in project incubator-skywalking by apache.
the class ZabbixMetricsTest method setupMetrics.
@Override
public void setupMetrics() throws Throwable {
moduleProvider = Mockito.mock(CoreModuleProvider.class);
moduleManager = Mockito.mock(ModuleManager.class);
// prepare the context
meterSystem = Mockito.spy(new MeterSystem(moduleManager));
Whitebox.setInternalState(MetricsStreamProcessor.class, "PROCESSOR", Mockito.spy(MetricsStreamProcessor.getInstance()));
doNothing().when(MetricsStreamProcessor.getInstance()).create(any(), (StreamDefinition) any(), any());
CoreModule coreModule = Mockito.spy(CoreModule.class);
Whitebox.setInternalState(coreModule, "loadedProvider", moduleProvider);
when(moduleManager.find(CoreModule.NAME)).thenReturn(coreModule);
when(moduleProvider.getService(MeterSystem.class)).thenReturn(meterSystem);
// prepare the meter functions
final HashMap<String, Class> map = Maps.newHashMap();
map.put("avg", AvgFunction.class);
map.put("avgLabeled", AvgLabeledFunction.class);
map.put("avgHistogram", AvgHistogramFunction.class);
map.put("avgHistogramPercentile", AvgHistogramPercentileFunction.class);
Whitebox.setInternalState(meterSystem, "functionRegister", map);
super.setupMetrics();
}
use of org.apache.skywalking.oap.server.core.analysis.meter.MeterSystem in project incubator-skywalking by apache.
the class MockCoreModuleProvider method prepare.
@Override
public void prepare() throws ServiceNotProvidedException, ModuleStartException {
this.registerServiceImplementation(NamingControl.class, new NamingControl(50, 50, 150, new EndpointNameGrouping()));
MockStreamAnnotationListener streamAnnotationListener = new MockStreamAnnotationListener(getManager());
annotationScan.registerListener(streamAnnotationListener);
AnnotationScan scopeScan = new AnnotationScan();
scopeScan.registerListener(new DefaultScopeDefine.Listener());
try {
scopeScan.scan();
} catch (Exception e) {
throw new ModuleStartException(e.getMessage(), e);
}
this.registerServiceImplementation(MeterSystem.class, new MeterSystem(getManager()));
CoreModuleConfig moduleConfig = new CoreModuleConfig();
this.registerServiceImplementation(ConfigService.class, new ConfigService(moduleConfig));
this.registerServiceImplementation(DownSamplingConfigService.class, new DownSamplingConfigService(Collections.emptyList()));
this.registerServiceImplementation(GRPCHandlerRegister.class, new MockGRPCHandlerRegister());
this.registerServiceImplementation(HTTPHandlerRegister.class, new MockHTTPHandlerRegister());
this.registerServiceImplementation(IComponentLibraryCatalogService.class, new MockComponentLibraryCatalogService());
this.registerServiceImplementation(SourceReceiver.class, new MockSourceReceiver());
MockWorkerInstancesService instancesService = new MockWorkerInstancesService();
this.registerServiceImplementation(IWorkerInstanceGetter.class, instancesService);
this.registerServiceImplementation(IWorkerInstanceSetter.class, instancesService);
this.registerServiceImplementation(RemoteSenderService.class, new RemoteSenderService(getManager()));
this.registerServiceImplementation(ModelCreator.class, storageModels);
this.registerServiceImplementation(IModelManager.class, storageModels);
this.registerServiceImplementation(ModelManipulator.class, storageModels);
this.registerServiceImplementation(NetworkAddressAliasCache.class, new NetworkAddressAliasCache(moduleConfig));
this.registerServiceImplementation(TopologyQueryService.class, new TopologyQueryService(getManager()));
this.registerServiceImplementation(MetricsMetadataQueryService.class, new MetricsMetadataQueryService());
this.registerServiceImplementation(MetricsQueryService.class, new MetricsQueryService(getManager()));
this.registerServiceImplementation(TraceQueryService.class, new TraceQueryService(getManager()));
this.registerServiceImplementation(BrowserLogQueryService.class, new BrowserLogQueryService(getManager()));
this.registerServiceImplementation(LogQueryService.class, new LogQueryService(getManager()));
this.registerServiceImplementation(MetadataQueryService.class, new MetadataQueryService(getManager()));
this.registerServiceImplementation(AggregationQueryService.class, new AggregationQueryService(getManager()));
this.registerServiceImplementation(AlarmQueryService.class, new AlarmQueryService(getManager()));
this.registerServiceImplementation(TopNRecordsQueryService.class, new TopNRecordsQueryService(getManager()));
// add profile service implementations
this.registerServiceImplementation(ProfileTaskMutationService.class, new ProfileTaskMutationService(getManager()));
this.registerServiceImplementation(ProfileTaskQueryService.class, new ProfileTaskQueryService(getManager(), moduleConfig));
this.registerServiceImplementation(ProfileTaskCache.class, new ProfileTaskCache(getManager(), moduleConfig));
this.registerServiceImplementation(CommandService.class, new CommandService(getManager()));
this.registerServiceImplementation(RemoteClientManager.class, new MockRemoteClientManager(getManager(), 0));
// add oal engine loader service implementations
this.registerServiceImplementation(OALEngineLoaderService.class, new OALEngineLoaderService(getManager()));
// Management
this.registerServiceImplementation(UITemplateManagementService.class, new UITemplateManagementService(getManager()));
this.registerServiceImplementation(EventQueryService.class, new EventQueryService(getManager()));
}
use of org.apache.skywalking.oap.server.core.analysis.meter.MeterSystem in project incubator-skywalking by apache.
the class OtelMetricReceiverProvider method start.
@Override
public void start() throws ServiceNotProvidedException, ModuleStartException {
if (config.getEnabledHandlers().isEmpty()) {
return;
}
GRPCHandlerRegister grpcHandlerRegister = getManager().find(SharingServerModule.NAME).provider().getService(GRPCHandlerRegister.class);
final MeterSystem service = getManager().find(CoreModule.NAME).provider().getService(MeterSystem.class);
Handler.all().stream().filter(h -> config.getEnabledHandlers().contains(h.type())).forEach(h -> h.active(config.getEnabledRulesFrom(h.type()), service, grpcHandlerRegister));
}
use of org.apache.skywalking.oap.server.core.analysis.meter.MeterSystem in project skywalking by apache.
the class CoreModuleProvider method prepare.
@Override
public void prepare() throws ServiceNotProvidedException, ModuleStartException {
if (moduleConfig.isActiveExtraModelColumns()) {
DefaultScopeDefine.activeExtraModelColumns();
}
EndpointNameGrouping endpointNameGrouping = new EndpointNameGrouping();
final NamingControl namingControl = new NamingControl(moduleConfig.getServiceNameMaxLength(), moduleConfig.getInstanceNameMaxLength(), moduleConfig.getEndpointNameMaxLength(), endpointNameGrouping);
this.registerServiceImplementation(NamingControl.class, namingControl);
MeterEntity.setNamingControl(namingControl);
try {
endpointNameGroupingRuleWatcher = new EndpointNameGroupingRuleWatcher(this, endpointNameGrouping);
if (moduleConfig.isEnableEndpointNameGroupingByOpenapi()) {
endpointNameGroupingRule4OpenapiWatcher = new EndpointNameGroupingRule4OpenapiWatcher(this, endpointNameGrouping);
}
} catch (FileNotFoundException e) {
throw new ModuleStartException(e.getMessage(), e);
}
AnnotationScan scopeScan = new AnnotationScan();
scopeScan.registerListener(new DefaultScopeDefine.Listener());
try {
scopeScan.scan();
} catch (Exception e) {
throw new ModuleStartException(e.getMessage(), e);
}
this.registerServiceImplementation(MeterSystem.class, new MeterSystem(getManager()));
AnnotationScan oalDisable = new AnnotationScan();
oalDisable.registerListener(DisableRegister.INSTANCE);
oalDisable.registerListener(new DisableRegister.SingleDisableScanListener());
try {
oalDisable.scan();
} catch (IOException | StorageException e) {
throw new ModuleStartException(e.getMessage(), e);
}
if (moduleConfig.isGRPCSslEnabled()) {
grpcServer = new GRPCServer(moduleConfig.getGRPCHost(), moduleConfig.getGRPCPort(), moduleConfig.getGRPCSslCertChainPath(), moduleConfig.getGRPCSslKeyPath(), null);
} else {
grpcServer = new GRPCServer(moduleConfig.getGRPCHost(), moduleConfig.getGRPCPort());
}
if (moduleConfig.getMaxConcurrentCallsPerConnection() > 0) {
grpcServer.setMaxConcurrentCallsPerConnection(moduleConfig.getMaxConcurrentCallsPerConnection());
}
if (moduleConfig.getMaxMessageSize() > 0) {
grpcServer.setMaxMessageSize(moduleConfig.getMaxMessageSize());
}
if (moduleConfig.getGRPCThreadPoolQueueSize() > 0) {
grpcServer.setThreadPoolQueueSize(moduleConfig.getGRPCThreadPoolQueueSize());
}
if (moduleConfig.getGRPCThreadPoolSize() > 0) {
grpcServer.setThreadPoolSize(moduleConfig.getGRPCThreadPoolSize());
}
grpcServer.initialize();
HTTPServerConfig httpServerConfig = HTTPServerConfig.builder().host(moduleConfig.getRestHost()).port(moduleConfig.getRestPort()).contextPath(moduleConfig.getRestContextPath()).idleTimeOut(moduleConfig.getRestIdleTimeOut()).maxThreads(moduleConfig.getRestMaxThreads()).acceptQueueSize(moduleConfig.getRestAcceptQueueSize()).maxRequestHeaderSize(moduleConfig.getHttpMaxRequestHeaderSize()).build();
httpServer = new HTTPServer(httpServerConfig);
httpServer.initialize();
this.registerServiceImplementation(ConfigService.class, new ConfigService(moduleConfig));
this.registerServiceImplementation(DownSamplingConfigService.class, new DownSamplingConfigService(moduleConfig.getDownsampling()));
this.registerServiceImplementation(GRPCHandlerRegister.class, new GRPCHandlerRegisterImpl(grpcServer));
this.registerServiceImplementation(HTTPHandlerRegister.class, new HTTPHandlerRegisterImpl(httpServer));
this.registerServiceImplementation(IComponentLibraryCatalogService.class, new ComponentLibraryCatalogService());
this.registerServiceImplementation(SourceReceiver.class, receiver);
WorkerInstancesService instancesService = new WorkerInstancesService();
this.registerServiceImplementation(IWorkerInstanceGetter.class, instancesService);
this.registerServiceImplementation(IWorkerInstanceSetter.class, instancesService);
this.registerServiceImplementation(RemoteSenderService.class, new RemoteSenderService(getManager()));
this.registerServiceImplementation(ModelCreator.class, storageModels);
this.registerServiceImplementation(IModelManager.class, storageModels);
this.registerServiceImplementation(ModelManipulator.class, storageModels);
this.registerServiceImplementation(NetworkAddressAliasCache.class, new NetworkAddressAliasCache(moduleConfig));
this.registerServiceImplementation(TopologyQueryService.class, new TopologyQueryService(getManager()));
this.registerServiceImplementation(MetricsMetadataQueryService.class, new MetricsMetadataQueryService());
this.registerServiceImplementation(MetricsQueryService.class, new MetricsQueryService(getManager()));
this.registerServiceImplementation(TraceQueryService.class, new TraceQueryService(getManager()));
this.registerServiceImplementation(BrowserLogQueryService.class, new BrowserLogQueryService(getManager()));
this.registerServiceImplementation(LogQueryService.class, new LogQueryService(getManager()));
this.registerServiceImplementation(MetadataQueryService.class, new MetadataQueryService(getManager()));
this.registerServiceImplementation(AggregationQueryService.class, new AggregationQueryService(getManager()));
this.registerServiceImplementation(AlarmQueryService.class, new AlarmQueryService(getManager()));
this.registerServiceImplementation(TopNRecordsQueryService.class, new TopNRecordsQueryService(getManager()));
this.registerServiceImplementation(EventQueryService.class, new EventQueryService(getManager()));
this.registerServiceImplementation(TagAutoCompleteQueryService.class, new TagAutoCompleteQueryService(getManager(), moduleConfig));
// add profile service implementations
this.registerServiceImplementation(ProfileTaskMutationService.class, new ProfileTaskMutationService(getManager()));
this.registerServiceImplementation(ProfileTaskQueryService.class, new ProfileTaskQueryService(getManager(), moduleConfig));
this.registerServiceImplementation(ProfileTaskCache.class, new ProfileTaskCache(getManager(), moduleConfig));
this.registerServiceImplementation(EBPFProfilingMutationService.class, new EBPFProfilingMutationService(getManager()));
this.registerServiceImplementation(EBPFProfilingQueryService.class, new EBPFProfilingQueryService(getManager(), moduleConfig, this.storageModels));
this.registerServiceImplementation(CommandService.class, new CommandService(getManager()));
// add oal engine loader service implementations
oalEngineLoaderService = new OALEngineLoaderService(getManager());
this.registerServiceImplementation(OALEngineLoaderService.class, oalEngineLoaderService);
annotationScan.registerListener(new StreamAnnotationListener(getManager()));
if (moduleConfig.isGRPCSslEnabled()) {
this.remoteClientManager = new RemoteClientManager(getManager(), moduleConfig.getRemoteTimeout(), moduleConfig.getGRPCSslTrustedCAPath());
} else {
this.remoteClientManager = new RemoteClientManager(getManager(), moduleConfig.getRemoteTimeout());
}
this.registerServiceImplementation(RemoteClientManager.class, remoteClientManager);
// Management
this.registerServiceImplementation(UITemplateManagementService.class, new UITemplateManagementService(getManager()));
if (moduleConfig.getMetricsDataTTL() < 2) {
throw new ModuleStartException("Metric TTL should be at least 2 days, current value is " + moduleConfig.getMetricsDataTTL());
}
if (moduleConfig.getRecordDataTTL() < 2) {
throw new ModuleStartException("Record TTL should be at least 2 days, current value is " + moduleConfig.getRecordDataTTL());
}
final MetricsStreamProcessor metricsStreamProcessor = MetricsStreamProcessor.getInstance();
metricsStreamProcessor.setEnableDatabaseSession(moduleConfig.isEnableDatabaseSession());
metricsStreamProcessor.setL1FlushPeriod(moduleConfig.getL1FlushPeriod());
metricsStreamProcessor.setStorageSessionTimeout(moduleConfig.getStorageSessionTimeout());
metricsStreamProcessor.setMetricsDataTTL(moduleConfig.getMetricsDataTTL());
TopNStreamProcessor.getInstance().setTopNWorkerReportCycle(moduleConfig.getTopNReportPeriod());
apdexThresholdConfig = new ApdexThresholdConfig(this);
ApdexMetrics.setDICT(apdexThresholdConfig);
loggingConfigWatcher = new LoggingConfigWatcher(this);
}
Aggregations