Java Code Examples for org.eclipse.microprofile.metrics.MetricRegistry#Type
The following examples show how to use
org.eclipse.microprofile.metrics.MetricRegistry#Type .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenMetricsExporter.java From smallrye-metrics with Apache License 2.0 | 6 votes |
private void writeTypeLine(StringBuilder sb, MetricRegistry.Type scope, String key, Metadata md, String suffix, String typeOverride) { if (!alreadyExportedNames.get().contains(md.getName())) { sb.append("# TYPE "); getNameWithScopeAndSuffix(sb, scope, key, suffix, md); if (typeOverride != null) { sb.append(typeOverride); } else if (md.getTypeRaw().equals(MetricType.TIMER)) { sb.append(SUMMARY); } else if (md.getTypeRaw().equals(MetricType.METERED)) { sb.append(COUNTER); } else { sb.append(md.getType()); } sb.append(LF); } }
Example 2
Source File: OpenMetricsExporter.java From smallrye-metrics with Apache License 2.0 | 6 votes |
private void addTags(StringBuilder sb, Map<String, String> tags, MetricRegistry.Type scope, Metadata metadata) { if (tags == null || tags.isEmpty()) { // always add the microprofile_scope even if there are no other tags if (writeScopeInTag(metadata)) { sb.append("{microprofile_scope=\"" + scope.getName().toLowerCase() + "\"}"); } return; } else { Iterator<Map.Entry<String, String>> iter = tags.entrySet().iterator(); sb.append("{"); while (iter.hasNext()) { Map.Entry<String, String> tag = iter.next(); sb.append(tag.getKey()).append("=\"").append(quoteValue(tag.getValue())).append("\""); if (iter.hasNext()) { sb.append(","); } } // append the microprofile_scope after other tags if (writeScopeInTag(metadata)) { sb.append(",microprofile_scope=\"" + scope.getName().toLowerCase() + "\""); } sb.append("}"); } }
Example 3
Source File: OpenMetricsExporter.java From smallrye-metrics with Apache License 2.0 | 5 votes |
private void getNameWithScopeAndSuffix(StringBuilder sb, MetricRegistry.Type scope, String key, String suffix, Metadata metadata) { if (writeScopeInPrefix(metadata)) { sb.append(scope.getName().toLowerCase()).append('_'); } sb.append(getOpenMetricsMetricName(key)); if (suffix != null) { sb.append(suffix); } sb.append(SPACE); }
Example 4
Source File: OpenMetricsExporter.java From smallrye-metrics with Apache License 2.0 | 5 votes |
private void writeConcurrentGaugeValues(StringBuilder sb, MetricRegistry.Type scope, ConcurrentGauge concurrentGauge, Metadata md, String key, Map<String, String> tags) { key = getOpenMetricsMetricName(key); writeHelpLine(sb, scope, key, md, "_current"); writeTypeAndValue(sb, scope, "_current", concurrentGauge.getCount(), GAUGE, md, false, tags); writeTypeAndValue(sb, scope, "_max", concurrentGauge.getMax(), GAUGE, md, false, tags); writeTypeAndValue(sb, scope, "_min", concurrentGauge.getMin(), GAUGE, md, false, tags); }
Example 5
Source File: OpenMetricsExporter.java From smallrye-metrics with Apache License 2.0 | 5 votes |
private void fillBaseName(StringBuilder sb, MetricRegistry.Type scope, String key, String suffix, Metadata metadata) { if (writeScopeInPrefix(metadata)) { sb.append(scope.getName().toLowerCase()).append("_"); } sb.append(key); if (suffix != null) sb.append(suffix); }
Example 6
Source File: OpenMetricsExporter.java From smallrye-metrics with Apache License 2.0 | 5 votes |
private void writeMeterRateValues(StringBuilder sb, MetricRegistry.Type scope, Metered metric, Metadata md, Map<String, String> tags) { writeTypeAndValue(sb, scope, "_rate_per_second", metric.getMeanRate(), GAUGE, md, false, tags); writeTypeAndValue(sb, scope, "_one_min_rate_per_second", metric.getOneMinuteRate(), GAUGE, md, false, tags); writeTypeAndValue(sb, scope, "_five_min_rate_per_second", metric.getFiveMinuteRate(), GAUGE, md, false, tags); writeTypeAndValue(sb, scope, "_fifteen_min_rate_per_second", metric.getFifteenMinuteRate(), GAUGE, md, false, tags); }
Example 7
Source File: OpenMetricsExporter.java From smallrye-metrics with Apache License 2.0 | 5 votes |
@Override public StringBuilder exportAllScopes() { StringBuilder sb = new StringBuilder(); for (MetricRegistry.Type scope : MetricRegistry.Type.values()) { alreadyExportedNames.set(new HashSet<>()); getEntriesForScope(scope, sb); alreadyExportedNames.set(null); } return sb; }
Example 8
Source File: OpenMetricsExporter.java From smallrye-metrics with Apache License 2.0 | 5 votes |
@Override public StringBuilder exportOneScope(MetricRegistry.Type scope) { alreadyExportedNames.set(new HashSet<>()); StringBuilder sb = new StringBuilder(); getEntriesForScope(scope, sb); alreadyExportedNames.set(null); return sb; }
Example 9
Source File: OpenMetricsExporter.java From smallrye-metrics with Apache License 2.0 | 4 votes |
private void writeMeterValues(StringBuilder sb, MetricRegistry.Type scope, Metered metric, Metadata md, Map<String, String> tags) { writeHelpLine(sb, scope, md.getName(), md, "_total"); writeTypeAndValue(sb, scope, "_total", metric.getCount(), COUNTER, md, false, tags); writeMeterRateValues(sb, scope, metric, md, tags); }
Example 10
Source File: MetricBuildItem.java From quarkus with Apache License 2.0 | 4 votes |
public Builder registryType(MetricRegistry.Type scope) { this.registryType = scope; return this; }
Example 11
Source File: OpenMetricsExporter.java From smallrye-metrics with Apache License 2.0 | 4 votes |
private void writeValueLine(StringBuilder sb, MetricRegistry.Type scope, String suffix, double valueRaw, Metadata md, Map<String, String> tags) { writeValueLine(sb, scope, suffix, valueRaw, md, tags, true); }
Example 12
Source File: JsonMetadataExporter.java From smallrye-metrics with Apache License 2.0 | 4 votes |
@Override public StringBuilder exportOneMetric(MetricRegistry.Type scope, MetricID metricID) { throw new UnsupportedOperationException( "Exporting metadata of one metricID is currently not implemented because it is not possible to perform such export according to specification."); }
Example 13
Source File: MetricBuildItem.java From quarkus with Apache License 2.0 | 4 votes |
public MetricRegistry.Type getRegistryType() { return registryType; }
Example 14
Source File: OpenMetricsExporter.java From smallrye-metrics with Apache License 2.0 | 4 votes |
private void writeTypeAndValue(StringBuilder sb, MetricRegistry.Type scope, String suffix, double valueRaw, String type, Metadata md, boolean performScaling, Map<String, String> tags) { String key = md.getName(); writeTypeLine(sb, scope, key, md, suffix, type); writeValueLine(sb, scope, suffix, valueRaw, md, tags, performScaling); }
Example 15
Source File: RegistryTypeLiteral.java From smallrye-graphql with Apache License 2.0 | 4 votes |
public RegistryTypeLiteral(MetricRegistry.Type type) { this.type = type; }
Example 16
Source File: OpenMetricsExporter.java From smallrye-metrics with Apache License 2.0 | 4 votes |
private void getEntriesForScope(MetricRegistry.Type scope, StringBuilder sb) { MetricRegistry registry = MetricRegistries.get(scope); Map<MetricID, Metric> metricMap = registry.getMetrics(); exposeEntries(scope, sb, registry, new TreeMap<>(metricMap)); }
Example 17
Source File: MetricBuildItem.java From quarkus with Apache License 2.0 | 3 votes |
/** * Create a metric build item from the specified metadata, tags, a callable, and scope. * Such metric will be picked up by the Metrics extension and registered in the registry for the desired scope. * * @param metadata The metadata that should be applied to the registered metric * @param implementor The object that implements the metric. It must be an instance of the appropriate * metric class (from the {@link org.eclipse.microprofile.metrics} package). * This is required for gauges and optional for all other metric types. * @param enabled Whether this metric is enabled * @param tags The tags that will be applied to this metric * @param configRootName the name of the root configuration of the extension as defined by the <code>@ConfigRoot</code> * annotation. * @param registryType Registry where the metric should be placed * */ public MetricBuildItem(Metadata metadata, Object implementor, boolean enabled, String configRootName, MetricRegistry.Type registryType, Tag... tags) { if (implementor == null && metadata.getTypeRaw() == MetricType.GAUGE) { throw new IllegalArgumentException("Gauges require a non-null implementation object"); } this.metadata = metadata; this.tags = tags; this.implementor = implementor; this.enabled = enabled; this.configRootName = configRootName; this.registryType = registryType; }
Example 18
Source File: Exporter.java From smallrye-metrics with Apache License 2.0 | 2 votes |
/** * Exports all metrics with the given name inside the given scope. */ StringBuilder exportMetricsByName(MetricRegistry.Type scope, String name);
Example 19
Source File: Exporter.java From smallrye-metrics with Apache License 2.0 | votes |
StringBuilder exportOneScope(MetricRegistry.Type scope);
Example 20
Source File: MetricsService.java From smallrye-graphql with Apache License 2.0 | votes |
MetricRegistry getMetricRegistry(MetricRegistry.Type type);