io.vertx.micrometer.Label Java Examples

The following examples show how to use io.vertx.micrometer.Label. 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: CountersTest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldAliasCounterLabel() {
  MeterRegistry registry = new SimpleMeterRegistry();
  BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match()
    .setLabel("address")
    .setType(MatchType.REGEX)
    .setValue("addr1")
    .setAlias("1")));
  Counters counters = new Counters("my_counter", "", registry, Label.EB_ADDRESS);
  counters.get("addr1").increment();
  counters.get("addr1").increment();
  counters.get("addr2").increment();

  Counter c = registry.find("my_counter").tags("address", "1").counter();
  assertThat(c.count()).isEqualTo(2d);
  c = registry.find("my_counter").tags("address", "addr1").counter();
  assertThat(c).isNull();
  c = registry.find("my_counter").tags("address", "addr2").counter();
  assertThat(c.count()).isEqualTo(1d);
}
 
Example #2
Source File: PrometheusMetricsITest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldPublishPercentileStats(TestContext context) {
  vertx = Vertx.vertx(new VertxOptions()
    .setMetricsOptions(new MicrometerMetricsOptions()
      .setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)
        .setPublishQuantiles(true)
        .setStartEmbeddedServer(true)
        .setEmbeddedServerOptions(new HttpServerOptions().setPort(9090)))
      .addLabels(Label.LOCAL, Label.HTTP_PATH, Label.REMOTE, Label.HTTP_CODE)
      .setEnabled(true)));

  Async async = context.async();
  // First "blank" connection to trigger some metrics
  PrometheusTestHelper.tryConnect(vertx, context, 9090, "localhost", "/metrics", r1 -> {
    // Delay to make "sure" metrics are populated
    vertx.setTimer(500, l ->
      // Second connection, this time actually reading the metrics content
      PrometheusTestHelper.tryConnect(vertx, context, 9090, "localhost", "/metrics", body -> {
        context.verify(v2 -> assertThat(body.toString())
          .contains("vertx_http_client_responseTime_seconds_bucket{code=\"200\""));
        async.complete();
      }));
  });
  async.awaitSuccess(10000);
}
 
Example #3
Source File: PrometheusMetricsITest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldExcludeCategory(TestContext context) {
  vertx = Vertx.vertx(new VertxOptions()
    .setMetricsOptions(new MicrometerMetricsOptions()
      .setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)
        .setStartEmbeddedServer(true)
        .setEmbeddedServerOptions(new HttpServerOptions().setPort(9090)))
      .addDisabledMetricsCategory(MetricsDomain.HTTP_SERVER)
      .addLabels(Label.LOCAL, Label.REMOTE)
      .setEnabled(true)));

  Async async = context.async();
  PrometheusTestHelper.tryConnect(vertx, context, 9090, "localhost", "/metrics", body -> {
    context.verify(v -> assertThat(body.toString())
      .contains("vertx_http_client_connections{local=\"?\",remote=\"localhost:9090\",} 1.0")
      .doesNotContain("vertx_http_server_connections{local=\"0.0.0.0:9090\",remote=\"_\",} 1.0"));
    async.complete();
  });
  async.awaitSuccess(10000);
}
 
Example #4
Source File: PrometheusMetricsITest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldStartEmbeddedServer(TestContext context) {
  vertx = Vertx.vertx(new VertxOptions()
    .setMetricsOptions(new MicrometerMetricsOptions()
      .setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)
        .setStartEmbeddedServer(true)
        .setEmbeddedServerOptions(new HttpServerOptions().setPort(9090)))
      .addLabels(Label.LOCAL, Label.HTTP_PATH, Label.REMOTE)
      .setEnabled(true)));

  Async async = context.async();
  // First "blank" connection to trigger some metrics
  PrometheusTestHelper.tryConnect(vertx, context, 9090, "localhost", "/metrics", r1 -> {
    // Delay to make "sure" metrics are populated
    vertx.setTimer(500, l ->
      // Second connection, this time actually reading the metrics content
      PrometheusTestHelper.tryConnect(vertx, context, 9090, "localhost", "/metrics", body -> {
          context.verify(v2 -> assertThat(body.toString())
            .contains("vertx_http_client_requests{local=\"?\",method=\"GET\",path=\"/metrics\",remote=\"localhost:9090\"")
            .doesNotContain("vertx_http_client_responseTime_seconds_bucket"));
          async.complete();
      }));
  });
  async.awaitSuccess(10000);
}
 
