Skip to content

Commit

Permalink
Merge pull request #4076 from Cousjava/PAYARA-3830-metrics-20
Browse files Browse the repository at this point in the history
PAYARA-3830 Microprofile Metrics 2.0
  • Loading branch information
Cousjava committed Jul 19, 2019
2 parents f2406da + 91d7d20 commit df8ebd0
Show file tree
Hide file tree
Showing 29 changed files with 1,362 additions and 504 deletions.
18 changes: 18 additions & 0 deletions appserver/payara-appserver-modules/microprofile/metrics/pom.xml
Expand Up @@ -60,6 +60,24 @@
<target>${javase.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>schemagen</id>
<goals>
<goal>schemagen</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>src/main/java/fish/payara/microprofile/metrics/jmx/MBeanMetadataConfig.java</source>
</sources>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
Expand Down
Expand Up @@ -74,6 +74,7 @@
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import org.eclipse.microprofile.metrics.MetricID;

import static org.eclipse.microprofile.metrics.MetricRegistry.Type.BASE;
import static org.eclipse.microprofile.metrics.MetricRegistry.Type.VENDOR;
Expand Down Expand Up @@ -162,18 +163,17 @@ public void event(Event event) {
* @param metadataConfig
*/
private void initMetadataConfig(List<MBeanMetadata> baseMetadataList, List<MBeanMetadata> vendorMetadataList, boolean isRetry) {
Map<String, String> globalTags = MetricsHelper.getGlobalTagsMap();
if (!baseMetadataList.isEmpty()) {
unresolvedBaseMetadataList = helper.registerMetadata(
getOrAddRegistry(BASE.getName()),
baseMetadataList,
globalTags, isRetry);
isRetry);
}
if (!vendorMetadataList.isEmpty()) {
unresolvedVendorMetadataList = helper.registerMetadata(
getOrAddRegistry(VENDOR.getName()),
vendorMetadataList,
globalTags, isRetry);
isRetry);
}
}

Expand Down Expand Up @@ -235,7 +235,7 @@ public boolean isSecurityEnabled() {
return Boolean.parseBoolean(metricsServiceConfiguration.getSecurityEnabled());
}

public Map<String, Metric> getMetricsAsMap(String registryName) throws NoSuchRegistryException {
public Map<MetricID, Metric> getMetricsAsMap(String registryName) throws NoSuchRegistryException {
MetricRegistry registry = getRegistry(registryName);
return registry.getMetrics();
}
Expand All @@ -245,14 +245,27 @@ public Map<String, Metadata> getMetadataAsMap(String registryName) throws NoSuch
return registry.getMetadata();
}

public Map<String, Metric> getMetricsAsMap(String registryName, String metricName) throws NoSuchRegistryException, NoSuchMetricException {
public Set<MetricID> getMetricsIDs(String registryName, String metricName) throws NoSuchRegistryException, NoSuchMetricException {
MetricRegistry registry = getRegistry(registryName);
Map<String, Metric> metricMap = registry.getMetrics();
if (metricMap.containsKey(metricName)) {
return Collections.singletonMap(metricName, metricMap.get(metricName));
} else {
throw new NoSuchMetricException(metricName);
Map<MetricID, Metric> metricMap = registry.getMetrics();
Set<MetricID> metricIDs = new HashSet<>();
for (MetricID id: metricMap.keySet()) {
if (id.getName().contains(metricName)) {
metricIDs.add(id);
}
}
return metricIDs;
}

public Map<MetricID, Metric> getMetricsAsMap(String registryName, String metricName) throws NoSuchRegistryException, NoSuchMetricException {
MetricRegistry registry = getRegistry(registryName);
Map<MetricID, Metric> metricMap = new HashMap<>();
for (Map.Entry<MetricID, Metric> metricPair: registry.getMetrics().entrySet()) {
if (metricPair.getKey().getName().equals(metricName)) {
metricMap.put(metricPair.getKey(), metricPair.getValue());
}
}
return metricMap;
}

public Map<String, Metadata> getMetadataAsMap(String registryName, String metricName) throws NoSuchRegistryException, NoSuchMetricException {
Expand Down

This file was deleted.

0 comments on commit df8ebd0

Please sign in to comment.