@Test public void toHierarchicalNamingConventionStrippingCharacters() { stripCharacters = "{}$!@#"; mapper = new PrefixHierarchicalNameMapper("mojito", "_t_", stripCharacters, NamingConvention.snakeCase); Tags tags = Tags.of("tag#1", "value/{1}/.") .and("tag#2", "value$2/{test}/value") .and("tag#3!", "value!3/@test#") .and("tag#4", ""); Meter.Id id = new Meter.Id("metricName", tags, null, null, Meter.Type.COUNTER); String hierarchicalName = mapper.toHierarchicalName(id, NamingConvention.camelCase); logger.debug(hierarchicalName); assertEquals("mojito.metricName._t_tag1.value/1/.._t_tag2.value2/test/value._t_tag3.value3/test._t_tag4.", 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);  }