Example #5
Source File: CountersTest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldIgnoreCounterLabel() {
  MeterRegistry registry = new SimpleMeterRegistry();
  BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match()
    .setLabel("address")
    .setType(MatchType.REGEX)
    .setValue(".*")
    .setAlias("_")));
  Counters counters = new Counters("my_counter", "", registry, Label.EB_ADDRESS);
  counters.get("addr1").increment();
  counters.get("addr1").increment();
  counters.get("addr2").increment();

  Counter c = registry.find("my_counter").tags("address", "_").counter();
  assertThat(c.count()).isEqualTo(3d);
  c = registry.find("my_counter").tags("address", "addr1").counter();
  assertThat(c).isNull();
  c = registry.find("my_counter").tags("address", "addr2").counter();
  assertThat(c).isNull();
}
 
Example #6
Source File: JmxMetricsITest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldReportJmx(TestContext context) throws Exception {
  vertx = Vertx.vertx(new VertxOptions()
    .setMetricsOptions(new MicrometerMetricsOptions()
      .setRegistryName(REGISTRY_NAME)
      .addLabels(Label.EB_ADDRESS)
      .setJmxMetricsOptions(new VertxJmxMetricsOptions().setEnabled(true)
        .setDomain("my-metrics")
        .setStep(1))
      .setEnabled(true)));

  // Send something on the eventbus and wait til it's received
  Async asyncEB = context.async();
  vertx.eventBus().consumer("test-eb", msg -> asyncEB.complete());
  vertx.eventBus().publish("test-eb", "test message");
  asyncEB.await(2000);

  // Read MBean
  MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
  assertThat(mbs.getDomains()).contains("my-metrics");
  Number result = (Number) mbs.getAttribute(new ObjectName("my-metrics", "name", "vertxEventbusHandlers.address.test-eb"), "Value");
  assertThat(result).isEqualTo(1d);
}
 
Example #7
Source File: TimersTest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldIgnoreTimerLabel() {
  MeterRegistry registry = new SimpleMeterRegistry();
  BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match()
    .setLabel("address")
    .setType(MatchType.REGEX)
    .setValue(".*")
    .setAlias("_")));
  Timers timers = new Timers("my_timer", "", registry, Label.EB_ADDRESS);
  timers.get("addr1").record(5, TimeUnit.MILLISECONDS);
  timers.get("addr1").record(8, TimeUnit.MILLISECONDS);
  timers.get("addr2").record(10, TimeUnit.MILLISECONDS);

  Timer t = registry.find("my_timer").timer();
  assertThat(t.count()).isEqualTo(3);
  assertThat(t.totalTime(TimeUnit.MILLISECONDS)).isEqualTo(23);
  t = registry.find("my_timer").tags("address", "addr1").timer();
  assertThat(t).isNull();
  t = registry.find("my_timer").tags("address", "addr2").timer();
  assertThat(t).isNull();
}
 
Example #8
Source File: TimersTest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldAliasTimerLabel() {
  MeterRegistry registry = new SimpleMeterRegistry();
  BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match()
    .setLabel("address")
    .setType(MatchType.REGEX)
    .setValue("addr1")
    .setAlias("1")));
  Timers timers = new Timers("my_timer", "", registry, Label.EB_ADDRESS);
  timers.get("addr1").record(5, TimeUnit.MILLISECONDS);
  timers.get("addr1").record(8, TimeUnit.MILLISECONDS);
  timers.get("addr2").record(10, TimeUnit.MILLISECONDS);

  Timer t = registry.find("my_timer").tags("address", "1").timer();
  assertThat(t.count()).isEqualTo(2);
  assertThat(t.totalTime(TimeUnit.MILLISECONDS)).isEqualTo(13);
  t = registry.find("my_timer").tags("address", "addr1").timer();
  assertThat(t).isNull();
  t = registry.find("my_timer").tags("address", "addr2").timer();
  assertThat(t.count()).isEqualTo(1);
  assertThat(t.totalTime(TimeUnit.MILLISECONDS)).isEqualTo(10);
}
 
