use of org.eclipse.microprofile.metrics.annotation.Metric in project Payara by payara.
the class MetricsHelper method metricNameOf.
private String metricNameOf(AnnotatedMember<?> member) {
if (member.isAnnotationPresent(Metric.class)) {
Metric metric = member.getAnnotation(Metric.class);
String name = metric.name().isEmpty() ? member.getJavaMember().getName() : metric.name();
return metric.absolute() ? name : MetricRegistry.name(member.getJavaMember().getDeclaringClass(), name);
} else {
String name = member.getJavaMember().getName();
return MetricRegistry.name(member.getJavaMember().getDeclaringClass(), name);
}
}
use of org.eclipse.microprofile.metrics.annotation.Metric in project Payara by payara.
the class MetricsHelper method metricNameOf.
private String metricNameOf(AnnotatedParameter<?> parameter) {
if (parameter.isAnnotationPresent(Metric.class)) {
Metric metric = parameter.getAnnotation(Metric.class);
String name = metric.name().isEmpty() ? getParameterName(parameter) : metric.name();
return metric.absolute() ? name : MetricRegistry.name(parameter.getDeclaringCallable().getJavaMember().getDeclaringClass(), name);
} else {
String name = getParameterName(parameter);
return MetricRegistry.name(parameter.getDeclaringCallable().getJavaMember().getDeclaringClass(), name);
}
}
use of org.eclipse.microprofile.metrics.annotation.Metric in project Payara by payara.
the class MetricsHelper method metadataOf.
private Metadata metadataOf(Annotated annotated, Class<?> type, String name) {
Metadata metadata = new Metadata(name, MetricType.from(type));
if (annotated.isAnnotationPresent(Metric.class)) {
Metric metric = annotated.getAnnotation(Metric.class);
metadata.setDescription(metric.description() == null || metric.description().trim().isEmpty() ? null : metric.description());
metadata.setDisplayName(metric.displayName() == null || metric.displayName().trim().isEmpty() ? null : metric.displayName());
metadata.setUnit(metric.unit() == null || metric.unit().trim().isEmpty() ? null : metric.unit());
for (String tag : metric.tags()) {
metadata.addTag(tag);
}
}
return metadata;
}