use of org.eclipse.microprofile.metrics.MetricRegistry in project wildfly-swarm by wildfly-swarm.
the class JsonMetadataExporter method exportAllScopes.
@Override
public StringBuilder exportAllScopes() {
StringBuilder sb = new StringBuilder();
sb.append("{");
MetricRegistry.Type[] values = MetricRegistry.Type.values();
int totalNonEmptyScopes = Helper.countNonEmptyScopes();
int scopes = 0;
for (int i = 0; i < values.length; i++) {
MetricRegistry.Type scope = values[i];
MetricRegistry registry = MetricRegistryFactory.get(scope);
if (registry.getNames().size() > 0) {
sb.append('"').append(scope.getName().toLowerCase()).append('"').append(" :\n");
getDataForOneScope(scope, sb);
sb.append(LF);
scopes++;
if (scopes < totalNonEmptyScopes) {
sb.append(',');
}
}
}
sb.append("}");
return sb;
}
use of org.eclipse.microprofile.metrics.MetricRegistry in project wildfly-swarm by wildfly-swarm.
the class JsonMetadataExporter method getDataForOneScope.
private void getDataForOneScope(MetricRegistry.Type scope, StringBuilder sb) {
MetricRegistry registry = MetricRegistryFactory.get(scope);
Map<String, Metadata> theMetadata = registry.getMetadata();
sb.append("{");
writeMetadataForMap(sb, theMetadata);
sb.append("}");
}
use of org.eclipse.microprofile.metrics.MetricRegistry in project wildfly-swarm by wildfly-swarm.
the class JsonMetadataExporter method exportOneMetric.
@Override
public StringBuilder exportOneMetric(MetricRegistry.Type scope, String metricName) {
MetricRegistry registry = MetricRegistryFactory.get(scope);
Map<String, Metadata> metadataMap = registry.getMetadata();
Metadata m = metadataMap.get(metricName);
Map<String, Metadata> outMap = new HashMap<>(1);
outMap.put(metricName, m);
StringBuilder sb = new StringBuilder();
sb.append("{");
writeMetadataForMap(sb, outMap);
sb.append("}");
sb.append(LF);
return sb;
}
use of org.eclipse.microprofile.metrics.MetricRegistry in project Payara by payara.
the class FaultToleranceServiceImpl method createMethodContext.
private FaultToleranceMethodContextImpl createMethodContext(MethodKey methodKey, InvocationContext context, RequestContextController requestContextController) {
MetricsService.MetricsContext metricsContext = getMetricsContext();
MetricRegistry metricRegistry = metricsContext != null ? metricsContext.getBaseRegistry() : null;
String appName = metricsContext != null ? metricsContext.getName() : "";
FaultToleranceMetrics metrics = metricRegistry == null ? FaultToleranceMetrics.DISABLED : new MethodFaultToleranceMetrics(metricRegistry, FaultToleranceUtils.getCanonicalMethodName(context));
logger.log(Level.FINE, "Creating FT method context for {0}", methodKey);
return new FaultToleranceMethodContextImpl(requestContextController, this, metrics, asyncExecutorService, delayExecutorService, appName);
}
use of org.eclipse.microprofile.metrics.MetricRegistry in project Payara by payara.
the class MetricsServiceImpl method processMetadataToAnnotations.
private static void processMetadataToAnnotations(MetricsContextImpl context, MonitoringDataCollector collector) {
RegisteredMetric metric = context.pollNewlyRegistered();
while (metric != null) {
MetricID metricID = metric.id;
Type scope = metric.scope;
MetricRegistry registry = context.getRegistry(scope);
MonitoringDataCollector metricCollector = tagCollector(context.getName(), metricID, collector);
Metadata metadata = registry.getMetadata(metricID.getName());
String suffix = "Count";
String property = "Count";
boolean isGauge = metadata.getTypeRaw() == MetricType.GAUGE;
if (isGauge) {
suffix = getMetricUnitSuffix(metadata.unit());
property = "Value";
}
// Note that by convention an annotation with value 0 done before the series collected any value is considered permanent
metricCollector.annotate(toName(metricID, suffix), 0, false, metadataToAnnotations(context.getName(), scope, metadata, property));
metric = context.pollNewlyRegistered();
}
}
Aggregations