Example #9
Source File: GaugesTest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldIgnoreGaugeLabel() {
  MeterRegistry registry = new SimpleMeterRegistry();
  BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match()
    .setLabel("address")
    .setType(MatchType.REGEX)
    .setValue(".*")
    .setAlias("_")));
  Gauges<LongAdder> gauges = new Gauges<>("my_gauge", "", LongAdder::new, LongAdder::doubleValue, registry, Label.EB_ADDRESS);
  gauges.get("addr1").increment();
  gauges.get("addr1").increment();
  gauges.get("addr2").increment();

  Gauge g = registry.find("my_gauge").tags("address", "_").gauge();
  assertThat(g.value()).isEqualTo(3d);
  g = registry.find("my_gauge").tags("address", "addr1").gauge();
  assertThat(g).isNull();
  g = registry.find("my_gauge").tags("address", "addr2").gauge();
  assertThat(g).isNull();
}
 
Example #10
Source File: GaugesTest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldAliasGaugeLabel() {
  MeterRegistry registry = new SimpleMeterRegistry();
  BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match()
    .setLabel("address")
    .setType(MatchType.REGEX)
    .setValue("addr1")
    .setAlias("1")));
  Gauges<LongAdder> gauges = new Gauges<>("my_gauge", "", LongAdder::new, LongAdder::doubleValue, registry, Label.EB_ADDRESS);
  gauges.get("addr1").increment();
  gauges.get("addr1").increment();
  gauges.get("addr2").increment();

  Gauge g = registry.find("my_gauge").tags("address", "1").gauge();
  assertThat(g.value()).isEqualTo(2d);
  g = registry.find("my_gauge").tags("address", "addr1").gauge();
  assertThat(g).isNull();
  g = registry.find("my_gauge").tags("address", "addr2").gauge();
  assertThat(g.value()).isEqualTo(1d);
}
 
Example #11
Source File: SummariesTest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldIgnoreSummaryLabel() {
  MeterRegistry registry = new SimpleMeterRegistry();
  BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match()
    .setLabel("address")
    .setType(MatchType.REGEX)
    .setValue(".*")
    .setAlias("_")));
  Summaries summaries = new Summaries("my_summary", "", registry, Label.EB_ADDRESS);
  summaries.get("addr1").record(5);
  summaries.get("addr1").record(8);
  summaries.get("addr2").record(10);

  DistributionSummary s = registry.find("my_summary").tags("address", "_").summary();
  assertThat(s.count()).isEqualTo(3);
  assertThat(s.totalAmount()).isEqualTo(23);
  s = registry.find("my_summary").tags("address", "addr1").summary();
  assertThat(s).isNull();
  s = registry.find("my_summary").tags("address", "addr2").summary();
  assertThat(s).isNull();
}
 
Example #12
Source File: SummariesTest.java    From vertx-micrometer-metrics with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldAliasSummaryLabel() {
  MeterRegistry registry = new SimpleMeterRegistry();
  BackendRegistries.registerMatchers(registry, ALL_LABELS, Collections.singletonList(new Match()
    .setLabel("address")
    .setType(MatchType.REGEX)
    .setValue("addr1")
    .setAlias("1")));
  Summaries summaries = new Summaries("my_summary", "", registry, Label.EB_ADDRESS);
  summaries.get("addr1").record(5);
  summaries.get("addr1").record(8);
  summaries.get("addr2").record(10);

  DistributionSummary s = registry.find("my_summary").tags("address", "1").summary();
  assertThat(s.count()).isEqualTo(2);
  assertThat(s.totalAmount()).isEqualTo(13);
  s = registry.find("my_summary").tags("address", "addr1").summary();
  assertThat(s).isNull();
  s = registry.find("my_summary").tags("address", "addr2").summary();
  assertThat(s.count()).isEqualTo(1);
  assertThat(s.totalAmount()).isEqualTo(10);
}
 
Example #13
Source File: MetricsServiceImplTest.java    From vertx-micrometer-metrics with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp(TestContext ctx) {
  vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MicrometerMetricsOptions()
    .setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true))
    .setRegistryName(registryName)
    .setLabels(EnumSet.complementOf(EnumSet.of(Label.LOCAL, Label.REMOTE)))
    .setEnabled(true)))
    .exceptionHandler(ctx.exceptionHandler());

  // Setup server
  Async serverReady = ctx.async();
  httpServer = vertx.createHttpServer();
  httpServer
    .requestHandler(req -> {
      // Timer as artificial processing time
      vertx.setTimer(30L, handler ->
        req.response().setChunked(true).putHeader("Content-Type", "text/plain").end(SERVER_RESPONSE));
    })
    .listen(9195, "127.0.0.1", r -> {
      if (r.failed()) {
        ctx.fail(r.cause());
      } else {
        serverReady.complete();
      }
    });
  serverReady.awaitSuccess();
}
 
