public HdfsSystemConsumerMetrics(MetricsRegistry metricsRegistry) { this.metricsRegistry = metricsRegistry; this.numEventsCounterMap = new ConcurrentHashMap<>(); this.numTotalEventsCounter = metricsRegistry.newCounter(METRICS_GROUP_NAME, "num-total-events"); }
public <T> Gauge<T> newGauge(String name, T value) { return registry.newGauge(groupName, new Gauge<T>((prefix + name).toLowerCase(), value)); }
public Timer newTimer(String name) { return registry.newTimer(groupName, (prefix + name).toLowerCase()); } }
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)); }
this.numMessage = metricsRegistry.newCounter(METRICS_GROUP, opId + "-messages"); this.handleMessageNs = metricsRegistry.newTimer(METRICS_GROUP, opId + "-handle-message-ns"); this.handleTimerNs = metricsRegistry.newTimer(METRICS_GROUP, opId + "-handle-timer-ns"); this.taskName = taskContext.getTaskModel().getTaskName();
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; }
public <T> ListGauge<T> newListGauge(String name) { return registry.newListGauge(groupName, new ListGauge(name)); }
this.numMessage = metricsRegistry.newCounter(METRICS_GROUP, opId + "-messages"); this.handleMessageNs = metricsRegistry.newTimer(METRICS_GROUP, opId + "-handle-message-ns"); this.handleTimerNs = metricsRegistry.newTimer(METRICS_GROUP, opId + "-handle-timer-ns");
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)); }
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> ListGauge<T> newListGauge(String name) { return registry.newListGauge(groupName, new ListGauge(name)); }
public void registerSystemStreamPartition(SystemStreamPartition systemStreamPartition) { numEventsCounterMap.putIfAbsent(systemStreamPartition, metricsRegistry.newCounter(METRICS_GROUP_NAME, "num-events-" + systemStreamPartition)); }
this.numMessage = metricsRegistry.newCounter(METRICS_GROUP, opId + "-messages"); this.handleMessageNs = metricsRegistry.newTimer(METRICS_GROUP, opId + "-handle-message-ns"); this.handleTimerNs = metricsRegistry.newTimer(METRICS_GROUP, opId + "-handle-timer-ns"); this.taskName = taskContext.getTaskModel().getTaskName();
verify(metricsRegistry, times(24)).newCounter(any(), anyString()); verify(metricsRegistry, times(23)).newTimer(any(), anyString()); verify(metricsRegistry, times(4)).newGauge(anyString(), any());
public <T> Gauge<T> newGauge(String name, T value) { return registry.newGauge(groupName, new Gauge<T>((prefix + name).toLowerCase(), value)); }
public Timer newTimer(String name) { return registry.newTimer(groupName, (prefix + name).toLowerCase()); } }
public <T> ListGauge<T> newListGauge(String name) { return registry.newListGauge(groupName, new ListGauge(name)); }
public Counter newCounter(String name) { return registry.newCounter(groupName, (prefix + name).toLowerCase()); }
this.numMessage = metricsRegistry.newCounter(METRICS_GROUP, opId + "-messages"); this.handleMessageNs = metricsRegistry.newTimer(METRICS_GROUP, opId + "-handle-message-ns"); this.handleTimerNs = metricsRegistry.newTimer(METRICS_GROUP, opId + "-handle-timer-ns"); this.taskName = taskContext.getTaskModel().getTaskName();
public <T> Gauge<T> newGauge(String name, T value) { return registry.newGauge(groupName, new Gauge<T>((prefix + name).toLowerCase(), value)); }