@Test
  public void createsMetricsForTheHandler() throws Exception {
    final ContentResponse response =
        client.GET("http://localhost:" + connector.getLocalPort() + "/hello");

    assertThat(response.getStatus()).isEqualTo(404);

    assertThat(registry.getNames())
        .containsOnly(
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.1xx-responses",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.2xx-responses",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.3xx-responses",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.4xx-responses",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.5xx-responses",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.requests",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.active-suspended",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.async-dispatches",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.async-timeouts",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.get-requests",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.put-requests",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.active-dispatches",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.trace-requests",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.other-requests",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.connect-requests",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.dispatches",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.head-requests",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.post-requests",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.options-requests",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.active-requests",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.delete-requests",
            "org.eclipse.jetty.server.handler.DefaultHandler.handler.move-requests");
  }
 @PreDestroy
 public void destroy() {
   log.info("Remove Cache Manager metrics");
   SortedSet<String> names = metricRegistry.getNames();
   names.forEach(metricRegistry::remove);
   log.info("Closing Cache Manager");
   cacheManager.shutdown();
 }
Esempio n. 3
0
  /**
   * Closes the named registry
   *
   * @param name the registry name to close
   */
  public void closeRegistry(final String name) {
    if (name == null || name.trim().isEmpty())
      throw new IllegalArgumentException("Metric registry name was null");
    final String mname = name.trim();
    MetricRegistry m = subRegistries.remove(mname);
    if (m != null) {
      for (String metricName : m.getNames()) {
        m.remove(metricName);
      }
    }
    JmxReporter reporter = subReporters.remove(mname);
    if (reporter != null) {

      try {
        reporter.close();
      } catch (Exception x) {
        /* No Op */
      }
    }
  }
 @Test
 public void testRegistration() {
   assertEquals(Collections.singleton("the_name"), SharedMetricRegistries.names());
   registry = SharedMetricRegistries.getOrCreate("the_name");
   assertTrue(registry.getNames().size() > 0);
 }