/** * Add tags to a metric name and return the newly created MetricName. * * @param add Tags to add. * @return A newly created metric name with the specified tags associated with it. */ public MetricId tagged(Map<String, String> add) { final TreeMap<String, String> tags = new TreeMap<>(this.tags); tags.putAll(add); return new MetricId(key, tags); }
/** * Build a new metric name using the specific path components. * * @param parts Path of the new metric name. * @return A newly created metric name with the specified path. **/ public static MetricId build(final String... parts) { if (parts == null || parts.length == 0) { return MetricId.EMPTY; } if (parts.length == 1) { return new MetricId(parts[0], EMPTY_TAGS); } return new MetricId(key(parts), EMPTY_TAGS); }
/** * Build the MetricName that is this with another path appended to it. * <p> * The new MetricName inherits the tags of this one. * * @param part The extra path element to add to the new metric. * @return A new metric name relative to the original by the path specified in p. */ public MetricId resolve(final String part) { return new MetricId(extendKey(part), tags); }
/** * Wraps an {@link java.util.concurrent.ScheduledExecutorService} uses an auto-generated default * name. * * @param delegate {@link java.util.concurrent.ScheduledExecutorService} to wrap. * @param registry {@link com.codahale.metrics.MetricRegistry} that will contain the metrics. */ public InstrumentedScheduledExecutorService( ScheduledExecutorService delegate, SemanticMetricRegistry registry ) { this(delegate, registry, new MetricId().tagged("executor", "scheduled-executor-" + NAME_COUNTER.incrementAndGet())); }
/** * Wraps an {@link java.util.concurrent.ScheduledExecutorService} uses an auto-generated default * name. * * @param delegate {@link java.util.concurrent.ScheduledExecutorService} to wrap. * @param registry {@link com.codahale.metrics.MetricRegistry} that will contain the metrics. */ public InstrumentedScheduledExecutorService( ScheduledExecutorService delegate, SemanticMetricRegistry registry ) { this(delegate, registry, new MetricId().tagged("executor", "scheduled-executor-" + NAME_COUNTER.incrementAndGet())); }
public InstrumentedExecutorService(ExecutorService delegate, SemanticMetricRegistry registry) { this(delegate, registry, new MetricId().tagged("executor", "executor-" + NAME_COUNTER.incrementAndGet())); }
public InstrumentedExecutorService(ExecutorService delegate, SemanticMetricRegistry registry) { this(delegate, registry, new MetricId().tagged("executor", "executor-" + NAME_COUNTER.incrementAndGet())); }
/** * Join the specified set of metric names. * * @param parts Multiple metric names to join using the separator. * @return A newly created metric name which has the name of the specified parts and includes * all tags of all child metric names. **/ public static MetricId join(MetricId... parts) { final StringBuilder nameBuilder = new StringBuilder(); final Map<String, String> tags = new HashMap<String, String>(); boolean first = true; for (MetricId part : parts) { final String name = part.getKey(); if (name != null && !name.isEmpty()) { if (first) { first = false; } else { nameBuilder.append(SEPARATOR); } nameBuilder.append(name); } if (!part.getTags().isEmpty()) { tags.putAll(part.getTags()); } } return new MetricId(nameBuilder.toString(), tags); }