io.vertx.core.metrics.MetricsOptions Java Examples

The following examples show how to use io.vertx.core.metrics.MetricsOptions. 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: MetricsServiceImplTest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldGetJvmMetricsInSnapshot(TestContext ctx) {
  MetricsOptions metricsOptions = new MicrometerMetricsOptions()
    .setJvmMetricsEnabled(true)
    .setMicrometerRegistry(new SimpleMeterRegistry())
    .setRegistryName(registryName)
    .setEnabled(true);
  VertxOptions vertxOptions = new VertxOptions().setMetricsOptions(metricsOptions);
  Vertx vertx = Vertx.vertx(vertxOptions)
    .exceptionHandler(ctx.exceptionHandler());

  JsonObject snapshot = MetricsService.create(vertx).getMetricsSnapshot("jvm");

  assertFalse(snapshot.isEmpty());

  vertx.close(ctx.asyncAssertSuccess());
}
 
Example #2
Source File: VertxProperties.java    From hono with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Configures the Vert.x options based on this object's property values.
 *
 * @param options The options to configure.
 * @return The (updated) options.
 */
public VertxOptions configureVertx(final VertxOptions options) {

    options.setPreferNativeTransport(this.preferNative);

    if (this.enableMetrics) {
        options.setMetricsOptions(new MetricsOptions().setEnabled(true));
    }

    options.setMaxEventLoopExecuteTime(maxEventLoopExecuteTimeMillis * 1000000L);
    options.setWarningExceptionTime(maxEventLoopExecuteTimeMillis * 1500000L);
    options.setAddressResolverOptions(new AddressResolverOptions()
            .setCacheNegativeTimeToLive(0) // discard failed DNS lookup results immediately
            .setCacheMaxTimeToLive(0) // support DNS based service resolution
            .setQueryTimeout(dnsQueryTimeout));
    return options;
}
 
Example #3
Source File: BesuCommand.java    From besu with Apache License 2.0 5 votes vote down vote up
private VertxOptions createVertxOptions(final MetricsSystem metricsSystem) {
  return new VertxOptions()
      .setMetricsOptions(
          new MetricsOptions()
              .setEnabled(true)
              .setFactory(new VertxMetricsAdapterFactory(metricsSystem)));
}
 
Example #4
Source File: DefaultVertxMetricsFactory.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Override
public MetricsOptions newOptions() {
  MetricsOptionsEx metricsOptions = new MetricsOptionsEx();
  metricsOptions.setFactory(this);
  metricsOptions.setEnabled(true);
  return metricsOptions;
}
 
Example #5
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 #6
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 #7
Source File: DropwizardMetricsOptions.java    From vertx-dropwizard-metrics with Apache License 2.0 5 votes vote down vote up
/**
 * Copy constructor with base metrics options
 *
 * @param other The other {@link MetricsOptions} to copy when creating this
 */
public DropwizardMetricsOptions(MetricsOptions other) {
  super(other);
  jmxEnabled = DEFAULT_JMX_ENABLED;
  monitoredEventBusHandlers = new ArrayList<>(DEFAULT_MONITORED_HANDLERS);
  monitoredHttpServerUris = new ArrayList<>(DEFAULT_MONITORED_HTTP_SERVER_URIS);
  monitoredHttpClientUris = new ArrayList<>(DEFAULT_MONITORED_HTTP_CLIENT_URIS);
  monitoredHttpClientEndpoints = new ArrayList<>(DEFAULT_MONITORED_HTTP_CLIENT_ENDPOINTS);
}
 
