TODO: move into a separate metric name strategy
426713
private String getParameterName(AnnotatedParameter<?> parameter) {
        Parameter[] parameters = ((Method) parameter.getDeclaringCallable().getJavaMember()).getParameters();
        Parameter param = parameters[parameter.getPosition()];
        if (param.isNamePresent()) {
            return param.getName();
        }
        else {
            throw new UnsupportedOperationException("Unable to retrieve name for parameter [" + parameter + "], activate the -parameters compiler argument or annotate the injected parameter with the @Metric annotation");
        }
    }
695380
def metric(slug, num=1, category=None, expire=None, date=None):
    """"""
    get_r().metric(slug, num=num, category=category, expire=expire, date=date)
1154327
def fire_metric(metric_name, metric_value):
    
    metric_value = float(metric_value)
    metric = {metric_name: metric_value}
    metric_client.fire_metrics(**metric)
    return "Fired metric <{}> with value <{}>".format(metric_name, metric_value)
806325
def metric(self, measurement_name, values, tags=None, timestamp=None):
        
        if not measurement_name or values in (None, {}):
            # Don't try to send empty data
            return

        tags = tags or {}

        # Do a shallow merge of the metric tags and global tags
        all_tags = dict(self.tags, **tags)

        # Create a metric line from the input and then send it to socket
        line = Line(measurement_name, values, all_tags, timestamp)
        self.send(line.to_line_protocol())
813752
private void addMetric(
      List<Metric> metrics,
      String name,
      TagList tags,
      Object value) {
    long now = System.currentTimeMillis();
    if (onlyNumericMetrics) {
      value = asNumber(value);
    }
    if (value != null) {

      TagList newTags = counters.matches(MonitorConfig.builder(name).withTags(tags).build())
          ? getTagListWithAdditionalTag(tags, DataSourceType.COUNTER)
          : getTagListWithAdditionalTag(tags, DataSourceType.GAUGE);
      Metric m = new Metric(name, newTags, now, value);
      metrics.add(m);
    }
  }
743100
public MetricName withTag(String key, String value) {
		return name(name).tags(tags).tag(key, value).build();
	}
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);
    }
  }
95721
def clean_metric_name(self, metric_name):
        
        if not self._clean_metric_name:
            return metric_name
        metric_name = str(metric_name)
        for _from, _to in self.cleaning_replacement_list:
            metric_name = metric_name.replace(_from, _to)
        return metric_name
1158713
def mmap_key(metric_name, name, labelnames, labelvalues):
    """"""
    # ensure labels are in consistent order for identity
    labels = dict(zip(labelnames, labelvalues))
    return json.dumps([metric_name, name, labels], sort_keys=True)
1357383
private void handleGetAllMMetricsName(final HttpServletRequest req,
      final Map<String, Object> ret) {
    if (MetricReportManager.isAvailable()) {
      final MetricReportManager metricManager = MetricReportManager.getInstance();
      final List<IMetric<?>> result = metricManager.getAllMetrics();
      if (result.size() == 0) {
        ret.put(RESPONSE_ERROR, "No Metric being tracked");
      } else {
        final List<String> metricNames = new LinkedList<>();
        for (final IMetric<?> metric : result) {
          metricNames.add(metric.getName());
        }
        ret.put("data", metricNames);
      }
    } else {
      ret.put(RESPONSE_ERROR, "MetricReportManager is not available");
    }
  }
1067611
def _format_metric_name(self, m_name, cfunc):
        '''  '''
        try:
            aggr = CFUNC_TO_AGGR[cfunc]
        except KeyError:
            aggr = cfunc.lower()

        try:
            m_name = CACTI_TO_DD[m_name]
            if aggr != 'avg':
                m_name += '.{}'.format(aggr)
            return m_name
        except KeyError:
            return "cacti.{}.{}".format(m_name.lower(), aggr)
1163123
def make_multi_metric(*metrics):
    
    def multi_metric(name, count, elapsed):
        """Calls multiple metrics (closure)"""
        for m in metrics:
            m(name, count, elapsed)
    return multi_metric
42485
private List<Long> collectLongMetric(String metricGetterName) {
        List<Long> vals = new ArrayList<Long>();
        for(BdbEnvironmentStats envStats: environmentStatsTracked) {
            vals.add((Long) ReflectUtils.callMethod(envStats,
                                                    BdbEnvironmentStats.class,
                                                    metricGetterName,
                                                    new Class<?>[0],
                                                    new Object[0]));
        }
        return vals;
    }
399269
private static DecoratorMap metric_map_(Map<IdentifierPair, MetricMatcher> matchers) {
        if (matchers.isEmpty()) return concat();

        return new DecoratorMap() {
            @Override
            public Stream<Consumer<MutableContext>> map(Stream<Consumer<MutableContext>> in, Context ctx) {
                final Map<IdentifierPair, List<Map.Entry<MetricMatcher.MatchedName, MetricValue>>> metricMapping = matchers.entrySet().stream()
                        .collect(Collectors.toMap(Map.Entry::getKey,
                                mmEntry -> mmEntry.getValue().filter(ctx).collect(Collectors.toList())));

                for (final Map.Entry<IdentifierPair, List<Map.Entry<MetricMatcher.MatchedName, MetricValue>>> mm
                     : metricMapping.entrySet()) {
                    final String groupIdentifier = mm.getKey().getGroup();
                    final String metricIdentifier = mm.getKey().getMetric();
                    final List<Consumer<MutableContext>> applications = mm.getValue().stream()
                            .map(matchedMetric -> {
                                Consumer<MutableContext> application = (nestedCtx) -> {
                                    nestedCtx.putGroupAliasByName(groupIdentifier, matchedMetric.getKey().getMatchedGroup()::getGroup);
                                    nestedCtx.putMetricAliasByName(metricIdentifier, matchedMetric.getKey().getMatchedGroup()::getGroup, matchedMetric.getKey()::getMetric);
                                };
                                return application;
                            })
                            .collect(Collectors.toList());

                    in = in.flatMap(inApplication -> applications.stream().map(inApplication::andThen));
                }
                return in;
            }
        };
    }
1289479
def metrics(self, name):
        
        return [
            MetricStub(
                ensure_unicode(stub.name),
                stub.type,
                stub.value,
                normalize_tags(stub.tags),
                ensure_unicode(stub.hostname),
            )
            for stub in self._metrics.get(to_string(name), [])
        ]
650878
function assignExtraMetrics(ctx, name, payload) {
	let def = ctx.action.metrics[name];
	// if metrics definitions is boolean do default, metrics=true
	if (def === true) {
		payload[name] = ctx[name];
	} else if (_.isArray(def)) {
		payload[name] = _.pick(ctx[name], def);
	} else if (_.isFunction(def)) {
		payload[name] = def(ctx[name]);
	}
}
242124
function map (msg, done) {
    var metric = {
      source: msg.source,
      name: 'my-metric',
      values: {val: msg.payload.val},
      tags: {tag: msg.payload.tag}
    }

    done(null, [metric])
  }