Search in sources :

Example 1 with MetricsCreator

use of org.apache.skywalking.oap.server.telemetry.api.MetricsCreator in project skywalking by apache.

the class InfluxStorageProvider method start.

@Override
public void start() throws ServiceNotProvidedException, ModuleStartException {
    MetricsCreator metricCreator = getManager().find(TelemetryModule.NAME).provider().getService(MetricsCreator.class);
    HealthCheckMetrics healthChecker = metricCreator.createHealthCheckerGauge("storage_influxdb", MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE);
    client.registerChecker(healthChecker);
    try {
        client.connect();
        InfluxTableInstaller installer = new InfluxTableInstaller(client, getManager());
        getManager().find(CoreModule.NAME).provider().getService(ModelCreator.class).addModelListener(installer);
    } catch (StorageException e) {
        throw new ModuleStartException(e.getMessage(), e);
    }
}
Also used : HealthCheckMetrics(org.apache.skywalking.oap.server.telemetry.api.HealthCheckMetrics) ModuleStartException(org.apache.skywalking.oap.server.library.module.ModuleStartException) MetricsCreator(org.apache.skywalking.oap.server.telemetry.api.MetricsCreator) ModelCreator(org.apache.skywalking.oap.server.core.storage.model.ModelCreator) StorageException(org.apache.skywalking.oap.server.core.storage.StorageException)

Example 2 with MetricsCreator

use of org.apache.skywalking.oap.server.telemetry.api.MetricsCreator in project incubator-skywalking by apache.

the class HealthCheckerProvider method start.

@Override
public void start() throws ServiceNotProvidedException, ModuleStartException {
    ModuleServiceHolder telemetry = getManager().find(TelemetryModule.NAME).provider();
    metricsCreator = telemetry.getService(MetricsCreator.class);
    collector = telemetry.getService(MetricsCollector.class);
}
Also used : MetricsCollector(org.apache.skywalking.oap.server.telemetry.api.MetricsCollector) ModuleServiceHolder(org.apache.skywalking.oap.server.library.module.ModuleServiceHolder) MetricsCreator(org.apache.skywalking.oap.server.telemetry.api.MetricsCreator)

Example 3 with MetricsCreator

use of org.apache.skywalking.oap.server.telemetry.api.MetricsCreator in project incubator-skywalking by apache.

the class RemoteServiceHandlerTestCase method callTest.

@Test
public void callTest() throws DuplicateProviderException, ProviderNotFoundException, IOException {
    final String testWorkerId = "mock-worker";
    ModuleManagerTesting moduleManager = new ModuleManagerTesting();
    ModuleDefineTesting moduleDefine = new ModuleDefineTesting();
    moduleManager.put(CoreModule.NAME, moduleDefine);
    WorkerInstancesService workerInstancesService = new WorkerInstancesService();
    moduleDefine.provider().registerServiceImplementation(IWorkerInstanceGetter.class, workerInstancesService);
    moduleDefine.provider().registerServiceImplementation(IWorkerInstanceSetter.class, workerInstancesService);
    TestWorker worker = new TestWorker(moduleManager);
    workerInstancesService.put(testWorkerId, worker, TestRemoteData.class);
    String serverName = InProcessServerBuilder.generateName();
    MetricsCreator metricsCreator = mock(MetricsCreator.class);
    when(metricsCreator.createCounter(any(), any(), any(), any())).thenReturn(new CounterMetrics() {

        @Override
        public void inc() {
        }

        @Override
        public void inc(double value) {
        }
    });
    when(metricsCreator.createHistogramMetric(any(), any(), any(), any())).thenReturn(new HistogramMetrics() {

        @Override
        public Timer createTimer() {
            return super.createTimer();
        }

        @Override
        public void observe(double value) {
        }
    });
    ModuleDefineTesting telemetryModuleDefine = new ModuleDefineTesting();
    moduleManager.put(TelemetryModule.NAME, telemetryModuleDefine);
    telemetryModuleDefine.provider().registerServiceImplementation(MetricsCreator.class, metricsCreator);
    gRPCCleanup.register(InProcessServerBuilder.forName(serverName).directExecutor().addService(new RemoteServiceHandler(moduleManager)).build().start());
    RemoteServiceGrpc.RemoteServiceStub remoteServiceStub = RemoteServiceGrpc.newStub(gRPCCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build()));
    StreamObserver<RemoteMessage> streamObserver = remoteServiceStub.call(new StreamObserver<Empty>() {

        @Override
        public void onNext(Empty empty) {
        }

        @Override
        public void onError(Throwable throwable) {
        }

        @Override
        public void onCompleted() {
        }
    });
    RemoteMessage.Builder remoteMessage = RemoteMessage.newBuilder();
    remoteMessage.setNextWorkerName(testWorkerId);
    RemoteData.Builder remoteData = RemoteData.newBuilder();
    remoteData.addDataStrings("test1");
    remoteData.addDataStrings("test2");
    remoteData.addDataLongs(10);
    remoteData.addDataLongs(20);
    remoteMessage.setRemoteData(remoteData);
    streamObserver.onNext(remoteMessage.build());
    streamObserver.onCompleted();
}
Also used : RemoteMessage(org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteMessage) CounterMetrics(org.apache.skywalking.oap.server.telemetry.api.CounterMetrics) WorkerInstancesService(org.apache.skywalking.oap.server.core.worker.WorkerInstancesService) MetricsCreator(org.apache.skywalking.oap.server.telemetry.api.MetricsCreator) RemoteData(org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData) ModuleManagerTesting(org.apache.skywalking.oap.server.testing.module.ModuleManagerTesting) ModuleDefineTesting(org.apache.skywalking.oap.server.testing.module.ModuleDefineTesting) Empty(org.apache.skywalking.oap.server.core.remote.grpc.proto.Empty) RemoteServiceGrpc(org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteServiceGrpc) HistogramMetrics(org.apache.skywalking.oap.server.telemetry.api.HistogramMetrics) Test(org.junit.Test)

