Package com.yammer.metrics.core

Examples of com.yammer.metrics.core.MetricName


      tearDown();
      System.setProperty(StatsCollectorFactoryCoda.environmentPrefixSystemPropertyName,"Hello.");
      setUp();
      StatsCollectorFactoryCoda.MetricNamingStrategy strategy = statsCollectorFactory.getNamingStrategy();
      ClusterId clusterId = new ClusterId("app","cluster");
      MetricName name = strategy.createName(clusterId, "metric");

      assertEquals("metric", name.getName());
      assertEquals("app-cluster", name.getGroup());
      assertTrue(strategy.buildPrefix(clusterId, new Destination() { @Override public String toString() { return "destination"; } }).startsWith("Hello."));

      // make sure setting the environment prefix doesn't effect the -D option
      statsCollectorFactory.setEnvironmentPrefix("otherEnvPrefix");
      assertTrue(strategy.buildPrefix(clusterId, new Destination() { @Override public String toString() { return "destination"; } }).startsWith("Hello."));
View Full Code Here


    Class<?> sourceClass = metricKey.getSourceClass();

    String[] path = metricKey.getPath();
    String name = Joiner.on('.').join(path);

    return new MetricName(sourceClass, name);
  }
View Full Code Here

    return new MetricName(sourceClass, name);
  }

  @Override
  public MetricTimer getTimer(MetricKey metricKey) {
    MetricName metricName = toMetricName(metricKey);
    return new MetricTimerAdapter(registry.newTimer(metricName, TimeUnit.MILLISECONDS, TimeUnit.SECONDS));
  }
View Full Code Here

    return new MetricTimerAdapter(registry.newTimer(metricName, TimeUnit.MILLISECONDS, TimeUnit.SECONDS));
  }

  @Override
  public MetricHistogram getHistogram(MetricKey metricKey) {
    MetricName metricName = toMetricName(metricKey);
    boolean biased = true;
    return new MetricHistogramAdapter(registry.newHistogram(metricName, biased));
  }
View Full Code Here

    return new MetricHistogramAdapter(registry.newHistogram(metricName, biased));
  }

  @Override
  public MetricMeter getCounter(MetricKey metricKey) {
    MetricName metricName = toMetricName(metricKey);
    String eventType = "events";
    return new MetricMeterAdapter(registry.newMeter(metricName, eventType, TimeUnit.SECONDS));
  }
View Full Code Here

            }
        }
    }
   
    public static final MetricName newMetricName(String scope, String name) {
        return new MetricName("com.urbanairship.statshtable", "StatsHTable", name, scope);
    }
View Full Code Here

     */
    public SHTimerMetric newSHTimerMetric(String scope, String name) {
        if(scope == null) {
            scope = "";
        }
        MetricName metricName = StatsHTable.newMetricName(scope + scopeSuffix, name);
        SHTimerMetric existingMetric = (SHTimerMetric)allMetrics().get(metricName);
        if(existingMetric != null) {
            return existingMetric;
        }
        SHTimerMetric newMetric = new SHTimerMetric(TimeUnit.MILLISECONDS,
View Full Code Here

  private static final Log LOG = LogFactory.getLog(ControllerServerEventHandler.class);
  private final Meter _connectionMeter;
  private final AtomicLong _connections = new AtomicLong();

  public ControllerServerEventHandler() {
    Metrics.newGauge(new MetricName(ORG_APACHE_BLUR, BLUR, "Connections"), new Gauge<Long>() {
      @Override
      public Long value() {
        return null;
      }
    });
    _connectionMeter = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, BLUR, "Connections/s"), "Connections/s",
        TimeUnit.SECONDS);
  }
View Full Code Here

  public static void setupJvmMetrics() {
    final MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
    final OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();

    Metrics.newGauge(new MetricName(ORG_APACHE_BLUR, SYSTEM, LOAD_AVERAGE), new Gauge<Double>() {
      @Override
      public Double value() {
        return operatingSystemMXBean.getSystemLoadAverage();
      }
    });
    Metrics.newGauge(new MetricName(ORG_APACHE_BLUR, JVM, HEAP_USED), new Gauge<Long>() {
      @Override
      public Long value() {
        MemoryUsage usage = memoryMXBean.getHeapMemoryUsage();
        return usage.getUsed();
      }
    });
    Method processCpuTimeMethod = null;
    for (Method method : operatingSystemMXBean.getClass().getDeclaredMethods()) {
      if (method.getName().equals("getProcessCpuTime")) {
        method.setAccessible(true);
        processCpuTimeMethod = method;
      }
    }
    final double availableProcessors = operatingSystemMXBean.getAvailableProcessors();
    if (processCpuTimeMethod != null) {
      final Method pctm = processCpuTimeMethod;
      Metrics.newGauge(new MetricName(ORG_APACHE_BLUR, JVM, CPU_USED), new Gauge<Double>() {
        private long start = System.nanoTime();
        private long lastCpuTime = getProcessCputTime(pctm, operatingSystemMXBean);

        @Override
        public Double value() {
View Full Code Here

  public static interface ReleaseReader {
    void release() throws IOException;
  }

  public void init() throws KeeperException, InterruptedException, IOException {
    MetricName tableCount = new MetricName(ORG_APACHE_BLUR, BLUR, TABLE_COUNT, _cluster);
    MetricName indexCount = new MetricName(ORG_APACHE_BLUR, BLUR, INDEX_COUNT, _cluster);
    MetricName segmentCount = new MetricName(ORG_APACHE_BLUR, BLUR, SEGMENT_COUNT, _cluster);
    MetricName indexMemoryUsage = new MetricName(ORG_APACHE_BLUR, BLUR, INDEX_MEMORY_USAGE, _cluster);

    Metrics.newGauge(tableCount, new AtomicLongGauge(_tableCount));
    Metrics.newGauge(indexCount, new AtomicLongGauge(_indexCount));
    Metrics.newGauge(segmentCount, new AtomicLongGauge(_segmentCount));
    Metrics.newGauge(indexMemoryUsage, new AtomicLongGauge(_indexMemoryUsage));
View Full Code Here

TOP

Related Classes of com.yammer.metrics.core.MetricName

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.