From 0d3909e32effaa4ae6a4c2e40816f16c595dcd9d Mon Sep 17 00:00:00 2001 From: Joe Ellis Date: Wed, 1 Nov 2017 11:06:41 -0400 Subject: [PATCH] safe metric name params (#52) --- .../main/java/com/palantir/tritium/metrics/MetricName.java | 4 ++-- .../com/palantir/tritium/metrics/TaggedMetricRegistry.java | 4 ++-- .../palantir/tritium/metrics/TaggedMetricRegistryTest.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tritium-metrics/src/main/java/com/palantir/tritium/metrics/MetricName.java b/tritium-metrics/src/main/java/com/palantir/tritium/metrics/MetricName.java index 030fe4130..5d5f77acb 100644 --- a/tritium-metrics/src/main/java/com/palantir/tritium/metrics/MetricName.java +++ b/tritium-metrics/src/main/java/com/palantir/tritium/metrics/MetricName.java @@ -32,14 +32,14 @@ public interface MetricName { *

* 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. *

* All tags and keys must be {@link com.palantir.logsafe.Safe} to log. */ - Map tags(); + Map safeTags(); static Builder builder() { return new Builder(); diff --git a/tritium-metrics/src/main/java/com/palantir/tritium/metrics/TaggedMetricRegistry.java b/tritium-metrics/src/main/java/com/palantir/tritium/metrics/TaggedMetricRegistry.java index a93238370..98165e645 100644 --- a/tritium-metrics/src/main/java/com/palantir/tritium/metrics/TaggedMetricRegistry.java +++ b/tritium-metrics/src/main/java/com/palantir/tritium/metrics/TaggedMetricRegistry.java @@ -77,8 +77,8 @@ private T getOrAdd(MetricName metricName, Class 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); } diff --git a/tritium-metrics/src/test/java/com/palantir/tritium/metrics/TaggedMetricRegistryTest.java b/tritium-metrics/src/test/java/com/palantir/tritium/metrics/TaggedMetricRegistryTest.java index 3f023186a..98ac99472 100644 --- a/tritium-metrics/src/test/java/com/palantir/tritium/metrics/TaggedMetricRegistryTest.java +++ b/tritium-metrics/src/test/java/com/palantir/tritium/metrics/TaggedMetricRegistryTest.java @@ -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;