Package com.codahale.metrics

Examples of com.codahale.metrics.JmxReporter


        Map<String, JmxReporter> reporters = REGISTRIES.get(registry);
        if (reporters == null) {
          reporters = new HashMap();
          REGISTRIES.put(registry, reporters);
        }
        JmxReporter reporter = reporters.get(domain);
        if (reporter == null) {
          Builder reporterBuilder = JmxReporter.forRegistry(registry)
              .filter(filter)
              .convertDurationsTo(defaultDurationUnit)
              .convertRatesTo(defaultRateUnit)
              .specificDurationUnits(durationUnits)
              .specificRateUnits(rateUnits)
              .inDomain(domain);
         
          reporter = reporterBuilder.build();
          reporter.start();
          reporters.put(domain, reporter);
        }
      }
    }
View Full Code Here


      for (Object event : Notifications.getLifecycleEvents(notification)) {
        if (event == Notifications.LifecycleEvent.SHUTDOWN) {
          synchronized (REGISTRIES) {
            Map<String, JmxReporter> reporters = REGISTRIES.get(getContext().getMetricRegistry());
            if (reporters != null) {
              JmxReporter reporter = reporters.remove(domain);
              if (reporter != null) {
                reporter.stop();
              }
            }
          }
        }
      }
View Full Code Here

        /*
         * MBeans for VisualVM, JConsole, or JMX
         */
        if (ninjaProps.getBooleanWithDefault("metrics.mbeans.enabled", true)) {

            JmxReporter reporter = JmxReporter.forRegistry(metricRegistry)
                    .inDomain(applicationName).build();

            reporter.start();

            reporters.add(reporter);

            log.debug("Started Ninja Metrics MBeans reporter");

View Full Code Here

    this.metricRegistry = metricRegistry;
  }

  @Override
  public JmxReporter get() {
    JmxReporter reporter = JmxReporter.forRegistry(metricRegistry).build();
    reporter.start();
    return reporter;
  }
View Full Code Here

        // Guarantee unique name
        domain += "-" + REPORTER_ID.incrementAndGet();

        if (jmxReporter) {
            JmxReporter reporter = JmxReporter
                    .forRegistry(registry)
                    .inDomain(domain)
                    .build();

            reporter.start();
            return reporter;
        }

        return null;
View Full Code Here

      REGISTRY.registerAll(new ThreadStatesGaugeSet());
    }

    private static JmxReporter getJmxReporter() {
      if (config.getBoolean(ExecConstants.METRICS_JMX_OUTPUT_ENABLED)) {
        JmxReporter reporter = JmxReporter.forRegistry(getInstance()).build();
        reporter.start();

        return reporter;
      } else {
        return null;
      }
View Full Code Here

    public static void main(String[] args) {
        LOG.info("starting echo server");

        NioTcpServer server = new NioTcpServer();
        MetricRegistry metrics = new MetricRegistry();
        JmxReporter reporter = JmxReporter.forRegistry(metrics).build();
        reporter.start();
        server.getSessionConfig().setIdleTimeInMillis(IdleStatus.READ_IDLE, 60 * 600 * 1000);
        server.getSessionConfig().setIdleTimeInMillis(IdleStatus.WRITE_IDLE, 60 * 600 * 1000);

        // create the filter chain for this service
        server.setFilters(new MonitoringFilter(metrics), new LoggingFilter("LoggingFilter1"),
                ((NioTcpEchoServerWithMonitoring) server).new TcpEchoFilter());
        server.setIoHandler(new AbstractIoHandler() {
            @Override
            public void sessionOpened(final IoSession session) {
                LOG.info("session opened {}", session);

                final String welcomeStr = "welcome\n";
                final ByteBuffer bf = ByteBuffer.allocate(welcomeStr.length());
                bf.put(welcomeStr.getBytes());
                bf.flip();
                session.write(bf);

            }

            @Override
            public void exceptionCaught(IoSession session, Exception cause) {
                cause.printStackTrace();
            }
        });

        try {
            final SocketAddress address = new InetSocketAddress(51000);
            server.bind(address);
            LOG.debug("Running the server for 25 sec");
            Thread.sleep(25000 * 1000);
            LOG.debug("Unbinding the UDP port");
            server.unbind();
        } catch (final InterruptedException e) {
            LOG.error("Interrupted exception", e);
        } finally {
            reporter.stop();
        }
    }
View Full Code Here

  public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception {
    MetricRegistry summaryRegistry = new MetricRegistry();
    MetricRegistry detailedRegistry = new MetricRegistry();
   
    if (isJmxPublish()) {
      JmxReporter jmxReporter = JmxReporter.forRegistry(summaryRegistry).build();
      jmxReporter.start();
      jmxReporter = JmxReporter.forRegistry(detailedRegistry).build();
      jmxReporter.start();
    }
   
    if (isSlf4jPublish()) {
      Slf4jReporter logReporter = Slf4jReporter.forRegistry(summaryRegistry)
          .outputTo(LoggerFactory.getLogger(OpenGammaMetricRegistry.class))
View Full Code Here

                                          .outputTo(LoggerFactory.getLogger(OpenGammaMetricRegistry.class))
                                          .convertRatesTo(TimeUnit.SECONDS)
                                          .convertDurationsTo(TimeUnit.MILLISECONDS)
                                          .build();
    logReporter.start(1, TimeUnit.MINUTES);
    JmxReporter jmxReporter = JmxReporter.forRegistry(s_summaryInstance).build();
    jmxReporter.start();
  }
View Full Code Here

        }
    }

    protected void setupReporters() {
        logger.info("Initializing Metrics JMX Reporter");
        final JmxReporter jmxReporter = JmxReporter.forRegistry(metrics).build();
        jmxReporter.start();

        setupGraphiteReporter();
    }
View Full Code Here

TOP

Related Classes of com.codahale.metrics.JmxReporter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.