com.netflix.spectator.api.Registry.config()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中com.netflix.spectator.api.Registry.config方法的一些代码示例,展示了Registry.config的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Registry.config方法的具体详情如下:
包路径:com.netflix.spectator.api.Registry
类名称:Registry
方法名:config

Registry.config介绍

[英]Configuration settings used for this registry.
[中]用于此注册表的配置设置。

代码示例

代码示例来源:origin: org.springframework.metrics/spring-metrics

@Override
public RegistryConfig config() {
  return composite.config();
}

代码示例来源:origin: Netflix/spectator

/** Create a new instance. */
Builder(Registry registry, Id baseId) {
 super();
 this.registry = registry;
 this.baseId = baseId;
 this.delay = registry.config().gaugePollingFrequency().toMillis();
}

代码示例来源:origin: com.netflix.spectator/spectator-api

/** Create a new instance. */
Builder(Registry registry, Id baseId) {
 super();
 this.registry = registry;
 this.baseId = baseId;
 this.delay = registry.config().gaugePollingFrequency().toMillis();
}

代码示例来源:origin: Netflix/spectator

/**
 * Log a warning and if enabled propagate the exception {@code t}. As a general rule
 * instrumentation code should degrade gracefully and avoid impacting the core application. If
 * the user makes a mistake and causes something to break, then it should not impact the
 * application unless that mistake triggers a problem outside of the instrumentation code.
 * However, in test code it is often better to throw so that mistakes are caught and corrected.
 *
 * This method is used to handle exceptions internal to the instrumentation code. Propagation
 * is controlled by the {@link RegistryConfig#propagateWarnings()} setting. If the setting
 * is true, then the exception will be propagated. Otherwise the exception will only get logged
 * as a warning.
 *
 * @param msg
 *     Message written out to the log.
 * @param t
 *     Exception to log and optionally propagate.
 */
default void propagate(String msg, Throwable t) {
 LoggerFactory.getLogger(getClass()).warn(msg, t);
 if (config().propagateWarnings()) {
  if (t instanceof RuntimeException) {
   throw (RuntimeException) t;
  } else {
   throw new RuntimeException(t);
  }
 }
}
/**

代码示例来源:origin: com.netflix.spectator/spectator-api

/**
 * Log a warning and if enabled propagate the exception {@code t}. As a general rule
 * instrumentation code should degrade gracefully and avoid impacting the core application. If
 * the user makes a mistake and causes something to break, then it should not impact the
 * application unless that mistake triggers a problem outside of the instrumentation code.
 * However, in test code it is often better to throw so that mistakes are caught and corrected.
 *
 * This method is used to handle exceptions internal to the instrumentation code. Propagation
 * is controlled by the {@link RegistryConfig#propagateWarnings()} setting. If the setting
 * is true, then the exception will be propagated. Otherwise the exception will only get logged
 * as a warning.
 *
 * @param msg
 *     Message written out to the log.
 * @param t
 *     Exception to log and optionally propagate.
 */
default void propagate(String msg, Throwable t) {
 LoggerFactory.getLogger(getClass()).warn(msg, t);
 if (config().propagateWarnings()) {
  if (t instanceof RuntimeException) {
   throw (RuntimeException) t;
  } else {
   throw new RuntimeException(t);
  }
 }
}
/**

代码示例来源:origin: Netflix/spectator

/**
 * Provided for backwards compatibility to support the {@link Registry#register(Meter)}
 * method. Use the builder created with {@link #using(Registry)} instead.
 *
 * @deprecated This method only exists to allow for backwards compatibility and should
 * be considered an internal detail. Scheduled to be removed in 2.0.
 */
@Deprecated
public static void monitorMeter(Registry registry, Meter meter) {
 ConcurrentMap<Id, Object> state = registry.state();
 Object c = Utils.computeIfAbsent(state, meter.id(), MeterState::new);
 if (!(c instanceof MeterState)) {
  Utils.propagateTypeError(registry, meter.id(), MeterState.class, c.getClass());
 } else {
  MeterState t = (MeterState) c;
  t.add(meter);
  long delay = registry.config().gaugePollingFrequency().toMillis();
  t.schedule(registry, null, delay);
 }
}

代码示例来源:origin: com.netflix.spectator/spectator-api

/**
 * Provided for backwards compatibility to support the {@link Registry#register(Meter)}
 * method. Use the builder created with {@link #using(Registry)} instead.
 *
 * @deprecated This method only exists to allow for backwards compatibility and should
 * be considered an internal detail. Scheduled to be removed in 2.0.
 */
@Deprecated
public static void monitorMeter(Registry registry, Meter meter) {
 ConcurrentMap<Id, Object> state = registry.state();
 Object c = Utils.computeIfAbsent(state, meter.id(), MeterState::new);
 if (!(c instanceof MeterState)) {
  Utils.propagateTypeError(registry, meter.id(), MeterState.class, c.getClass());
 } else {
  MeterState t = (MeterState) c;
  t.add(meter);
  long delay = registry.config().gaugePollingFrequency().toMillis();
  t.schedule(registry, null, delay);
 }
}

相关文章