Report a gauge using the field gauge. Only numeric values are used.

@param name
@param gauge
335708
private void reportGauge(String name, Gauge gauge) {
        String prefixedName = prefix(name);

        Object value = gauge.getValue();
        if (value instanceof Number) {

            if (!snapshots.hasDescriptor(prefixedName)) {
                snapshots.setDescriptor(prefixedName, MetricItem.Builder.create().count("gauge").build());
            }
            long timestamp = getTimestamp();

            snapshots.addSnapshot(prefixedName, timestamp, (Map) map("gauge", value));
        }
    }
1111554
public void count(final Stat name, final int count) {
        Integer value = counters.get(name);
        value = value == null ? count : value + count;
        counters.put(name, value);
    }
1020089
protected static void checkMetricLabelName(String name) {
    if (!METRIC_LABEL_NAME_RE.matcher(name).matches()) {
      throw new IllegalArgumentException("Invalid metric label name: " + name);
    }
    if (RESERVED_METRIC_LABEL_NAME_RE.matcher(name).matches()) {
      throw new IllegalArgumentException("Invalid metric label name, reserved for internal use: " + name);
    }
  }
1017100
public static final void cellName(String name)
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "cellName", name);

        _cellName = name;

        if (tc.isEntryEnabled())
            Tr.exit(tc, "cellName");
    }
1315405
protected void incrementNamedCountingMonitor(String name, ConcurrentMap<String, NamedCountingMonitor> map) {
        NamedCountingMonitor monitor = map.get(name);
        if (monitor == null) {
            monitor = new NamedCountingMonitor(name);
            NamedCountingMonitor conflict = map.putIfAbsent(name, monitor);
            if (conflict != null) monitor = conflict;
            else MonitorRegistry.getInstance().registerObject(monitor);
        }
        monitor.increment();
    }
60432
@Override
    public String name(String name, Meter.Type type, @Nullable String baseUnit) {
        String conventionName = NamingConvention.snakeCase.name(name, type, baseUnit);

        switch (type) {
            case COUNTER:
            case DISTRIBUTION_SUMMARY:
            case GAUGE:
                if (baseUnit != null && !conventionName.endsWith("_" + baseUnit))
                    conventionName += "_" + baseUnit;
                break;
        }

        switch (type) {
            case COUNTER:
                if (!conventionName.endsWith("_total"))
                    conventionName += "_total";
                break;
            case TIMER:
            case LONG_TASK_TIMER:
                if (conventionName.endsWith(timerSuffix)) {
                    conventionName += "_seconds";
                } else if (!conventionName.endsWith("_seconds"))
                    conventionName += timerSuffix + "_seconds";
                break;
        }

        String sanitized = nameChars.matcher(conventionName).replaceAll("_");
        if (!Character.isLetter(sanitized.charAt(0))) {
            sanitized = "m_" + sanitized;
        }
        return sanitized;
    }
309165
def gauge(self, name, producer):
        
        return self._get_or_add_stat(name, functools.partial(Gauge, producer))
377726
protected <G,T> Gauge<T> createColumnFamilyGauge(String name, Gauge<T> gauge, Gauge<G> globalGauge)
    {
        Gauge<T> cfGauge = Metrics.newGauge(factory.createMetricName(name), gauge);
        if (register(name, cfGauge))
        {
            Metrics.newGauge(globalNameFactory.createMetricName(name), globalGauge);
        }
        return cfGauge;
    }
1373097
def process_gauge(self, key, fields):
        
        try:
            self.gauges[key] = float(fields[0])
            if self.stats_seen >= maxint:
                self.logger.info("hit maxint, reset seen counter")
                self.stats_seen = 0
            self.stats_seen += 1
        except Exception as err:
            self.logger.info("error decoding gauge event: %s" % err)
            if self.debug:
                print "error decoding gauge event: %s" % err
1087170
def gauge(name, value, rate=1, tags=None):
    
    client().gauge(name, value, rate, tags)
