congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
SharedMetricRegistries
Code IndexAdd Tabnine to your IDE (free)

How to use
SharedMetricRegistries
in
com.codahale.metrics

Best Java code snippets using com.codahale.metrics.SharedMetricRegistries (Showing top 20 results out of 540)

Refine searchRefine arrow

  • MetricRegistry
  • SortedMap
  • Matchers
origin: signalapp/Signal-Server

public LockingRateLimiter(ReplicatedJedisPool cacheClient, String name, int bucketSize, double leakRatePerMinute) {
 super(cacheClient, name, bucketSize, leakRatePerMinute);
 MetricRegistry metricRegistry = SharedMetricRegistries.getOrCreate(Constants.METRICS_NAME);
 this.meter = metricRegistry.meter(name(getClass(), name, "locked"));
}
origin: io.dropwizard.metrics/metrics-core

public static MetricRegistry getOrCreate(String name) {
  final MetricRegistry existing = REGISTRIES.get(name);
  if (existing == null) {
    final MetricRegistry created = new MetricRegistry();
    final MetricRegistry raced = add(name, created);
    if (raced == null) {
      return created;
    }
    return raced;
  }
  return existing;
}
origin: stagemonitor/stagemonitor

@AfterClass
public static void resetStagemonitor() {
  Stagemonitor.reset();
  SharedMetricRegistries.clear();
}
origin: io.dropwizard.metrics/metrics-core

/**
 * Creates a new registry and sets it as the default one under the provided name.
 *
 * @param name the registry name
 * @return the default registry
 * @throws IllegalStateException if the name has already been set
 */
public synchronized static MetricRegistry setDefault(String name) {
  final MetricRegistry registry = getOrCreate(name);
  return setDefault(name, registry);
}
origin: astefanutti/metrics-aspectj

@Test
public void timedMethodsNotCalledYet() {
  assertThat("Shared metric registry is not created", SharedMetricRegistries.names(), hasItem(REGISTRY_NAME));
  MetricRegistry registry = SharedMetricRegistries.getOrCreate(REGISTRY_NAME);
  assertThat("Timers are not registered correctly", registry.getTimers().keySet(), is(equalTo(absoluteMetricNames())));
  // Make sure that all the timers haven't been called yet
  assertThat("Timer counts are incorrect", registry.getTimers().values(), everyItem(Matchers.<Timer>hasProperty("count", equalTo(0L))));
}
origin: astefanutti/metrics-aspectj

@Test
public void callExceptionMeteredStaticMethodsOnceWithoutThrowing() {
  Runnable runnableThatDoesNoThrowExceptions = new Runnable() {
    @Override
    public void run() {
    }
  };
  // Call the metered methods and assert they haven't been marked
  MeteredStaticMethodWithExceptions.illegalArgumentExceptionMeteredStaticMethod(runnableThatDoesNoThrowExceptions);
  MeteredStaticMethodWithExceptions.exceptionMeteredStaticMethod(runnableThatDoesNoThrowExceptions);
  assertThat("Shared metric registry is not created", SharedMetricRegistries.names(), hasItem(REGISTRY_NAME));
  MetricRegistry registry = SharedMetricRegistries.getOrCreate(REGISTRY_NAME);
  assertThat("Meters are not registered correctly", registry.getMeters().keySet(), is(equalTo(absoluteMetricNames())));
  assertThat("Meter count is incorrect", registry.getMeters().get(absoluteMetricName(0)).getCount(), is(equalTo(METER_COUNTS[0].get())));
  assertThat("Meter count is incorrect", registry.getMeters().get(absoluteMetricName(1)).getCount(), is(equalTo(METER_COUNTS[1].get())));
}
origin: astefanutti/metrics-aspectj

@Test
public void timedMethodNotCalledYet() {
  assertThat("Shared metric registry is not created", SharedMetricRegistries.names(), hasItem(REGISTRY_NAME));
  MetricRegistry registry = SharedMetricRegistries.getOrCreate(REGISTRY_NAME);
  assertThat("Timer is not registered correctly", registry.getTimers(), hasKey(TIMER_NAME));
  Timer timer = registry.getTimers().get(TIMER_NAME);
  // Make sure that the timer hasn't been called yet
  assertThat("Timer count is incorrect", timer.getCount(), is(equalTo(0L)));
}
origin: astefanutti/metrics-aspectj