Example #14
Source File: VertxPoolMetrics.java    From vertx-micrometer-metrics with Apache License 2.0 5 votes vote down vote up
VertxPoolMetrics(MeterRegistry registry) {
  super(registry, MetricsDomain.NAMED_POOLS);
  queueDelay = timers("queue.delay", "Queue time for a resource", Label.POOL_TYPE, Label.POOL_NAME);
  queueSize = longGauges("queue.size", "Number of elements waiting for a resource", Label.POOL_TYPE, Label.POOL_NAME);
  usage = timers("usage", "Time using a resource", Label.POOL_TYPE, Label.POOL_NAME);
  inUse = longGauges("inUse", "Number of resources used", Label.POOL_TYPE, Label.POOL_NAME);
  usageRatio = doubleGauges("ratio", "Pool usage ratio, only present if maximum pool size could be determined", Label.POOL_TYPE, Label.POOL_NAME);
  completed = counters("completed", "Number of elements done with the resource", Label.POOL_TYPE, Label.POOL_NAME);
}
 
Example #15
Source File: InfluxDbReporterITest.java    From vertx-micrometer-metrics with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSendDataToInfluxDb(TestContext context) throws Exception {
  // Mock an influxdb server
  Async asyncInflux = context.async();
  InfluxDbTestHelper.simulateInfluxServer(vertxForSimulatedServer, context, 8086, body -> {
    if (body.contains("vertx_eventbus_handlers,address=test-eb,metric_type=gauge value=1")) {
      asyncInflux.complete();
    }
  });

  vertx = Vertx.vertx(new VertxOptions()
    .setMetricsOptions(new MicrometerMetricsOptions()
      .setInfluxDbOptions(new VertxInfluxDbOptions()
        .setStep(1)
        .setDb("mydb")
        .setEnabled(true))
      .setRegistryName(REGITRY_NAME)
      .addLabels(Label.EB_ADDRESS)
      .setEnabled(true)));

  // Send something on the eventbus and wait til it's received
  Async asyncEB = context.async();
  vertx.eventBus().consumer("test-eb", msg -> asyncEB.complete());
  vertx.eventBus().publish("test-eb", "test message");
  asyncEB.await(2000);

  // Await influx
  asyncInflux.awaitSuccess(2000);
}
 
Example #16
Source File: PrometheusMetricsITest.java    From vertx-micrometer-metrics with Apache License 2.0 5 votes vote down vote up
@Test
public void canMatchLabels(TestContext context) {
  vertx = Vertx.vertx(new VertxOptions()
    .setMetricsOptions(new MicrometerMetricsOptions()
      .setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)
        .setStartEmbeddedServer(true)
        .setEmbeddedServerOptions(new HttpServerOptions().setPort(9090)))
      .addLabels(Label.HTTP_PATH)
      .addLabelMatch(new Match()
        .setDomain(MetricsDomain.HTTP_CLIENT)
        .setValue(".*")
        .setLabel(Label.HTTP_PATH.toString())
        .setType(MatchType.REGEX))
      .setEnabled(true)));

  Async async = context.async();
  // First "blank" connection to trigger some metrics
  PrometheusTestHelper.tryConnect(vertx, context, 9090, "localhost", "/metrics", r1 -> {
    // Delay to make "sure" metrics are populated
    vertx.setTimer(500, l ->
      // Second connection, this time actually reading the metrics content
      PrometheusTestHelper.tryConnect(vertx, context, 9090, "localhost", "/metrics", body -> {
        context.verify(v2 -> assertThat(body.toString())
          .contains("vertx_http_client_requests{method=\"GET\",path=\"/metrics\",}")
          .doesNotContain("vertx_http_client_responseTime_seconds_bucket"));
        async.complete();
      }));
  });
  async.awaitSuccess(10000);
}
 
Example #17
Source File: Application.java    From strimzi-kafka-bridge with Apache License 2.0 5 votes vote down vote up
/**
 * Set up the Vert.x metrics options
 * 
 * @return instance of the MicrometerMetricsOptions on Vert.x
 */
