io.vertx.core.spi.metrics.VertxMetrics Java Examples

The following examples show how to use io.vertx.core.spi.metrics.VertxMetrics. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetricsTest.java    From vertx-dropwizard-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void testClientMetricsLifecycle() {
  VertxMetrics spi = ((VertxInternal) vertx).metricsSPI();
  SocketAddress address = SocketAddress.inetSocketAddress(8080, "localhost");
  ClientMetrics[] metrics = new ClientMetrics[2];
  for (int i = 0;i < metrics.length;i++) {
    metrics[i] = spi.createClientMetrics(address, "backend", "acme");
  }
  JsonObject snapshot = metricsService.getMetricsSnapshot("vertx.backend.clients.acme.localhost:8080");
  assertTrue(snapshot.size() > 0);
  metrics[0].close();
  snapshot = metricsService.getMetricsSnapshot("vertx.backend.clients.acme.localhost:8080");
  assertTrue(snapshot.size() > 0);
  metrics[1].close();
  snapshot = metricsService.getMetricsSnapshot("vertx.backend.clients.acme.localhost:8080");
  assertTrue(snapshot.size() == 0);
}
 
Example #2
Source File: DefaultVertxMetricsFactory.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized VertxMetrics metrics(VertxOptions options) {
  if (vertxMetrics == null) {
    vertxMetrics = new DefaultVertxMetrics(options);
  }
  return vertxMetrics;
}
 
Example #3
Source File: TestDefaultVertxMetricsFactory.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Test
public void metrics() {
  MetricsOptions metricsOptions = factory.newOptions();
  options.setMetricsOptions(metricsOptions);
  VertxMetrics vertxMetrics = factory.metrics(options);

  Assert.assertSame(factory, metricsOptions.getFactory());
  Assert.assertTrue(metricsOptions.isEnabled());

  Assert.assertSame(factory.getVertxMetrics(), vertxMetrics);
  Assert.assertTrue(vertxMetrics.isMetricsEnabled());
  Assert.assertTrue(vertxMetrics.isEnabled());
}
 
Example #4
Source File: PgPoolImpl.java    From vertx-sql-client with Apache License 2.0 5 votes vote down vote up
public static PgPoolImpl create(ContextInternal context, boolean closeVertx, PgConnectOptions connectOptions, PoolOptions poolOptions) {
  QueryTracer tracer = context.tracer() == null ? null : new QueryTracer(context.tracer(), connectOptions);
  VertxMetrics vertxMetrics = context.owner().metricsSPI();
  ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(connectOptions.getSocketAddress(), "sql", connectOptions.getMetricsName()) : null;
  PgPoolImpl pool = new PgPoolImpl(context, new PgConnectionFactory(context.owner(), context, connectOptions), tracer, metrics, poolOptions);
  CloseFuture closeFuture = pool.closeFuture();
  if (closeVertx) {
    closeFuture.onComplete(ar -> context.owner().close());
  } else {
    context.addCloseHook(closeFuture);
  }
  return pool;
}
 
Example #5
Source File: DB2PoolImpl.java    From vertx-sql-client with Apache License 2.0 5 votes vote down vote up
public static DB2PoolImpl create(ContextInternal context, boolean closeVertx, DB2ConnectOptions connectOptions,
                                 PoolOptions poolOptions) {
  QueryTracer tracer = context.tracer() == null ? null : new QueryTracer(context.tracer(), connectOptions);
  VertxMetrics vertxMetrics = context.owner().metricsSPI();
  ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(connectOptions.getSocketAddress(), "sql", connectOptions.getMetricsName()) : null;
  DB2PoolImpl pool = new DB2PoolImpl(context, poolOptions, new DB2ConnectionFactory(context, connectOptions), tracer, metrics);
  CloseFuture closeFuture = pool.closeFuture();
  if (closeVertx) {
    closeFuture.onComplete(ar -> context.owner().close());
  } else {
    context.addCloseHook(closeFuture);
  }
  return pool;
}
 
Example #6
Source File: MSSQLPoolImpl.java    From vertx-sql-client with Apache License 2.0 5 votes vote down vote up
public static MSSQLPoolImpl create(ContextInternal context, boolean closeVertx, MSSQLConnectOptions connectOptions, PoolOptions poolOptions) {
  QueryTracer tracer = context.tracer() == null ? null : new QueryTracer(context.tracer(), connectOptions);
  VertxMetrics vertxMetrics = context.owner().metricsSPI();
  ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(connectOptions.getSocketAddress(), "sql", connectOptions.getMetricsName()) : null;
  MSSQLPoolImpl pool = new MSSQLPoolImpl(context, new MSSQLConnectionFactory(context, connectOptions), tracer, metrics, poolOptions);
  CloseFuture closeFuture = pool.closeFuture();
  if (closeVertx) {
    closeFuture.onComplete(ar -> context.owner().close());
  } else {
    context.addCloseHook(closeFuture);
  }
  return pool;
}
 
Example #7
Source File: MetricsTestBase.java    From vertx-sql-client with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
  vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(
    new MetricsOptions().setEnabled(true).setFactory(tracingOptions -> new VertxMetrics() {
      @Override
      public ClientMetrics<?, ?, ?, ?> createClientMetrics(SocketAddress remoteAddress, String type, String namespace) {
        return metrics;
      }
    }))
  );
}
 
Example #8
Source File: MySQLPoolImpl.java    From vertx-sql-client with Apache License 2.0 5 votes vote down vote up
public static MySQLPoolImpl create(ContextInternal context, boolean closeVertx, MySQLConnectOptions connectOptions, PoolOptions poolOptions) {
  QueryTracer tracer = context.tracer() == null ? null : new QueryTracer(context.tracer(), connectOptions);
  VertxMetrics vertxMetrics = context.owner().metricsSPI();
  ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(connectOptions.getSocketAddress(), "sql", connectOptions.getMetricsName()) : null;
  MySQLPoolImpl pool = new MySQLPoolImpl(context, new MySQLConnectionFactory(context, connectOptions), tracer, metrics, poolOptions);
  CloseFuture closeFuture = pool.closeFuture();
  if (closeVertx) {
    closeFuture.onComplete(ar -> context.owner().close());
  } else {
    context.addCloseHook(closeFuture);
  }
  return pool;
}
 
Example #9
Source File: VertxMetricsAdapterFactory.java    From besu with Apache License 2.0 4 votes vote down vote up
@Override
public VertxMetrics metrics(final VertxOptions options) {
  return new VertxMetricsAdapter(metricsSystem);
}
 
Example #10
Source File: LealoneVertxMetricsFactory.java    From Lealone-Plugins with Apache License 2.0 4 votes vote down vote up
@Override
public VertxMetrics metrics(VertxOptions arg0) {
    // TODO Auto-generated method stub
    return null;
}
 
Example #11
Source File: JDBCClientImpl.java    From vertx-jdbc-client with Apache License 2.0 4 votes vote down vote up
private PoolMetrics createMetrics(String poolName, int maxPoolSize) {
  VertxMetrics metricsSPI = vertx.metricsSPI();
  return metricsSPI != null ? metricsSPI.createPoolMetrics("datasource", poolName, maxPoolSize) : null;
}