Example 4 with MetricsCreator

use of org.apache.skywalking.oap.server.telemetry.api.MetricsCreator in project incubator-skywalking by apache.

the class GRPCRemoteClientTestCase method testPush.

@Test
public void testPush() throws InterruptedException {
    MetricsCreator metricsCreator = mock(MetricsCreator.class);
    when(metricsCreator.createCounter(any(), any(), any(), any())).thenReturn(new CounterMetrics() {

        @Override
        public void inc() {
        }

        @Override
        public void inc(double value) {
        }
    });
    when(metricsCreator.createHistogramMetric(any(), any(), any(), any())).thenReturn(new HistogramMetrics() {

        @Override
        public Timer createTimer() {
            return super.createTimer();
        }

        @Override
        public void observe(double value) {
        }
    });
    ModuleDefineTesting telemetryModuleDefine = new ModuleDefineTesting();
    moduleManager.put(TelemetryModule.NAME, telemetryModuleDefine);
    telemetryModuleDefine.provider().registerServiceImplementation(MetricsCreator.class, metricsCreator);
    grpcServerRule.getServiceRegistry().addService(new RemoteServiceHandler(moduleManager));
    Address address = new Address("not-important", 11, false);
    GRPCRemoteClient remoteClient = spy(new GRPCRemoteClient(moduleManager, address, 1, 10, 10, null));
    remoteClient.connect();
    doReturn(grpcServerRule.getChannel()).when(remoteClient).getChannel();
    for (int i = 0; i < 12; i++) {
        remoteClient.push(nextWorkerName, new TestStreamData());
    }
    TimeUnit.SECONDS.sleep(2);
}
Also used : RemoteServiceHandler(org.apache.skywalking.oap.server.core.remote.RemoteServiceHandler) CounterMetrics(org.apache.skywalking.oap.server.telemetry.api.CounterMetrics) MetricsCreator(org.apache.skywalking.oap.server.telemetry.api.MetricsCreator) HistogramMetrics(org.apache.skywalking.oap.server.telemetry.api.HistogramMetrics) ModuleDefineTesting(org.apache.skywalking.oap.server.testing.module.ModuleDefineTesting) Test(org.junit.Test)

Example 5 with MetricsCreator

use of org.apache.skywalking.oap.server.telemetry.api.MetricsCreator in project incubator-skywalking by apache.

the class H2StorageProvider method start.

@Override
public void start() throws ServiceNotProvidedException, ModuleStartException {
    final ConfigService configService = getManager().find(CoreModule.NAME).provider().getService(ConfigService.class);
    MetricsCreator metricCreator = getManager().find(TelemetryModule.NAME).provider().getService(MetricsCreator.class);
    HealthCheckMetrics healthChecker = metricCreator.createHealthCheckerGauge("storage_h2", MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE);
    h2Client.registerChecker(healthChecker);
    try {
        h2Client.connect();
        H2TableInstaller installer = new H2TableInstaller(h2Client, getManager());
        getManager().find(CoreModule.NAME).provider().getService(ModelCreator.class).addModelListener(installer);
    } catch (StorageException e) {
        throw new ModuleStartException(e.getMessage(), e);
    }
}
Also used : ConfigService(org.apache.skywalking.oap.server.core.config.ConfigService) H2TableInstaller(org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TableInstaller) HealthCheckMetrics(org.apache.skywalking.oap.server.telemetry.api.HealthCheckMetrics) ModuleStartException(org.apache.skywalking.oap.server.library.module.ModuleStartException) MetricsCreator(org.apache.skywalking.oap.server.telemetry.api.MetricsCreator) ModelCreator(org.apache.skywalking.oap.server.core.storage.model.ModelCreator) StorageException(org.apache.skywalking.oap.server.core.storage.StorageException)

Aggregations

MetricsCreator (org.apache.skywalking.oap.server.telemetry.api.MetricsCreator)34 ModelCreator (org.apache.skywalking.oap.server.core.storage.model.ModelCreator)10 ModuleStartException (org.apache.skywalking.oap.server.library.module.ModuleStartException)10 HealthCheckMetrics (org.apache.skywalking.oap.server.telemetry.api.HealthCheckMetrics)10 ModuleDefineTesting (org.apache.skywalking.oap.server.testing.module.ModuleDefineTesting)8 StorageException (org.apache.skywalking.oap.server.core.storage.StorageException)6 CounterMetrics (org.apache.skywalking.oap.server.telemetry.api.CounterMetrics)6 ModuleManagerTesting (org.apache.skywalking.oap.server.testing.module.ModuleManagerTesting)6 ConfigService (org.apache.skywalking.oap.server.core.config.ConfigService)4 ServiceNotProvidedException (org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException)4 HistogramMetrics (org.apache.skywalking.oap.server.telemetry.api.HistogramMetrics)4 Test (org.junit.Test)4 IoTDBConnectionException (org.apache.iotdb.rpc.IoTDBConnectionException)2 StatementExecutionException (org.apache.iotdb.rpc.StatementExecutionException)2 ClusterNodesQuery (org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery)2 NamingControl (org.apache.skywalking.oap.server.core.config.NamingControl)2 RemoteServiceHandler (org.apache.skywalking.oap.server.core.remote.RemoteServiceHandler)2 Empty (org.apache.skywalking.oap.server.core.remote.grpc.proto.Empty)2 RemoteData (org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData)2 RemoteMessage (org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteMessage)2