private void reportMetered(String name, Metered meter, long timestamp, List<String> tags) throws IOException { if (expansions.contains(Expansion.COUNT)) { request.addGauge(new CirconusGauge( appendExpansionSuffix(name, Expansion.COUNT), meter.getCount(), timestamp, host, tags)); } double[] values = { meter.getOneMinuteRate(), meter.getFiveMinuteRate(), meter.getFifteenMinuteRate(), meter.getMeanRate() }; for (int i = 0; i < RATE_EXPANSIONS.length; i++) { if (expansions.contains(RATE_EXPANSIONS[i])) { request.addGauge(new CirconusGauge( appendExpansionSuffix(name, RATE_EXPANSIONS[i]), toNumber(convertRate(values[i])), timestamp, host, tags)); } } }
private void reportMeter(String name, Metered meter, long now) { if (canSkipMetric(name, meter)) { return; } Map<String, Object> fields = new HashMap<String, Object>(); fields.put("count", meter.getCount()); fields.put("m1_rate", convertRate(meter.getOneMinuteRate())); fields.put("m5_rate", convertRate(meter.getFiveMinuteRate())); fields.put("m15_rate", convertRate(meter.getFifteenMinuteRate())); fields.put("mean_rate", convertRate(meter.getMeanRate())); if (includeMeterFields != null) { fields.keySet().retainAll(includeMeterFields); } influxDb.appendPoints( new InfluxDbPoint( getMeasurementName(name), getTags(name), now, fields)); }
private void reportMetered(MetricContext context, String name, Metered metered, long timeStamp) throws IOException { this.graphiteSender.send( MetricRegistry.name(context.getName(), name, Measurements.COUNT.getName()), Long.toString(metered.getCount()), timeStamp); this.graphiteSender.send( MetricRegistry.name(context.getName(), name, Measurements.RATE_1MIN.getName()), Double.toHexString(convertRate(metered.getOneMinuteRate())), timeStamp); this.graphiteSender.send( MetricRegistry.name(context.getName(), name, Measurements.RATE_5MIN.getName()), Double.toString(convertRate(metered.getFiveMinuteRate())), timeStamp); this.graphiteSender.send( MetricRegistry.name(context.getName(), name, Measurements.RATE_15MIN.getName()), Double.toString(convertRate(metered.getFifteenMinuteRate())), timeStamp); this.graphiteSender.send( MetricRegistry.name(context.getName(), name, Measurements.MEAN_RATE.getName()), Double.toString(convertRate(metered.getMeanRate())), timeStamp); }
private void reportMetered(String index, long timestamp, String name, Metered meter) throws IOException { StringWriter writer = new StringWriter(); JsonGenerator jsonGenerator = jsonFactory.createGenerator(writer); jsonGenerator.writeStartObject(); jsonGenerator.writeNumberField(timestampFieldName, timestamp); jsonGenerator.writeStringField("@name", prefixMetricName(name)); jsonGenerator.writeNumberField("count", meter.getCount()); jsonGenerator.writeNumberField("m1_rate", convertRate(meter.getOneMinuteRate())); jsonGenerator.writeNumberField("m5_rate", convertRate(meter.getFiveMinuteRate())); jsonGenerator.writeNumberField("m15_rate", convertRate(meter.getFifteenMinuteRate())); jsonGenerator.writeNumberField("mean_rate", convertRate(meter.getMeanRate())); jsonGenerator.writeEndObject(); jsonGenerator.flush(); addReportToBulkRequest(index, MetricElasticsearchTypes.METER, writer.toString()); }
void addMetered(String baseName, Metered metered) { addMetric(metered, baseName, SignalFxReporter.MetricDetails.COUNT, SignalFxProtocolBuffers.MetricType.CUMULATIVE_COUNTER, metered.getCount()); addMetric(metered, baseName, SignalFxReporter.MetricDetails.RATE_15_MIN, SignalFxProtocolBuffers.MetricType.GAUGE, metered.getFifteenMinuteRate()); addMetric(metered, baseName, SignalFxReporter.MetricDetails.RATE_1_MIN, SignalFxProtocolBuffers.MetricType.GAUGE, metered.getOneMinuteRate()); addMetric(metered, baseName, SignalFxReporter.MetricDetails.RATE_5_MIN, SignalFxProtocolBuffers.MetricType.GAUGE, metered.getFiveMinuteRate()); addMetric(metered, baseName, SignalFxReporter.MetricDetails.RATE_MEAN, SignalFxProtocolBuffers.MetricType.GAUGE, metered.getMeanRate()); }
private void printMetered(TagEncodedMetricName metric, Metered meter) { addDataPoint(metric.submetric("rate").withTags("window", "1m"), convertRate(meter.getOneMinuteRate())); addDataPoint(metric.submetric("rate").withTags("window", "5m"), convertRate(meter.getFiveMinuteRate())); addDataPoint(metric.submetric("rate").withTags("window", "15m"), convertRate(meter.getFifteenMinuteRate())); //addDataPoint(rootMetric.submetric("rate", "window", "all"), epoch, meter.getMeanRate()); }
private void writeMetered(String dropwizardName, Metered metered) throws IOException { String name = sanitizeMetricName(dropwizardName); writer.writeSample(name, mapOf("rate", "m1"), metered.getOneMinuteRate()); writer.writeSample(name, mapOf("rate", "m5"), metered.getFiveMinuteRate()); writer.writeSample(name, mapOf("rate", "m15"), metered.getFifteenMinuteRate()); writer.writeSample(name, mapOf("rate", "mean"), metered.getMeanRate()); }
private void reportMetered( final BatchBuilder builder, final Metered value ) { final BatchBuilder b = builder.withUnit(builder.getUnit() + "/s"); b.buildPoint("1m", value.getOneMinuteRate()); b.buildPoint("5m", value.getFiveMinuteRate()); }
public MeteredEntity(final Metered meter) { count = meter.getCount(); m1Rate = meter.getOneMinuteRate(); m5Rate = meter.getFiveMinuteRate(); m15Rate = meter.getFifteenMinuteRate(); meanRate = meter.getMeanRate(); }
private void reportMetered(String name, Metered meter) throws IOException { statsdClient.send(prefix(name, "count"), format(meter.getCount()), StatsdClient.StatType.GAUGE); statsdClient.send(prefix(name, "mean_rate"), format(convertRate(meter.getMeanRate())), StatsdClient.StatType.TIMER); }
private String formatMetered(String name, Metered meter, long timestamp) { StringBuilder outputBuilder = new StringBuilder(); outputBuilder.append(formatLine(MetricNamingUtil.join(name, "count"), meter.getCount(), timestamp)); outputBuilder.append(formatLine(MetricNamingUtil.join(name, "m1_rate"), convertRate(meter.getOneMinuteRate()), timestamp)); outputBuilder.append(formatLine(MetricNamingUtil.join(name, "m5_rate"), convertRate(meter.getFiveMinuteRate()), timestamp)); outputBuilder.append(formatLine(MetricNamingUtil.join(name, "m15_rate"), convertRate(meter.getFifteenMinuteRate()), timestamp)); outputBuilder.append(formatLine(MetricNamingUtil.join(name, "mean_rate"), convertRate(meter.getMeanRate()), timestamp)); return outputBuilder.toString(); }
private void registerHealthCheck(String name, Optional<Double> ceiling, Metered errorMeter, Metered timer) { final Gauge<Double> errorRate = Gauges.ratioOf(errorMeter, timer, Metered::getFifteenMinuteRate); final HealthCheck healthCheck = HealthChecks.forDoubleGauge( errorRate, ceiling ); healthCheckRegistry.register(name, healthCheck); }
private void registerErrorGauges(String name, Meter errorMeter, Timer timer) { final Gauge<Double> totalErrorPct = Gauges.ratioOf(errorMeter, timer, m -> Long.valueOf(m.getCount()).doubleValue()); final Gauge<Double> meanErrorPct = Gauges.ratioOf(errorMeter, timer, Metered::getMeanRate); final Gauge<Double> m1ErrorPct = Gauges.ratioOf(errorMeter, timer, Metered::getOneMinuteRate); final Gauge<Double> m5ErrorPct = Gauges.ratioOf(errorMeter, timer, Metered::getFiveMinuteRate); final Gauge<Double> m15ErrorPct = Gauges.ratioOf(errorMeter, timer, Metered::getFifteenMinuteRate); tryRegister(totalErrorPct, MetricRegistry.name(name, "errors", "total_pct")); tryRegister(meanErrorPct, MetricRegistry.name(name, "errors", "mean_pct")); tryRegister(m1ErrorPct, MetricRegistry.name(name, "errors", "m1_pct")); tryRegister(m5ErrorPct, MetricRegistry.name(name, "errors", "m5_pct")); tryRegister(m15ErrorPct, MetricRegistry.name(name, "errors", "m15_pct")); }
public static MeteredRatioGauge ratioOf( Metered numerator, Metered denominator, Function<Metered, Double> accessor ) { return new MeteredRatioGauge(numerator, denominator, accessor); }
@Test public void testOverrideAccessor() throws Exception { when(numerator.getFifteenMinuteRate()).thenReturn(10d); when(denominator.getFifteenMinuteRate()).thenReturn(100d); Gauge<Double> gauge = Gauges.ratioOf( numerator, denominator, Metered::getFifteenMinuteRate ); assertEquals((Double) 0.1d, gauge.getValue()); }
@Test public void testNaN() throws Exception { when(numerator.getFifteenMinuteRate()).thenReturn(10d); when(denominator.getFifteenMinuteRate()).thenReturn(0d); Gauge<Double> gauge = Gauges.ratioOf( numerator, denominator, Metered::getFifteenMinuteRate ); assertEquals(Double.NaN, (Object) gauge.getValue()); }
private void reportMetered(List<Serie> series, MetricContext context, String name, Metered metered, long timeStamp) { series.add(buildSerie(context, name, Optional.of(Measurements.COUNT), timeStamp, metered.getCount())); series.add(buildSerie(context, name, Optional.of(Measurements.MEAN_RATE), timeStamp, convertRate(metered.getMeanRate()))); series.add(buildSerie(context, name, Optional.of(Measurements.RATE_1MIN), timeStamp, convertRate(metered.getOneMinuteRate()))); series.add(buildSerie(context, name, Optional.of(Measurements.RATE_5MIN), timeStamp, convertRate(metered.getFiveMinuteRate()))); series.add(buildSerie(context, name, Optional.of(Measurements.RATE_15MIN), timeStamp, convertRate(metered.getFifteenMinuteRate()))); }
/** * Extracts metrics from {@link com.codahale.metrics.Metered}. * @param name name of the {@link com.codahale.metrics.Metered}. * @param meter instance of {@link com.codahale.metrics.Metered} to serialize. * @return a list of {@link gobblin.metrics.Metric}. */ protected List<Metric> serializeMetered(String name, Metered meter) { return Lists.newArrayList( serializeValue(name, meter.getCount(), Measurements.COUNT.name()), serializeValue(name, meter.getMeanRate(), Measurements.MEAN_RATE.name()), serializeValue(name, meter.getOneMinuteRate(), Measurements.RATE_1MIN.name()), serializeValue(name, meter.getFiveMinuteRate(), Measurements.RATE_5MIN.name()), serializeValue(name, meter.getFifteenMinuteRate(), Measurements.RATE_15MIN.name()) ); }
@Override @SuppressWarnings("unchecked") public MetricAdapter createMetricAdapterFor(String originalMetricName, Metric metric) { Preconditions.checkArgument(!(metric instanceof MetricSet), "Metric Sets cannot be adapted!!"); String translatedName = translate(originalMetricName); MetricDescriptor descriptor = metricDescriptorLookup.getDescriptorFor(translatedName); if (metric instanceof Timer) { return new TimerAdapter((Timer) metric, translatedName, descriptor.getDescription()); } if (metric instanceof Histogram) { return new HistogramAdapter((Histogram) metric, translatedName, descriptor.getDescription(), descriptor.getUnit()); } if (metric instanceof Counter) { return new CountingAdapter((Counter) metric, translatedName, descriptor.getDescription(), descriptor.getSemantics()); } if (metric instanceof Gauge) { return new GaugeAdapter<>((Gauge) metric, translatedName, descriptor.getDescription(), descriptor.getUnit(), descriptor.getSemantics()); } if (metric instanceof Metered) { return new MeteredAdapter((Metered) metric, translatedName, descriptor.getDescription()); } throw new UnsupportedOperationException(String.format("Unable to produce a monitorable adapter for metrics of class %s (%s)", metric.getClass().getName(), originalMetricName)); }
public MeteredAdapter(Metered metered, String name, String description) { this.metered = metered; this.fifteenMinuteRate = new NonSelfRegisteringSettableValue<>(name(name, "fifteen_minute_rate"), description + " - Fifteen minute rate", ONE, metered.getFifteenMinuteRate(), ValueSemantics.FREE_RUNNING); this.fiveMinuteRate = new NonSelfRegisteringSettableValue<>(name(name, "five_minute_rate"), description + " - Five minute rate", ONE, metered.getFiveMinuteRate(), ValueSemantics.FREE_RUNNING); this.oneMinuteRate = new NonSelfRegisteringSettableValue<>(name(name, "one_minute_rate"), description + " - One minute rate", ONE, metered.getOneMinuteRate(), ValueSemantics.FREE_RUNNING); this.meanRate = new NonSelfRegisteringSettableValue<>(name(name, "mean_rate"), description + " - Mean rate", ONE, metered.getMeanRate(), ValueSemantics.FREE_RUNNING); this.count = new NonSelfRegisteringSettableValue<>(name(name, "count"), description + " - Count", ONE, metered.getCount(), ValueSemantics.MONOTONICALLY_INCREASING); }
private void addMeterDataObject(String key, Metered meter, long clock, List<DataObject> dataObjectList) { dataObjectList.add(toDataObject(key, ".count", meter.getCount(), clock)); dataObjectList.add(toDataObject(key, ".meanRate", convertRate(meter.getMeanRate()), clock)); dataObjectList.add(toDataObject(key, ".1-minuteRate", convertRate(meter.getOneMinuteRate()), clock)); dataObjectList.add(toDataObject(key, ".5-minuteRate", convertRate(meter.getFiveMinuteRate()), clock)); dataObjectList.add(toDataObject(key, ".15-minuteRate", convertRate(meter.getFifteenMinuteRate()), clock)); }
private static Snapshot toSnapshot( String name, Metric value ) { Snapshot snapshot = new Snapshot( name ); if( value instanceof Sampling ) snapshot.mean = ( ( Sampling ) value ).getSnapshot().getMean(); if( value instanceof Metered ) snapshot.meanRate = ( ( Metered ) value ).getMeanRate(); if( value instanceof Counting ) snapshot.count = ( ( Counting ) value ).getCount(); if( value instanceof Gauge ) snapshot.count = ( ( Number ) ( ( Gauge ) value ).getValue() ).longValue(); return snapshot; }
private void reportMetered(String name, Metered meter, long timestamp) throws IOException { instrumental.send(MetricType.GAUGE, prefix(name, "count"), format(meter.getCount()), timestamp); instrumental.send(MetricType.GAUGE, prefix(name, "m1_rate"), format(convertRate(meter.getOneMinuteRate())), timestamp); instrumental.send(MetricType.GAUGE, prefix(name, "m5_rate"), format(convertRate(meter.getFiveMinuteRate())), timestamp); instrumental.send(MetricType.GAUGE, prefix(name, "m15_rate"), format(convertRate(meter.getFifteenMinuteRate())), timestamp); instrumental.send(MetricType.GAUGE, prefix(name, "mean_rate"), format(convertRate(meter.getMeanRate())), timestamp); }
private static void populateMetered(JsonObject json, Metered meter, TimeUnit rateUnit) { double factor = rateUnit.toSeconds(1); json.put("count", meter.getCount()); json.put("meanRate", meter.getMeanRate() * factor); json.put("oneMinuteRate", meter.getOneMinuteRate() * factor); json.put("fiveMinuteRate", meter.getFiveMinuteRate() * factor); json.put("fifteenMinuteRate", meter.getFifteenMinuteRate() * factor); String rate = "events/" + rateUnit.toString().toLowerCase(); json.put("rate", rate); }
private void reportMetered(List<Point> points, String prefix, String name, Metered metered, long timestamp) throws IOException { reportCounter(points,prefix, name, metered, timestamp); String baseMetricName = getKey(prefix, name); points.add(buildRateAsPoint(getKey(baseMetricName, RATE_1MIN), metered.getOneMinuteRate(), timestamp)); points.add(buildRateAsPoint(getKey(baseMetricName, RATE_5MIN), metered.getFiveMinuteRate(), timestamp)); points.add(buildRateAsPoint(getKey(baseMetricName, RATE_15MIN), metered.getFifteenMinuteRate(), timestamp)); points.add(buildRateAsPoint(getKey(baseMetricName, MEAN_RATE), metered.getMeanRate(), timestamp)); }
private void reportMetered(String prefix, String name, Metered metered, long timestamp) throws IOException { reportCounter(prefix, name, metered, timestamp); String baseMetricName = getKey(prefix, name); pushMetricRate(getKey(baseMetricName, RATE_1MIN), metered.getOneMinuteRate(), timestamp); pushMetricRate(getKey(baseMetricName, RATE_5MIN), metered.getFiveMinuteRate(), timestamp); pushMetricRate(getKey(baseMetricName, RATE_15MIN), metered.getFifteenMinuteRate(), timestamp); pushMetricRate(getKey(baseMetricName, MEAN_RATE), metered.getMeanRate(), timestamp); }
/** * Extracts metrics from {@link com.codahale.metrics.Metered}. * * @param name name of the {@link com.codahale.metrics.Metered}. * @param meter instance of {@link com.codahale.metrics.Metered} to serialize. * @return a list of {@link org.apache.gobblin.metrics.Metric}. */ protected List<Metric> serializeMetered(String name, Metered meter) { return Lists.newArrayList( serializeValue(name, meter.getCount(), Measurements.COUNT.name()), serializeValue(name, meter.getMeanRate(), Measurements.MEAN_RATE.name()), serializeValue(name, meter.getOneMinuteRate(), Measurements.RATE_1MIN.name()), serializeValue(name, meter.getFiveMinuteRate(), Measurements.RATE_5MIN.name()), serializeValue(name, meter.getFifteenMinuteRate(), Measurements.RATE_15MIN.name()) ); }
private static void dumpMetered(ObjectNode node, Metered meter) { node.put("count", meter.getCount()); node.put("15min-rate", meter.getFifteenMinuteRate()); node.put("5min-rate", meter.getFiveMinuteRate()); node.put("1min-rate", meter.getOneMinuteRate()); node.put("mean-rate", meter.getMeanRate()); }
private void reportMeter(String name, Metered meter, long timestamp) { if (canSkipMetric(name, meter)) { return; } Object[] p = pointsMeter[0]; p[0] = influxdb.convertTimestamp(timestamp); p[1] = meter.getCount(); p[2] = convertRate(meter.getOneMinuteRate()); p[3] = convertRate(meter.getFiveMinuteRate()); p[4] = convertRate(meter.getFifteenMinuteRate()); p[5] = convertRate(meter.getMeanRate()); assert (p.length == COLUMNS_METER.length); influxdb.appendSeries(prefix, name, ".meter", COLUMNS_METER, pointsMeter); }
private void reportMetered(final String name, final Metered meter, final Date timestamp) { final DBCollection coll = db.getCollection("metered"); final MeteredEntity entity = new MeteredEntity(meter); entity.setName(prefix(name)); entity.setTimestamp(timestamp); try { coll.save(entity.toDBObject()); } catch(MongoException e){ LOGGER.warn("Unable to report meter {}",name, e); } }
@Override public String getIndex() { TemplateCall call = templater.template(PREFIX + "index.html"); call.set("gauges", registry.getGauges().entrySet()); call.set("counters", this.<Counting>combine(registry.getCounters(), registry.getMeters(), registry.getTimers(), registry.getHistograms()).entrySet()); call.set("meters", this.<Metered>combine(registry.getMeters(), registry.getTimers()).entrySet()); call.set("histograms", this.<Sampling>combine(registry.getHistograms(), registry.getTimers()).entrySet()); return call.process(); }
@Override public boolean matches(MetricName name, Metric metric) { if (metric instanceof Metered) { return ((Metered) metric).getCount() > 0; } return true; }
private void printMetered(Metered metered, StringBuilder sb) { printDouble(convertRate(metered.getMeanRate()), sb); printDouble(convertRate(metered.getOneMinuteRate()), sb); printDouble(convertRate(metered.getFiveMinuteRate()), sb); printDouble(convertRate(metered.getFifteenMinuteRate()), sb); sb.append(String.format("%-13s | ", getRateUnit())); sb.append(getDurationUnit()); }
private void writeMetered(Metered metered, JsonGenerator jg) throws IOException { jg.writeNumberField("count", metered.getCount()); writeDoubleUnlessNaN(jg, "m1_rate", convertRate(metered.getOneMinuteRate())); writeDoubleUnlessNaN(jg, "m5_rate", convertRate(metered.getFiveMinuteRate())); writeDoubleUnlessNaN(jg, "m15_rate", convertRate(metered.getFifteenMinuteRate())); writeDoubleUnlessNaN(jg, "mean_rate", convertRate(metered.getMeanRate())); }
private String reportMetered(Metered metered) { return "count=" + getIntegerValue(metered.getCount()) + "," + "m1_rate=" + getRate(metered.getOneMinuteRate()) + "," + "m5_rate=" + getRate(metered.getFiveMinuteRate()) + "," + "m15_rate=" + getRate(metered.getFifteenMinuteRate()) + "," + "mean_rate=" + getRate(metered.getMeanRate()); }
private <M extends Metered> MetricFamilySamples fromMeter(List<Map.Entry<MetricName, M>> metersWithSameName, String suffix) { final Map.Entry<MetricName, M> first = metersWithSameName.get(0); final MetricName firstName = first.getKey(); ArrayList<MetricFamilySamples.Sample> sampleList = new ArrayList<MetricFamilySamples.Sample>(metersWithSameName.size()); final String name = firstName.getName() + suffix; for (Map.Entry<MetricName, M> entry : metersWithSameName) { final M metered = entry.getValue(); sampleList.add(new MetricFamilySamples.Sample(name + "_total", entry.getKey().getTagKeys(), entry.getKey().getTagValues(), metered.getCount())); sampleList.add(new MetricFamilySamples.Sample(name + "_m1", entry.getKey().getTagKeys(), entry.getKey().getTagValues(), metered.getOneMinuteRate())); sampleList.add(new MetricFamilySamples.Sample(name + "_m5", entry.getKey().getTagKeys(), entry.getKey().getTagValues(), metered.getFiveMinuteRate())); sampleList.add(new MetricFamilySamples.Sample(name + "_m15", entry.getKey().getTagKeys(), entry.getKey().getTagValues(), metered.getFifteenMinuteRate())); } return new MetricFamilySamples(name, Type.UNTYPED, getHelpMessage(firstName, first.getValue()), sampleList); }
private Metered getMetered() { return new Metered() { @Override public long getCount() { return 1; } @Override public double getFifteenMinuteRate() { return 1; } @Override public double getFiveMinuteRate() { return 1; } @Override public double getMeanRate() { return 1; } @Override public double getOneMinuteRate() { return 1; } }; }
private void reportMetered(final Metric m, Metered value) { final String u = getUnit(m); final Metric r = m.attribute("unit", u + "/s"); send(r.attribute("stat", "1m").value(value.getOneMinuteRate())); send(r.attribute("stat", "5m").value(value.getFiveMinuteRate())); }
Stream<MetricPart<Metered, Object>> metered() { return METERED.stream() .filter(metricPart -> metricPredicate.test(metricPart.getSuffix())); }