Java Code Examples for com.netflix.spectator.api.Registry#register()

The following examples show how to use com.netflix.spectator.api.Registry#register() . 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: DoubleDistributionSummary.java    From spectator with Apache License 2.0 5 votes vote down vote up
/**
 * Get or create a double distribution summary with the specified id.
 *
 * @param registry
 *     Registry to use.
 * @param id
 *     Identifier for the metric being registered.
 * @return
 *     Distribution summary corresponding to the id.
 */
static DoubleDistributionSummary get(Registry registry, Id id) {
  DoubleDistributionSummary instance = INSTANCES.get(id);
  if (instance == null) {
    final Clock c = registry.clock();
    DoubleDistributionSummary tmp = new DoubleDistributionSummary(c, id, RESET_FREQ);
    instance = INSTANCES.putIfAbsent(id, tmp);
    if (instance == null) {
      instance = tmp;
      registry.register(tmp);
    }
  }
  return instance;
}
 
Example 2
Source File: Jmx.java    From spectator with Apache License 2.0 2 votes vote down vote up
/**
 * Add meters based on configured JMX queries. See the {@link JmxConfig} class for more
 * details.
 *
 * @param registry
 *     Registry to use for reporting the data.
 * @param cfg
 *     Config object with the mappings.
 */
public static void registerMappingsFromConfig(Registry registry, Config cfg) {
  registry.register(new JmxMeter(registry, JmxConfig.from(cfg)));
}