Example #8
Source File: VertxProperties.java    From vertx-spring-boot with Apache License 2.0 4 votes vote down vote up
public VertxOptions toVertxOptions() {
    VertxOptions vertxOptions = new VertxOptions();
    vertxOptions.setEventLoopPoolSize(eventLoopPoolSize);
    vertxOptions.setWorkerPoolSize(workerPoolSize);
    vertxOptions.setInternalBlockingPoolSize(internalBlockingPoolSize);
    vertxOptions.setBlockedThreadCheckInterval(blockedThreadCheckInterval);
    vertxOptions.setMaxEventLoopExecuteTime(maxEventLoopExecuteTime);
    vertxOptions.setMaxWorkerExecuteTime(maxWorkerExecuteTime);
    vertxOptions.setHAEnabled(haEnabled);
    vertxOptions.setQuorumSize(quorumSize);
    vertxOptions.setHAGroup(haGroup);
    vertxOptions.setWarningExceptionTime(warningExceptionTime);
    vertxOptions.setPreferNativeTransport(preferNativeTransport);
    vertxOptions.setMaxEventLoopExecuteTimeUnit(maxEventLoopExecuteTimeUnit);
    vertxOptions.setMaxWorkerExecuteTimeUnit(maxWorkerExecuteTimeUnit);
    vertxOptions.setWarningExceptionTimeUnit(warningExceptionTimeUnit);
    vertxOptions.setBlockedThreadCheckIntervalUnit(blockedThreadCheckIntervalUnit);

    MetricsOptions metricsOptions = new MetricsOptions();
    metricsOptions.setEnabled(metricsEnabled);
    vertxOptions.setMetricsOptions(metricsOptions);

    FileSystemOptions fileSystemOptions = new FileSystemOptions();
    fileSystemOptions.setClassPathResolvingEnabled(fileSystem.isClassPathResolvingEnabled());
    fileSystemOptions.setFileCachingEnabled(fileSystem.isFileCachingEnabled());
    vertxOptions.setFileSystemOptions(fileSystemOptions);

    AddressResolverOptions addressResolverOptions = new AddressResolverOptions();
    addressResolverOptions.setHostsPath(addressResolver.getHostsPath());
    addressResolverOptions.setHostsValue(addressResolver.getHostsValue());
    addressResolverOptions.setServers(addressResolver.getServers());
    addressResolverOptions.setOptResourceEnabled(addressResolver.isOptResourceEnabled());
    addressResolverOptions.setCacheMinTimeToLive(addressResolver.getCacheMinTimeToLive());
    addressResolverOptions.setCacheMaxTimeToLive(addressResolver.getCacheMaxTimeToLive());
    addressResolverOptions.setCacheNegativeTimeToLive(addressResolver.getCacheNegativeTimeToLive());
    addressResolverOptions.setQueryTimeout(addressResolver.getQueryTimeout());
    addressResolverOptions.setMaxQueries(addressResolver.getMaxQueries());
    addressResolverOptions.setRdFlag(addressResolver.isRdFlag());
    addressResolverOptions.setSearchDomains(addressResolver.getSearchDomains());
    addressResolverOptions.setNdots(addressResolver.getNdots());
    addressResolverOptions.setRotateServers(addressResolver.isRotateServers());
    vertxOptions.setAddressResolverOptions(addressResolverOptions);

    return vertxOptions;
}
 
Example #9
Source File: VertxMetricsFactoryImpl.java    From vertx-micrometer-metrics with Apache License 2.0 4 votes vote down vote up
@Override
public MetricsOptions newOptions() {
  return newOptions(null);
}
 
Example #10
Source File: VertxMetricsFactoryImpl.java    From vertx-micrometer-metrics with Apache License 2.0 4 votes vote down vote up
@Override
public MetricsOptions newOptions(JsonObject jsonObject) {
  return jsonObject == null ? new MicrometerMetricsOptions() : new MicrometerMetricsOptions(jsonObject);
}
 
Example #11
Source File: VertxMetricsFactoryImpl.java    From vertx-dropwizard-metrics with Apache License 2.0 4 votes vote down vote up
@Override
public MetricsOptions newOptions() {
  return newOptions(null);
}
 
Example #12
Source File: VertxMetricsFactoryImpl.java    From vertx-dropwizard-metrics with Apache License 2.0 4 votes vote down vote up
@Override
public MetricsOptions newOptions(JsonObject jsonObject) {
  return jsonObject == null ? new DropwizardMetricsOptions() : new DropwizardMetricsOptions(jsonObject);
}