public void initMetrics(SystemStreamPartition systemStreamPartition) { this.noMoreMessageGaugeMap.putIfAbsent(systemStreamPartition, metricsRegistry.<Boolean>newGauge(group, "no-more-messages-" + systemStreamPartition, false)); this.blockingPollCountMap.putIfAbsent(systemStreamPartition, metricsRegistry.newCounter(group, "blocking-poll-count-" + systemStreamPartition)); this.blockingPollTimeoutCountMap.putIfAbsent(systemStreamPartition, metricsRegistry.newCounter(group, "blocking-poll-timeout-count-" + systemStreamPartition)); metricsRegistry.<Integer>newGauge(group, new BufferGauge(systemStreamPartition, "buffered-message-count-" + systemStreamPartition)); metricsRegistry.<Long>newGauge(group, new BufferSizeGauge(systemStreamPartition, "buffered-message-size-" + systemStreamPartition)); }
public <T> Gauge<T> newGauge(String name, T value) { return registry.newGauge(groupName, new Gauge<T>((prefix + name).toLowerCase(), value)); }
public <T> Gauge<T> newGauge(String name, T value) { return registry.newGauge(groupName, new Gauge<T>((prefix + name).toLowerCase(), value)); }
public <T> Gauge<T> newGauge(String name, T value) { return registry.newGauge(groupName, new Gauge<T>((prefix + name).toLowerCase(), value)); }
public <T> Gauge<T> newGauge(String name, T value) { return registry.newGauge(groupName, new Gauge<T>((prefix + name).toLowerCase(), value)); }
public void initMetrics(SystemStreamPartition systemStreamPartition) { this.noMoreMessageGaugeMap.putIfAbsent(systemStreamPartition, metricsRegistry.<Boolean>newGauge(group, "no-more-messages-" + systemStreamPartition, false)); this.blockingPollCountMap.putIfAbsent(systemStreamPartition, metricsRegistry.newCounter(group, "blocking-poll-count-" + systemStreamPartition)); this.blockingPollTimeoutCountMap.putIfAbsent(systemStreamPartition, metricsRegistry.newCounter(group, "blocking-poll-timeout-count-" + systemStreamPartition)); metricsRegistry.<Integer>newGauge(group, new BufferGauge(systemStreamPartition, "buffered-message-count-" + systemStreamPartition)); metricsRegistry.<Long>newGauge(group, new BufferSizeGauge(systemStreamPartition, "buffered-message-size-" + systemStreamPartition)); }
SamzaHistogram(MetricsRegistry registry, String group, String name, List<Double> percentiles) { this.registry = registry; this.histogram = new Histogram(new ExponentiallyDecayingReservoir()); this.percentiles = percentiles; this.gauges = percentiles.stream() .filter(x -> x > 0 && x <= 100) .collect( Collectors.toMap(Function.identity(), x -> this.registry.newGauge(group, name + "_" + String.valueOf(0), 0D))); }
public <T> Gauge<T> newGauge(String name, final ValueFunction<T> valueFunc) { return registry.newGauge(groupName, new Gauge<T>((prefix + name).toLowerCase(), valueFunc.getValue()) { @Override public T getValue() { return valueFunc.getValue(); } }); }
public <T> Gauge<T> newGauge(String name, final ValueFunction<T> valueFunc) { return registry.newGauge(groupName, new Gauge<T>((prefix + name).toLowerCase(), valueFunc.getValue()) { @Override public T getValue() { return valueFunc.getValue(); } }); }
public <T> Gauge<T> newGauge(String name, final ValueFunction<T> valueFunc) { return registry.newGauge(groupName, new Gauge<T>((prefix + name).toLowerCase(), valueFunc.getValue()) { @Override public T getValue() { return valueFunc.getValue(); } }); }
public <T> Gauge<T> newGauge(String name, final ValueFunction<T> valueFunc) { return registry.newGauge(groupName, new Gauge<T>((prefix + name).toLowerCase(), valueFunc.getValue()) { @Override public T getValue() { return valueFunc.getValue(); } }); }
public <T> Gauge<T> newGauge(String name, final ValueFunction<T> valueFunc) { return registry.newGauge(groupName, new Gauge<T>((prefix + name).toLowerCase(), valueFunc.getValue()) { @Override public T getValue() { return valueFunc.getValue(); } }); }
public SamzaHistogram(MetricsRegistry registry, String group, String name, List<Double> percentiles) { this.histogram = new Histogram(new ExponentiallyDecayingReservoir()); this.percentiles = percentiles; this.gauges = this.percentiles.stream() .filter(x -> x > 0 && x <= 100) .collect(Collectors.toMap(Function.identity(), x -> registry.newGauge(group, new HistogramGauge(x, name + "_" + String.valueOf(x), 0D)))); }
/** * Create a new gauge by delegating to the underlying metrics registry * @param name name of the gauge * @param supplier a function that supplies the value * @param <T> type of the value * @return newly created gauge */ public <T> Gauge<T> newGauge(String name, Supplier<T> supplier) { return metricsRegistry.newGauge(groupName, new SupplierGauge(getMetricFullName(name), supplier)); }
/** * Create a new gauge by delegating to the underlying metrics registry * @param name name of the gauge * @param supplier a function that supplies the value * @param <T> type of the value * @return newly created gauge */ public <T> Gauge<T> newGauge(String name, Supplier<T> supplier) { return metricsRegistry.newGauge(groupName, new SupplierGauge(getMetricFullName(name), supplier)); }
/** * Create a new gauge by delegating to the underlying metrics registry * @param name name of the gauge * @param supplier a function that supplies the value * @param <T> type of the value * @return newly created gauge */ public <T> Gauge<T> newGauge(String name, Supplier<T> supplier) { return metricsRegistry.newGauge(groupName, new SupplierGauge(getMetricFullName(name), supplier)); }
/** * Create a new gauge by delegating to the underlying metrics registry * @param name name of the gauge * @param supplier a function that supplies the value * @param <T> type of the value * @return newly created gauge */ public <T> Gauge<T> newGauge(String name, Supplier<T> supplier) { return metricsRegistry.newGauge(groupName, new SupplierGauge(getMetricFullName(name), supplier)); }
/** * Create a new gauge by delegating to the underlying metrics registry * @param name name of the gauge * @param supplier a function that supplies the value * @param <T> type of the value * @return newly created gauge */ public <T> Gauge<T> newGauge(String name, Supplier<T> supplier) { return metricsRegistry.newGauge(groupName, new SupplierGauge(getMetricFullName(name), supplier)); }
public static Context getMockContext() { Context context = new MockContext(); MetricsRegistry metricsRegistry = mock(MetricsRegistry.class); doAnswer(args -> new Timer((String) args.getArguments()[0])).when(metricsRegistry).newTimer(anyString(), anyString()); doAnswer(args -> new Counter((String) args.getArguments()[0])).when(metricsRegistry).newCounter(anyString(), anyString()); doAnswer(args -> new Gauge((String) args.getArguments()[0], 0)).when(metricsRegistry).newGauge(anyString(), any()); doReturn(metricsRegistry).when(context.getContainerContext()).getContainerMetricsRegistry(); return context; }
private void initTables(boolean isTimerMetricsDisabled, ReadWriteTable ... tables) { Map<String, String> config = new HashMap<>(); if (isTimerMetricsDisabled) { config.put(MetricsConfig.METRICS_TIMER_ENABLED(), "false"); } Context context = new MockContext(); doReturn(new MapConfig(config)).when(context.getJobContext()).getConfig(); metricsRegistry = mock(MetricsRegistry.class); doReturn(mock(Timer.class)).when(metricsRegistry).newTimer(anyString(), anyString()); doReturn(mock(Counter.class)).when(metricsRegistry).newCounter(anyString(), anyString()); doReturn(mock(Gauge.class)).when(metricsRegistry).newGauge(anyString(), any()); doReturn(metricsRegistry).when(context.getContainerContext()).getContainerMetricsRegistry(); Arrays.asList(tables).forEach(t -> t.init(context)); }