@Test
public void metricsMethodNotCalledYet() {
  assertThat("Shared metric registry is not created", SharedMetricRegistries.names(), hasItem(REGISTRY_NAME));
  MetricRegistry registry = SharedMetricRegistries.getOrCreate(REGISTRY_NAME);
  assertThat("Metrics are not registered correctly", registry.getMetrics().keySet(), is(equalTo(absoluteMetricNames())));
  // Make sure that the metrics haven't been called yet
  assertThat("Meter count is incorrect", registry.getMeters().get(absoluteMetricName("exception")).getCount(), is(equalTo(0L)));
  assertThat("Meter count is incorrect", registry.getMeters().get(absoluteMetricName("meter")).getCount(), is(equalTo(0L)));
  assertThat("Timer count is incorrect", registry.getTimers().get(absoluteMetricName("timer")).getCount(), is(equalTo(0L)));
}
origin: astefanutti/metrics-aspectj

@Test
public void gaugeCalledWithDefaultValue() {
  assertThat("Shared metric registry is not created", SharedMetricRegistries.names(), hasItem(REGISTRY_NAME));
  MetricRegistry registry = SharedMetricRegistries.getOrCreate(REGISTRY_NAME);
  assertThat("Gauge is not registered correctly", registry.getGauges(), hasKey(GAUGE_NAME));
  @SuppressWarnings("unchecked")
  Gauge<Long> gauge = registry.getGauges().get(GAUGE_NAME);
  // Make sure that the gauge has the expected value
  assertThat("Gauge value is incorrect", gauge.getValue(), is(equalTo(0L)));
}
origin: astefanutti/metrics-aspectj

@Test
public void meteredMethodNotCalledYet() {
  assertThat("Shared metric registry is not created", SharedMetricRegistries.names(), hasItem(REGISTRY_NAME));
  MetricRegistry registry = SharedMetricRegistries.getOrCreate(REGISTRY_NAME);
  assertThat("Meter is not registered correctly", registry.getMeters(), hasKey(METER_NAME));
  Meter meter = registry.getMeters().get(METER_NAME);
  // Make sure that the meter hasn't been called yet
  assertThat("Meter count is incorrect", meter.getCount(), is(equalTo(0L)));
}
origin: NGDATA/hbase-indexer

private void copyIndexingMetrics3ToCounters(Context context) {
  for (String name : SharedMetricRegistries.names()) {
    MetricRegistry metricRegistry = SharedMetricRegistries.getOrCreate(name);
    for (Map.Entry<String, com.codahale.metrics.Counter> entry : metricRegistry.getCounters().entrySet()) {
      addCounting(context, entry.getKey(), entry.getValue(), 1);
    }
    for (Map.Entry<String, com.codahale.metrics.Histogram> entry : metricRegistry.getHistograms().entrySet()) {
      addCounting(context, entry.getKey(), entry.getValue(), 1);
    }
    for (Map.Entry<String, com.codahale.metrics.Meter> entry : metricRegistry.getMeters().entrySet()) {
      addCounting(context, entry.getKey(), entry.getValue(), 1);
    }
    for (Map.Entry<String, com.codahale.metrics.Timer> entry : metricRegistry.getTimers().entrySet()) {
      long nanosPerMilliSec = 1000 * 1000;
      addCounting(context, entry.getKey(), entry.getValue(), nanosPerMilliSec);
    }
  }
}
origin: astefanutti/metrics-aspectj

  @Test
  public void metricMethodsWithDefaultNamingConvention() {
    assertThat("Shared metric registry is not created", SharedMetricRegistries.names(), hasItem(REGISTRY_NAME));
    MetricRegistry registry = SharedMetricRegistries.getOrCreate(REGISTRY_NAME);
    assertThat("Metrics are not registered correctly", registry.getMetrics().keySet(), is(equalTo(metricNames())));
  }
}
origin: juzu/juzu

@Test
public void testTimer() throws Exception {
 SharedMetricRegistries.clear();                                                             //<1>
 MockApplication<File> application = application(InjectorProvider.GUICE, "examples.metrics");//<2>
 application.init();
 MockClient client = application.client();
 MockViewBridge view = client.render();                                                      //<3>
 assertEquals("ok", view.assertStringResponse());
 assertEquals(Collections.singleton("examples.metrics"), SharedMetricRegistries.names());    //<4>
 MetricRegistry registry = SharedMetricRegistries.getOrCreate("examples.metrics");
 Timer timer = registry.getTimers().get("juzu.responses");                                   //<5>
 assertEquals(1, timer.getCount());
 Meter meter = registry.getMeters().get("custom");                                           //<6>
 assertNotNull(meter);
}
// end::testTimer[]
origin: gentics/mesh