725393
public static final void clusterName(String name)
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "clusterName", name);

        _clusterName = name;

        if (tc.isEntryEnabled())
            Tr.exit(tc, "clusterName");
    }
445248
@SuppressWarnings("rawtypes")
  @Nullable
  private Metric collectGauge(MetricName dropwizardMetric, Gauge gauge) {
    // TODO cache dropwizard MetricName -> OC MetricDescriptor, Labels conversion
    String metricName = DropWizardUtils.generateFullMetricName(dropwizardMetric.getKey(), "gauge");
    String metricDescription =
        DropWizardUtils.generateFullMetricDescription(dropwizardMetric.getKey(), gauge);
    AbstractMap.SimpleImmutableEntry<List<LabelKey>, List<LabelValue>> labels =
        DropWizardUtils.generateLabels(dropwizardMetric);
    // Figure out which gauge instance and call the right method to get value
    Type type;
    Value value;

    Object obj = gauge.getValue();
    if (obj instanceof Number) {
      type = Type.GAUGE_DOUBLE;
      value = Value.doubleValue(((Number) obj).doubleValue());
    } else if (obj instanceof Boolean) {
      type = Type.GAUGE_INT64;
      value = Value.longValue(((Boolean) obj) ? 1 : 0);
    } else {
      // Ignoring Gauge (gauge.getKey()) with unhandled type.
      return null;
    }

    MetricDescriptor metricDescriptor =
        MetricDescriptor.create(metricName, metricDescription, DEFAULT_UNIT, type, labels.getKey());
    TimeSeries timeSeries =
        TimeSeries.createWithOnePoint(labels.getValue(), Point.create(value, clock.now()), null);
    return Metric.createWithOneTimeSeries(metricDescriptor, timeSeries);
  }
13434
protected <T extends Number> Gauge<T> createColumnFamilyGauge(final String name, Gauge<T> gauge)
    {
        return createColumnFamilyGauge(name, gauge, new Gauge<Long>()
        {
            public Long value()
            {
                long total = 0;
                for (Metric cfGauge : allColumnFamilyMetrics.get(name))
                {
                    total = total + ((Gauge<? extends Number>) cfGauge).value().longValue();
                }
                return total;
            }
        });
    }
967145
public final void record(final String name, final Number value) {
    record(name, value.longValue(), null);
  }
537574
def Get(self, fields=None):
    """"""
    result = super(_GaugeMetric, self).Get(fields=fields)
    if callable(result):
      return result()
    else:
      return result
306447
@Override
	public void report() {
		// instead of locking here, we tolerate exceptions
		// we do this to prevent holding the lock for very long and blocking
		// operator creation and shutdown
		try {
			for (Map.Entry<Gauge<?>, String> entry : gauges.entrySet()) {
				if (closed) {
					return;
				}
				reportGauge(entry.getValue(), entry.getKey());
			}

			for (Map.Entry<Counter, String> entry : counters.entrySet()) {
				if (closed) {
					return;
				}
				reportCounter(entry.getValue(), entry.getKey());
			}

			for (Map.Entry<Histogram, String> entry : histograms.entrySet()) {
				reportHistogram(entry.getValue(), entry.getKey());
			}

			for (Map.Entry<Meter, String> entry : meters.entrySet()) {
				reportMeter(entry.getValue(), entry.getKey());
			}
		}
		catch (ConcurrentModificationException | NoSuchElementException e) {
			// ignore - may happen when metrics are concurrently added or removed
			// report next time
		}
	}
1159972
@RequestMapping(value = "/{name}", method = RequestMethod.DELETE)
	@ResponseStatus(HttpStatus.OK)
	protected void delete(@PathVariable("name") String name) {
		FieldValueCounter counter = repository.findOne(name);
		if (counter == null) {
			throw new NoSuchMetricException(name);
		}
		repository.reset(name);
	}