Skip to content

Commit

Permalink
safe metric name params (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellisjoe authored and schlosna committed Nov 1, 2017
1 parent e4a5f1e commit 0d3909e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ public interface MetricName {
* <p>
* Names must be {@link com.palantir.logsafe.Safe} to log.
*/
String name();
String safeName();

/**
* Metadata/coordinates for where a particular measure came from. Used for filtering & grouping.
* <p>
* All tags and keys must be {@link com.palantir.logsafe.Safe} to log.
*/
Map<String, String> tags();
Map<String, String> safeTags();

static Builder builder() {
return new Builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ private <T extends Metric> T getOrAdd(MetricName metricName, Class<T> metricClas
if (!metricClass.isInstance(metric)) {
throw new IllegalArgumentException(String.format(
"'%s' already used for a metric of type '%s' but wanted type '%s'. tags: %s",
metricName.name(), metric.getClass().getSimpleName(),
metricClass.getSimpleName(), metricName.tags()));
metricName.safeName(), metric.getClass().getSimpleName(),
metricClass.getSimpleName(), metricName.safeTags()));
}
return metricClass.cast(metric);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

public final class TaggedMetricRegistryTest {

private static final MetricName METRIC_1 = MetricName.builder().name("name").build();
private static final MetricName METRIC_2 = MetricName.builder().name("name").putTags("key", "val").build();
private static final MetricName METRIC_1 = MetricName.builder().safeName("name").build();
private static final MetricName METRIC_2 = MetricName.builder().safeName("name").putSafeTags("key", "val").build();

private TaggedMetricRegistry registry;

Expand Down

0 comments on commit 0d3909e

Please sign in to comment.