@Test public void testSubmit() throws Exception { String gaugeName = "gaugeName"; double value = 10; this.gaugeService.submit(gaugeName, value); gaugeName = LookoutSpringBootMetricsImpl.LOOKOUT_GAUGE_PREFIX + gaugeName; Metric metric = this.lookoutRegistryMetricReader.findOne(gaugeName); assertEquals(value, metric.getValue()); }
@Override public void submit(String metricName, double value) { if (StringUtils.isBlank(metricName)) { return; } metricName = wrapName(LOOKOUT_GAUGE_PREFIX, metricName); SimpleLookoutGauge gauge = this.gauges.get(metricName); if (gauge == null) { SimpleLookoutGauge newGauge = new SimpleLookoutGauge(value); gauge = this.gauges.putIfAbsent(metricName, newGauge); if (gauge == null) { Id id = this.registry.createId(metricName); this.registry.gauge(id, newGauge); return; } } gauge.setValue(value); }
LookoutSpringBootMetricsImpl implements CounterService, GaugeService { @Override public void submit(String metricName, double value) { if (StringUtils.isBlank(metricName)) { return; } metricName = wrapName(LOOKOUT_GAUGE_PREFIX, metricName); SimpleLookoutGauge gauge = this.gauges.get(metricName); if (gauge == null) { SimpleLookoutGauge newGauge = new SimpleLookoutGauge(value); gauge = this.gauges.putIfAbsent(metricName, newGauge); if (gauge == null) { Id id = this.registry.createId(metricName); this.registry.gauge(id, newGauge); return; } } gauge.setValue(value); } }
LookoutSpringBootMetricsImpl implements CounterService, GaugeService { @Override public void submit(String metricName, double value) { if (StringUtils.isBlank(metricName)) { return; } metricName = wrapName(LOOKOUT_GAUGE_PREFIX, metricName); SimpleLookoutGauge gauge = this.gauges.get(metricName); if (gauge == null) { SimpleLookoutGauge newGauge = new SimpleLookoutGauge(value); gauge = this.gauges.putIfAbsent(metricName, newGauge); if (gauge == null) { Id id = this.registry.createId(metricName); this.registry.gauge(id, newGauge); return; } } gauge.setValue(value); } LookoutSpringBootMetricsImpl(Registry registry); }
LookoutSpringBootMetricsImpl implements CounterService, GaugeService { @Override public void submit(String metricName, double value) { if (StringUtils.isBlank(metricName)) { return; } metricName = wrapName(LOOKOUT_GAUGE_PREFIX, metricName); SimpleLookoutGauge gauge = this.gauges.get(metricName); if (gauge == null) { SimpleLookoutGauge newGauge = new SimpleLookoutGauge(value); gauge = this.gauges.putIfAbsent(metricName, newGauge); if (gauge == null) { Id id = this.registry.createId(metricName); this.registry.gauge(id, newGauge); return; } } gauge.setValue(value); } LookoutSpringBootMetricsImpl(Registry registry); @Override void increment(String metricName); @Override void decrement(String metricName); @Override void reset(String metricName); @Override void submit(String metricName, double value); }
LookoutSpringBootMetricsImpl implements CounterService, GaugeService { @Override public void submit(String metricName, double value) { if (StringUtils.isBlank(metricName)) { return; } metricName = wrapName(LOOKOUT_GAUGE_PREFIX, metricName); SimpleLookoutGauge gauge = this.gauges.get(metricName); if (gauge == null) { SimpleLookoutGauge newGauge = new SimpleLookoutGauge(value); gauge = this.gauges.putIfAbsent(metricName, newGauge); if (gauge == null) { Id id = this.registry.createId(metricName); this.registry.gauge(id, newGauge); return; } } gauge.setValue(value); } LookoutSpringBootMetricsImpl(Registry registry); @Override void increment(String metricName); @Override void decrement(String metricName); @Override void reset(String metricName); @Override void submit(String metricName, double value); static final String LOOKOUT_COUNTER_PREFIX; static final String LOOKOUT_GAUGE_PREFIX; }