private static MicrometerMetricsOptions metricsOptions() {
    return new MicrometerMetricsOptions()
            .setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true))
            // define the labels on the HTTP server related metrics
            .setLabels(EnumSet.of(Label.REMOTE, Label.LOCAL, Label.HTTP_PATH, Label.HTTP_METHOD, Label.HTTP_CODE))
            // disable metrics about pool and verticles
            .setDisabledMetricsCategories(EnumSet.of(MetricsDomain.NAMED_POOLS, MetricsDomain.VERTICLES))
            .setJvmMetricsEnabled(true)
            .setEnabled(true);
}
 
Example #18
Source File: VertxEventBusMetrics.java    From vertx-micrometer-metrics with Apache License 2.0 5 votes vote down vote up
VertxEventBusMetrics(MeterRegistry registry) {
  super(registry, MetricsDomain.EVENT_BUS);
  handlers = longGauges("handlers", "Number of event bus handlers in use", Label.EB_ADDRESS);
  pending = longGauges("pending", "Number of messages not processed yet", Label.EB_ADDRESS, Label.EB_SIDE);
  processed = counters("processed", "Number of processed messages", Label.EB_ADDRESS, Label.EB_SIDE);
  published = counters("published", "Number of messages published (publish / subscribe)", Label.EB_ADDRESS, Label.EB_SIDE);
  sent = counters("sent", "Number of messages sent (point-to-point)", Label.EB_ADDRESS, Label.EB_SIDE);
  received = counters("received", "Number of messages received", Label.EB_ADDRESS, Label.EB_SIDE);
  delivered = counters("delivered", "Number of messages delivered to handlers", Label.EB_ADDRESS, Label.EB_SIDE);
  discarded = counters("discarded", "Number of discarded messages", Label.EB_ADDRESS, Label.EB_SIDE);
  replyFailures = counters("replyFailures", "Number of message reply failures", Label.EB_ADDRESS, Label.EB_FAILURE);
  bytesRead = summaries("bytesRead", "Number of bytes received while reading messages from event bus cluster peers", Label.EB_ADDRESS);
  bytesWritten = summaries("bytesWritten", "Number of bytes sent while sending messages to event bus cluster peers", Label.EB_ADDRESS);
}
 
Example #19
Source File: Counters.java    From vertx-micrometer-metrics with Apache License 2.0 5 votes vote down vote up
public Counters(String name,
                String description,
                MeterRegistry registry,
                Label... keys) {
  this.name = name;
  this.description = description;
  this.registry = registry;
  this.keys = keys;
}
 
Example #20
Source File: Timers.java    From vertx-micrometer-metrics with Apache License 2.0 5 votes vote down vote up
public Timers(String name,
              String description,
              MeterRegistry registry,
              Label... keys) {
  this.name = name;
  this.description = description;
  this.registry = registry;
  this.keys = keys;
}
 
Example #21
Source File: Gauges.java    From vertx-micrometer-metrics with Apache License 2.0 5 votes vote down vote up
public Gauges(String name,
              String description,
              Supplier<T> tSupplier,
              ToDoubleFunction<T> dGetter,
              MeterRegistry registry,
              Label... keys) {
  this.name = name;
  this.description = description;
  this.tSupplier = tSupplier;
  this.dGetter = dGetter;
  this.registry = registry;
  this.keys = keys;
}
 
Example #22
Source File: VertxNetClientMetrics.java    From vertx-micrometer-metrics with Apache License 2.0 5 votes vote down vote up
VertxNetClientMetrics(MeterRegistry registry, MetricsDomain domain) {
  super(registry, domain);
  connections = longGauges("connections", "Number of connections to the remote host currently opened", Label.LOCAL, Label.REMOTE);
  bytesReceived = summaries("bytesReceived", "Number of bytes received from the remote host", Label.LOCAL, Label.REMOTE);
  bytesSent = summaries("bytesSent", "Number of bytes sent to the remote host", Label.LOCAL, Label.REMOTE);
  errorCount = counters("errors", "Number of errors", Label.LOCAL, Label.REMOTE, Label.CLASS_NAME);
}
 
Example #23
Source File: VertxNetServerMetrics.java    From vertx-micrometer-metrics with Apache License 2.0 5 votes vote down vote up
VertxNetServerMetrics(MeterRegistry registry, MetricsDomain domain) {
  super(registry, domain);
  connections = longGauges("connections", "Number of opened connections to the server", Label.LOCAL, Label.REMOTE);
  bytesReceived = summaries("bytesReceived", "Number of bytes received by the server", Label.LOCAL, Label.REMOTE);
  bytesSent = summaries("bytesSent", "Number of bytes sent by the server", Label.LOCAL, Label.REMOTE);
  errorCount = counters("errors", "Number of errors", Label.LOCAL, Label.REMOTE, Label.CLASS_NAME);
}
 
