use of org.jboss.as.controller.client.helpers.MeasurementUnit in project wildfly by wildfly.
the class MetricCollector method collectResourceMetrics0.
private void collectResourceMetrics0(final Resource current, ImmutableManagementResourceRegistration managementResourceRegistration, PathAddress address, Function<PathAddress, PathAddress> resourceAddressResolver, MetricRegistration registration, boolean exposeAnySubsystem, List<String> exposedSubsystems, String prefix) {
if (!isExposingMetrics(address, exposeAnySubsystem, exposedSubsystems)) {
return;
}
Map<String, AttributeAccess> attributes = managementResourceRegistration.getAttributes(address);
if (attributes == null) {
return;
}
ModelNode resourceDescription = null;
for (Map.Entry<String, AttributeAccess> entry : attributes.entrySet()) {
String attributeName = entry.getKey();
AttributeAccess attributeAccess = entry.getValue();
if (!isCollectibleMetric(attributeAccess)) {
continue;
}
if (resourceDescription == null) {
DescriptionProvider modelDescription = managementResourceRegistration.getModelDescription(address);
resourceDescription = modelDescription.getModelDescription(Locale.getDefault());
}
PathAddress resourceAddress = resourceAddressResolver.apply(address);
MeasurementUnit unit = attributeAccess.getAttributeDefinition().getMeasurementUnit();
boolean isCounter = attributeAccess.getFlags().contains(AttributeAccess.Flag.COUNTER_METRIC);
String attributeDescription = resourceDescription.get(ATTRIBUTES, attributeName, DESCRIPTION).asStringOrNull();
WildFlyMetric metric = new WildFlyMetric(modelControllerClient, resourceAddress, attributeName);
WildFlyMetricMetadata metadata = new WildFlyMetricMetadata(attributeName, resourceAddress, prefix, attributeDescription, unit, isCounter ? COUNTER : GAUGE);
registration.addRegistrationTask(() -> registration.registerMetric(metric, metadata));
registration.addUnregistrationTask(metadata.getMetricID());
}
for (String type : current.getChildTypes()) {
for (Resource.ResourceEntry entry : current.getChildren(type)) {
final PathElement pathElement = entry.getPathElement();
final PathAddress childAddress = address.append(pathElement);
collectResourceMetrics0(entry, managementResourceRegistration, childAddress, resourceAddressResolver, registration, exposeAnySubsystem, exposedSubsystems, prefix);
}
}
}
use of org.jboss.as.controller.client.helpers.MeasurementUnit in project wildfly by wildfly.
the class JmxMetricCollector method metadataOf.
private JmxMetricMetadata metadataOf(Map.Entry<String, List<MetricProperty>> metadataEntry) {
String name = metadataEntry.getKey();
Map<String, String> entryProperties = new HashMap<>();
metadataEntry.getValue().forEach(prop -> entryProperties.put(prop.propertyKey, prop.propertyValue));
List<String> tagsToFill = new ArrayList<>();
if (entryProperties.containsKey("tagsToFill")) {
tagsToFill = Arrays.asList(entryProperties.get("tagsToFill").split(","));
}
final MeasurementUnit unit = (entryProperties.get("unit") == null) ? NONE : MeasurementUnit.valueOf(entryProperties.get("unit").toUpperCase());
JmxMetricMetadata metadata = new JmxMetricMetadata(name, entryProperties.get("description"), unit, MetricMetadata.Type.valueOf(entryProperties.get("type").toUpperCase()), entryProperties.get("mbean"), tagsToFill, Collections.emptyList());
return metadata;
}
Aggregations