@Test void testJsonMetaWithTags() { JsonObject expected = Json.createReader(new StringReader(JSON_META_WITH_TAGS)).readObject(); JsonObjectBuilder builder = Json.createObjectBuilder(); impl.jsonMeta(builder, METRIC_IDS); assertThat(builder.build(), is(expected)); }
@Override public void jsonMeta(JsonObjectBuilder builder, List<MetricID> metricIDs) { JsonObjectBuilder metaBuilder = new MetricsSupport.MergingJsonObjectBuilder(JSON.createObjectBuilder()); addNonEmpty(metaBuilder, "unit", metadata.getUnit().orElse(null)); addNonEmpty(metaBuilder, "type", metadata.getType()); addNonEmpty(metaBuilder, "description", metadata.getDescription().orElse(null)); addNonEmpty(metaBuilder, "displayName", metadata.getDisplayName()); if (metricIDs != null) { for (MetricID metricID : metricIDs) { boolean tagAdded = false; JsonArrayBuilder ab = JSON.createArrayBuilder(); for (Tag tag : metricID.getTagsAsList()) { tagAdded = true; ab.add(tagForJsonKey(tag)); } if (tagAdded) { metaBuilder.add("tags", ab); } } } builder.add(getName(), metaBuilder); }
MetricImpl implements HelidonMetric { @Override public void jsonMeta(JsonObjectBuilder builder, List<MetricID> metricIDs) { JsonObjectBuilder metaBuilder = new MetricsSupport.MergingJsonObjectBuilder(JSON.createObjectBuilder()); addNonEmpty(metaBuilder, "unit", metadata.getUnit().orElse(null)); addNonEmpty(metaBuilder, "type", metadata.getType()); addNonEmpty(metaBuilder, "description", metadata.getDescription().orElse(null)); addNonEmpty(metaBuilder, "displayName", metadata.getDisplayName()); if (metricIDs != null) { for (MetricID metricID : metricIDs) { boolean tagAdded = false; JsonArrayBuilder ab = JSON.createArrayBuilder(); for (Tag tag : metricID.getTagsAsList()) { tagAdded = true; ab.add(tagForJsonKey(tag)); } if (tagAdded) { metaBuilder.add("tags", ab); } } } builder.add(getName(), metaBuilder); } }
MetricImpl implements HelidonMetric { @Override public void jsonMeta(JsonObjectBuilder builder, List<MetricID> metricIDs) { JsonObjectBuilder metaBuilder = new MetricsSupport.MergingJsonObjectBuilder(JSON.createObjectBuilder()); addNonEmpty(metaBuilder, "unit", metadata.getUnit().orElse(null)); addNonEmpty(metaBuilder, "type", metadata.getType()); addNonEmpty(metaBuilder, "description", metadata.getDescription().orElse(null)); addNonEmpty(metaBuilder, "displayName", metadata.getDisplayName()); if (metricIDs != null) { for (MetricID metricID : metricIDs) { boolean tagAdded = false; JsonArrayBuilder ab = JSON.createArrayBuilder(); for (Tag tag : metricID.getTagsAsList()) { tagAdded = true; ab.add(tagForJsonKey(tag)); } if (tagAdded) { metaBuilder.add("tags", ab); } } } builder.add(getName(), metaBuilder); } MetricImpl(String registryType, Metadata metadata); }
MetricImpl implements HelidonMetric { @Override public void jsonMeta(JsonObjectBuilder builder, List<MetricID> metricIDs) { JsonObjectBuilder metaBuilder = new MetricsSupport.MergingJsonObjectBuilder(JSON.createObjectBuilder()); addNonEmpty(metaBuilder, "unit", metadata.getUnit().orElse(null)); addNonEmpty(metaBuilder, "type", metadata.getType()); addNonEmpty(metaBuilder, "description", metadata.getDescription().orElse(null)); addNonEmpty(metaBuilder, "displayName", metadata.getDisplayName()); if (metricIDs != null) { for (MetricID metricID : metricIDs) { boolean tagAdded = false; JsonArrayBuilder ab = JSON.createArrayBuilder(); for (Tag tag : metricID.getTagsAsList()) { tagAdded = true; ab.add(tagForJsonKey(tag)); } if (tagAdded) { metaBuilder.add("tags", ab); } } } builder.add(getName(), metaBuilder); } MetricImpl(String registryType, Metadata metadata); @Override String getName(); @Override Metadata metadata(); @Override String toString(); @Override void jsonMeta(JsonObjectBuilder builder, List<MetricID> metricIDs); @Override void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType); @Override String prometheusNameWithUnits(MetricID metricID); abstract String prometheusValue(); }
MetricImpl implements HelidonMetric { @Override public void jsonMeta(JsonObjectBuilder builder, List<MetricID> metricIDs) { JsonObjectBuilder metaBuilder = new MetricsSupport.MergingJsonObjectBuilder(JSON.createObjectBuilder()); addNonEmpty(metaBuilder, "unit", metadata.getUnit().orElse(null)); addNonEmpty(metaBuilder, "type", metadata.getType()); addNonEmpty(metaBuilder, "description", metadata.getDescription().orElse(null)); addNonEmpty(metaBuilder, "displayName", metadata.getDisplayName()); if (metricIDs != null) { for (MetricID metricID : metricIDs) { boolean tagAdded = false; JsonArrayBuilder ab = JSON.createArrayBuilder(); for (Tag tag : metricID.getTagsAsList()) { tagAdded = true; ab.add(tagForJsonKey(tag)); } if (tagAdded) { metaBuilder.add("tags", ab); } } } builder.add(getName(), metaBuilder); } MetricImpl(String registryType, Metadata metadata); @Override String getName(); @Override Metadata metadata(); @Override String toString(); @Override void jsonMeta(JsonObjectBuilder builder, List<MetricID> metricIDs); @Override void prometheusData(StringBuilder sb, MetricID metricID, boolean withHelpType); @Override String prometheusNameWithUnits(MetricID metricID); abstract String prometheusValue();  }