Example #24
Source File: VertxHttpClientMetrics.java    From vertx-micrometer-metrics with Apache License 2.0 5 votes vote down vote up
VertxHttpClientMetrics(MeterRegistry registry) {
  super(registry, MetricsDomain.HTTP_CLIENT);
  requests = longGauges("requests", "Number of requests waiting for a response", Label.LOCAL, Label.REMOTE, Label.HTTP_PATH, Label.HTTP_METHOD);
  requestCount = counters("requestCount", "Number of requests sent", Label.LOCAL, Label.REMOTE, Label.HTTP_PATH, Label.HTTP_METHOD);
  responseTime = timers("responseTime", "Response time", Label.LOCAL, Label.REMOTE, Label.HTTP_PATH, Label.HTTP_METHOD, Label.HTTP_CODE);
  responseCount = counters("responseCount", "Response count with codes", Label.LOCAL, Label.REMOTE, Label.HTTP_PATH, Label.HTTP_METHOD, Label.HTTP_CODE);
  wsConnections = longGauges("wsConnections", "Number of websockets currently opened", Label.LOCAL, Label.REMOTE);
}
 
Example #25
Source File: Labels.java    From vertx-micrometer-metrics with Apache License 2.0 5 votes vote down vote up
public static List<Tag> toTags(Label[] keys, String[] values) {
  if (keys.length == 0) {
    return Collections.emptyList();
  }
  List<Tag> tags = new ArrayList<>(keys.length);
  for (int i = 0; i < keys.length; i++) {
    if (values[i] != null) {
      String lowKey = keys[i].toString();
      tags.add(Tag.of(lowKey, values[i]));
    }
  }
  return tags;
}
 
Example #26
Source File: Summaries.java    From vertx-micrometer-metrics with Apache License 2.0 5 votes vote down vote up
public Summaries(String name,
                 String description,
                 MeterRegistry registry,
                 Label... keys) {
  this.name = name;
  this.description = description;
  this.registry = registry;
  this.keys = keys;
}
 
Example #27
Source File: VertxHttpServerMetrics.java    From vertx-micrometer-metrics with Apache License 2.0 5 votes vote down vote up
VertxHttpServerMetrics(MeterRegistry registry) {
  super(registry, MetricsDomain.HTTP_SERVER);
  requests = longGauges("requests", "Number of requests being processed", Label.LOCAL, Label.REMOTE, Label.HTTP_PATH, Label.HTTP_METHOD);
  requestCount = counters("requestCount", "Number of processed requests", Label.LOCAL, Label.REMOTE, Label.HTTP_PATH, Label.HTTP_METHOD, Label.HTTP_CODE);
  requestResetCount = counters("requestResetCount", "Number of requests reset", Label.LOCAL, Label.REMOTE, Label.HTTP_PATH, Label.HTTP_METHOD);
  processingTime = timers("responseTime", "Request processing time", Label.LOCAL, Label.REMOTE, Label.HTTP_PATH, Label.HTTP_METHOD, Label.HTTP_CODE);
  wsConnections = longGauges("wsConnections", "Number of websockets currently opened", Label.LOCAL, Label.REMOTE);
}
 
Example #28
Source File: AbstractMetrics.java    From vertx-micrometer-metrics with Apache License 2.0 4 votes vote down vote up
Counters counters(String name, String description, Label... keys) {
  return new Counters(domain.getPrefix() + name, description, registry, keys);
}
 
Example #29
Source File: AbstractMetrics.java    From vertx-micrometer-metrics with Apache License 2.0 4 votes vote down vote up
Gauges<LongAdder> longGauges(String name, String description, Label... keys) {
  return new Gauges<>(domain.getPrefix() + name, description, LongAdder::new, LongAdder::doubleValue, registry, keys);
}
 
Example #30
Source File: AbstractMetrics.java    From vertx-micrometer-metrics with Apache License 2.0 4 votes vote down vote up
Gauges<AtomicReference<Double>> doubleGauges(String name, String description, Label... keys) {
  return new Gauges<>(domain.getPrefix() + name, description, () -> new AtomicReference<>(0d), AtomicReference::get, registry, keys);
}