private static long getCount(String name, long fallback) {
  MetricRegistry registry = SharedMetricRegistries.getOrCreate("mesh");
  SortedMap<String, Counter> counters = registry.getCounters();
  Counter counter = counters.get(name);
  if (counter == null) {
    return fallback;
  } else {
    return counter.getCount();
  }
}
origin: apache/flume

  .setMetricRegistry(SharedMetricRegistries.getOrCreate(morphlineFileAndId))
  .build();
  new File(morphlineFile), morphlineId, morphlineContext, finalChild, override);
this.mappingTimer = morphlineContext.getMetricRegistry().timer(
  MetricRegistry.name("morphline.app", Metrics.ELAPSED_TIME));
this.numRecords = morphlineContext.getMetricRegistry().meter(
  MetricRegistry.name("morphline.app", Metrics.NUM_RECORDS));
this.numFailedRecords = morphlineContext.getMetricRegistry().meter(
origin: org.nuxeo.elasticsearch/nuxeo-elasticsearch-core

public ElasticSearchIndexingImpl(ElasticSearchAdminImpl esa) {
  this.esa = esa;
  MetricRegistry registry = SharedMetricRegistries.getOrCreate(MetricsService.class.getName());
  indexTimer = registry.timer(MetricRegistry.name("nuxeo", "elasticsearch", "service", "index"));
  deleteTimer = registry.timer(MetricRegistry.name("nuxeo", "elasticsearch", "service", "delete"));
  bulkIndexTimer = registry.timer(MetricRegistry.name("nuxeo", "elasticsearch", "service", "bulkIndex"));
  this.jsonESDocumentWriter = new JsonESDocumentWriter();// default writer
  this.useExternalVersion = esa.useExternalVersion();
}
origin: signalapp/Signal-Server

public PushSender(ApnFallbackManager apnFallbackManager,
         GCMSender gcmSender, APNSender apnSender,
         WebsocketSender websocketSender, int queueSize)
{
 this.apnFallbackManager = apnFallbackManager;
 this.gcmSender          = gcmSender;
 this.apnSender          = apnSender;
 this.webSocketSender    = websocketSender;
 this.queueSize          = queueSize;
 this.executor           = new BlockingThreadPoolExecutor(50, queueSize);
 SharedMetricRegistries.getOrCreate(Constants.METRICS_NAME)
            .register(name(PushSender.class, "send_queue_depth"),
                 (Gauge<Integer>) executor::getSize);
}
origin: signalapp/Signal-Server

 throws Exception
SharedMetricRegistries.add(Constants.METRICS_NAME, environment.metrics());
environment.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
environment.getObjectMapper().setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
environment.jersey().register(new DeviceLimitExceededExceptionMapper());
environment.metrics().register(name(CpuUsageGauge.class, "cpu"), new CpuUsageGauge());
environment.metrics().register(name(FreeMemoryGauge.class, "free_memory"), new FreeMemoryGauge());
environment.metrics().register(name(NetworkSentGauge.class, "bytes_sent"), new NetworkSentGauge());
environment.metrics().register(name(NetworkReceivedGauge.class, "bytes_received"), new NetworkReceivedGauge());
origin: sonatype/nexus-public

public InstrumentedConnectionFactory(final ConnectionFactory connectionFactory) {
 super(connectionFactory, SharedMetricRegistries.getOrCreate("nexus").timer("connection-duration"));
 this.connectionFactory = connectionFactory;
}
origin: smoketurner/notification

/** Constructor */
public CursorResolver() {
 final MetricRegistry registry = SharedMetricRegistries.getOrCreate("default");
 this.siblingCounts = registry.histogram(name(CursorResolver.class, "sibling-counts"));
}
com.codahale.metricsSharedMetricRegistries

Javadoc

A map of shared, named metric registries.

Most used methods

  • getOrCreate
  • add
  • clear
  • setDefault
    Sets the provided registry as the default one under the provided name
  • tryGetDefault
    Same as #getDefault() except returns null when the default registry has not been set.
  • getDefault
    Gets the name of the default registry, if it has been set
  • names
  • remove

Popular in Java

  • Reading from database using SQL prepared statement
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • notifyDataSetChanged (ArrayAdapter)
  • scheduleAtFixedRate (Timer)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Option (scala)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now