コード例 #1
0
ファイル: Counter.java プロジェクト: seeemilyplay/client_java
    /** Generate a concrete {@link Counter} from this {@link Builder}. */
    public Counter build() {
      final String name = base.buildName();
      final String docstring = base.buildDocstring();

      final Metrics.MetricFamily.Builder builder =
          Metrics.MetricFamily.newBuilder()
              .setName(name)
              .setHelp(docstring)
              .setType(Metrics.MetricType.COUNTER);

      return new Counter(
          name,
          docstring,
          base.buildLabelNames(),
          getDefaultValue(),
          builder.build(),
          base.getRegisterStatic());
    }
コード例 #2
0
ファイル: Counter.java プロジェクト: seeemilyplay/client_java
  @Override
  Metrics.MetricFamily.Builder annotateBuilder(final Metrics.MetricFamily.Builder b) {
    for (final Map<String, String> labels : children.keySet()) {
      final Child child = children.get(labels);
      final Metrics.Metric.Builder m = b.addMetricBuilder();

      for (final String label : labels.keySet()) {
        final String value = labels.get(label);
        m.addLabelBuilder().setName(label).setValue(value);
      }

      m.setCounter(Metrics.Counter.newBuilder().setValue(child.value.get()));
    }

    return b;
  }