Mockito.when(metricsUtils.getUaaMetrics(any())).thenReturn(uaaMetrics1, uaaMetrics2); uaaMetricsEmitter.emitGlobalRequestMetrics(); Mockito.verify(statsDClient).count("requests.global.completed.count", 3087l); Mockito.verify(statsDClient).gauge("requests.global.completed.time", 29l); Mockito.verify(statsDClient).count("requests.global.unhealthy.count", 1l); Mockito.verify(statsDClient).gauge("requests.global.unhealthy.time", 4318l); Mockito.verify(statsDClient).count("requests.global.status_1xx.count", 0l); Mockito.verify(statsDClient).count("requests.global.status_2xx.count", 2148l); Mockito.verify(statsDClient).count("requests.global.status_3xx.count", 763l); Mockito.verify(statsDClient).count("requests.global.status_4xx.count", 175l); Mockito.verify(statsDClient).count("requests.global.status_5xx.count", 1l); Mockito.verify(statsDClient).gauge("server.inflight.count", 3l); Mockito.verify(statsDClient).gauge("server.up.time", 12349843l); Mockito.verify(statsDClient).gauge("server.idle.time", 12349l); Mockito.verify(statsDClient).count("database.global.completed.count", 83797l); Mockito.verify(statsDClient).gauge("database.global.completed.time", 0l); Mockito.verify(statsDClient).count("database.global.unhealthy.count", 17549l); Mockito.verify(statsDClient).gauge("database.global.unhealthy.time", 0l); reset(statsDClient); uaaMetricsEmitter.emitGlobalRequestMetrics(); Mockito.verify(statsDClient).count("requests.global.completed.count", 4l); Mockito.verify(statsDClient).count("requests.global.unhealthy.count", 1l); Mockito.verify(statsDClient).count("requests.global.status_1xx.count", 0l); Mockito.verify(statsDClient).count("requests.global.status_2xx.count", 1l); Mockito.verify(statsDClient).count("requests.global.status_3xx.count", 1l); Mockito.verify(statsDClient).count("requests.global.status_4xx.count", 1l); Mockito.verify(statsDClient).count("requests.global.status_5xx.count", 1l); Mockito.verify(statsDClient).count("database.global.completed.count", 2l); Mockito.verify(statsDClient).count("database.global.unhealthy.count", 5l);
@Override protected void processDataPoint(IMetricsConsumer.DataPoint dataPoint) { statsDClient.count(dataPoint.name, (long) dataPoint.value); }
@Override public void recordCount(String parameterName, Long value){ statsd.count(parameterName, value); }
@Override protected void processDataPoint(IMetricsConsumer.DataPoint dataPoint) { statsDClient.count(dataPoint.name, (long) dataPoint.value); }
public void report(String s, int number) { LOG.debug("reporting: {}={}", s, number); statsd.count(s, number); }
@SuppressWarnings("unchecked") @Override protected void processDataPoint(DataPoint dataPoint) { long sum = 0; for (Map.Entry<String, Long> entry : ((Map<String, Long>) dataPoint.value).entrySet()) { statsDClient.count(dataPoint.name + ",filterKey=" + entry.getKey(), entry.getValue()); sum += entry.getValue(); } statsDClient.count(dataPoint.name, sum); }
@SuppressWarnings("unchecked") @Override protected void processDataPoint(DataPoint dataPoint) { long sum = 0; for (Map.Entry<String, Long> entry : ((Map<String, Long>) dataPoint.value).entrySet()) { statsDClient.count(dataPoint.name + ",filterKey=" + entry.getKey(), entry.getValue()); sum += entry.getValue(); } statsDClient.count(dataPoint.name, sum); }
public void logStats(Stats stats) { client.count(keyPrefix + ".failed", stats.failed.get()); client.count(keyPrefix + ".succeeded", stats.succeeded.get()); client.count(keyPrefix + ".flushCount", stats.flushCount.get()); client.count(keyPrefix + ".messagesReceived", stats.messagesReceived.get()); for(Integer partitionId : stats.lastCommitOffsetByPartitionId.keySet()) { client.gauge( String.format("%s.partition_%s.offset", keyPrefix, partitionId), stats.lastCommitOffsetByPartitionId.get(partitionId)); } } }
@Override public void count(String key, List<String> tags, long delta) { if(configuration.isDatadogSendingEnabled()) { statsd.count(key, delta, tags.toArray(new String[tags.size()])); } else { log.debug("Skip sending to datadog cause it is disabled"); } }
/** * Tell the logger a session has closed, meaning the total interval * length can now be computed */ synchronized void sessionEnded() { // round up to 15 second intervals int intervals15s = 1 + (int) (summedTime / INTERVAL_LENGTH_MS); if(client != null) { client.count(ASPECT_INTERVAL, intervals15s); } logger.info("sent " + summedTime + "ms to speech API, " + "for a total of " + intervals15s + " intervals"); summedTime = 0; }
statsdClient.count(metric, finalValue, tags);
statsdClient.count(metric, finalValue, tags);
public void sendLiveStat(String groupName, Counter counter, long value) { if (client != null) { if (log.isTraceEnabled()) { log.trace("Looking for aspect matching " + groupName + " / " + counter.getName()); } CounterToStatsDConfiguration.StatsDAspect aspect = config.getAspect(CounterToStatsDConfiguration.StatsDOutputType.LIVE, groupName, counter); if (aspect != null) { log.trace("Found aspect " + aspect); String fullName = aspect.getFullName(counter.getName()); log.trace("Sending " + aspect.getType() + '(' + fullName + " -> " + counter.getValue() + ')'); switch (aspect.getType()) { case GAUGE: client.gauge(fullName, value); break; case COUNTER: client.count(fullName, value); break; default: client.time(fullName, value); } } } }
public void sendFinalStats(Counters counters) { if (client != null) { for (CounterGroup group : counters) { for (Counter counter : group) { if (log.isTraceEnabled()) { log.trace("Looking for aspect matching " + group.getName() + " / " + counter.getName()); } CounterToStatsDConfiguration.StatsDAspect aspect = config.getAspect(CounterToStatsDConfiguration.StatsDOutputType.FINAL, group, counter); if (aspect != null) { String fullName = aspect.getFullName(counter.getName()); if (log.isTraceEnabled()) { log.trace("Sending " + aspect.getType() + '(' + fullName + " -> " + counter.getValue() + ')'); } switch (aspect.getType()) { case GAUGE: client.gauge(fullName, counter.getValue()); break; case COUNTER: client.count(fullName, counter.getValue()); break; default: client.time(fullName, counter.getValue()); } } } } } }
@Override public void updateImpl(List<Metric> metrics) { // The statsd client doesn't do any checks on the underlying socket's state // and the socket connects only once, so we cannot trust the socket to stay // open over a period of time. If this is changed/fixed we could reuse the // client but until then it cannot be safely reused. StatsDClient statsd = createClient(); LOGGER.debug("sending data"); try { for (Metric metric : metrics) { String aspect = namingConvention.getName(metric); if (metric.getConfig().getTags().getTag(DataSourceType.COUNTER.getValue()) != null) { statsd.count(aspect, metric.getNumberValue().longValue()); } else if (metric.hasNumberValue()) { statsd.gauge(aspect, metric.getNumberValue().longValue()); } else { statsd.set(aspect, metric.getValue().toString()); } statsd.time(aspect, metric.getTimestamp() / 1000); } } finally { statsd.stop(); } }