@Test public void toHierarchicalNameOverrideNameConvention() { mapper = new PrefixHierarchicalNameMapper("mojito", "_t_", null, NamingConvention.snakeCase); Meter.Id id = new Meter.Id("metric.name", Tags.of("tag.with.case.1", "value1").and("tag2", "value2"), null, null, Meter.Type.COUNTER); String hierarchicalName = mapper.toHierarchicalName(id, NamingConvention.camelCase); logger.debug(hierarchicalName); assertEquals("mojito.metric_name._t_tag_with_case_1.value1._t_tag2.value2", hierarchicalName); }
@Override public String toHierarchicalName(Meter.Id id, NamingConvention namingConvention) { namingConvention = Optional.ofNullable(nameConventionOverride).orElse(namingConvention); String prefix = Strings.isNullOrEmpty(namePrefix) ? "" : (namingConvention.name(namePrefix, Meter.Type.OTHER) + "."); return prefix + id.getConventionName(namingConvention) + id.getConventionTags(namingConvention) .stream() .map(this::formatTag) .map(nameSegment -> nameSegment.replace(" ", "_")) .collect(Collectors.joining("")); }
PrefixHierarchicalNameMapper implements HierarchicalNameMapper { @Override public String toHierarchicalName(Meter.Id id, NamingConvention namingConvention) { namingConvention = Optional.ofNullable(nameConventionOverride).orElse(namingConvention); String prefix = Strings.isNullOrEmpty(namePrefix) ? "" : (namingConvention.name(namePrefix, Meter.Type.OTHER) + "."); return prefix + id.getConventionName(namingConvention) + id.getConventionTags(namingConvention) .stream() .map(this::formatTag) .map(nameSegment -> nameSegment.replace(" ", "_")) .collect(Collectors.joining("")); } }
PrefixHierarchicalNameMapper implements HierarchicalNameMapper { @Override public String toHierarchicalName(Meter.Id id, NamingConvention namingConvention) { namingConvention = Optional.ofNullable(nameConventionOverride).orElse(namingConvention); String prefix = Strings.isNullOrEmpty(namePrefix) ? "" : (namingConvention.name(namePrefix, Meter.Type.OTHER) + "."); return prefix + id.getConventionName(namingConvention) + id.getConventionTags(namingConvention) .stream() .map(this::formatTag) .map(nameSegment -> nameSegment.replace(" ", "_")) .collect(Collectors.joining("")); } PrefixHierarchicalNameMapper(String namePrefix,
                                        String tagKeyPrefix,
                                        String stripCharacters,
                                        @Nullable NamingConvention nameConventionOverride); }
PrefixHierarchicalNameMapper implements HierarchicalNameMapper { @Override public String toHierarchicalName(Meter.Id id, NamingConvention namingConvention) { namingConvention = Optional.ofNullable(nameConventionOverride).orElse(namingConvention); String prefix = Strings.isNullOrEmpty(namePrefix) ? "" : (namingConvention.name(namePrefix, Meter.Type.OTHER) + "."); return prefix + id.getConventionName(namingConvention) + id.getConventionTags(namingConvention) .stream() .map(this::formatTag) .map(nameSegment -> nameSegment.replace(" ", "_")) .collect(Collectors.joining("")); } PrefixHierarchicalNameMapper(String namePrefix,
                                        String tagKeyPrefix,
                                        String stripCharacters,
                                        @Nullable NamingConvention nameConventionOverride); @Override String toHierarchicalName(Meter.Id id, NamingConvention namingConvention); }
PrefixHierarchicalNameMapper implements HierarchicalNameMapper { @Override public String toHierarchicalName(Meter.Id id, NamingConvention namingConvention) { namingConvention = Optional.ofNullable(nameConventionOverride).orElse(namingConvention); String prefix = Strings.isNullOrEmpty(namePrefix) ? "" : (namingConvention.name(namePrefix, Meter.Type.OTHER) + "."); return prefix + id.getConventionName(namingConvention) + id.getConventionTags(namingConvention) .stream() .map(this::formatTag) .map(nameSegment -> nameSegment.replace(" ", "_")) .collect(Collectors.joining("")); } PrefixHierarchicalNameMapper(String namePrefix,
                                        String tagKeyPrefix,
                                        String stripCharacters,
                                        @Nullable NamingConvention nameConventionOverride); @Override String toHierarchicalName(Meter.Id id, NamingConvention namingConvention);  }