mirror of
https://github.com/jlengrand/helidon.git
synced 2026-03-10 08:21:17 +00:00
Remove MP Metrics 1.0-to-2.0 bridge component and related classes in other components (#1879)
This commit is contained in:
22
CHANGELOG.md
22
CHANGELOG.md
@@ -19,6 +19,28 @@ This is the fourth milestone release of Helidon 2.0.
|
||||
|
||||
### Backward incompatible changes
|
||||
|
||||
#### Internal `helidon-common-metrics` and Related Classes Removed
|
||||
Later releases of Helidon 1.x included the `helidon-common-metrics` component and related
|
||||
classes which provided a common interface to ease the transition from MicroProfile
|
||||
Metrics 1.x to 2.x.
|
||||
Although intended for use only by Helidon subsystems rather than
|
||||
by developers and users, the component and its contents had to be public so multiple Helidon
|
||||
subsystems could use them.
|
||||
Therefore, user code might have used these elements.
|
||||
|
||||
This release removes this common interface and associated classes.
|
||||
Any user code that used these internal classes can use the corresponding supported classes in
|
||||
`io.helidon.metrics:helidon-metrics` and MicroProfile Metrics 2.0 instead.
|
||||
|
||||
|Helidon Artifact |Interfaces/Classes |
|
||||
|--------------|----------------|
|
||||
|`io.helidon.common:helidon-common-metrics` |Entire artifact, including all `io.helidon.common.metrics...` classes |
|
||||
|`io.helidon.metrics:helidon-metrics` |`HelidonMetadata` |
|
||||
| |`InternalBridgeImpl` |
|
||||
| |`InternalMetadataBuilderImpl` |
|
||||
| |`InternalMetadataImpl` |
|
||||
| |`InternalMetricIDImpl` |
|
||||
|
||||
## [2.0.0-M3]
|
||||
|
||||
### Notes
|
||||
|
||||
@@ -555,11 +555,6 @@
|
||||
<artifactId>helidon-common-context</artifactId>
|
||||
<version>${helidon.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.helidon.common</groupId>
|
||||
<artifactId>helidon-common-metrics</artifactId>
|
||||
<version>${helidon.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- db client -->
|
||||
<dependency>
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>io.helidon.common</groupId>
|
||||
<artifactId>helidon-common-project</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>helidon-common-metrics</artifactId>
|
||||
|
||||
<name>Helidon Common Metrics</name>
|
||||
|
||||
<description>
|
||||
Helidon Metrics common definitions
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.helidon.config</groupId>
|
||||
<artifactId>helidon-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.microprofile.metrics</groupId>
|
||||
<artifactId>microprofile-metrics-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,771 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
package io.helidon.common.metrics;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.SortedMap;
|
||||
import java.util.SortedSet;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.helidon.config.Config;
|
||||
|
||||
import org.eclipse.microprofile.metrics.Counter;
|
||||
import org.eclipse.microprofile.metrics.Gauge;
|
||||
import org.eclipse.microprofile.metrics.Histogram;
|
||||
import org.eclipse.microprofile.metrics.Meter;
|
||||
import org.eclipse.microprofile.metrics.Metric;
|
||||
import org.eclipse.microprofile.metrics.MetricType;
|
||||
import org.eclipse.microprofile.metrics.Timer;
|
||||
|
||||
/**
|
||||
* Internal abstraction layer for MicroProfile 1.1 and 2.0.
|
||||
* <p>
|
||||
* Only Helidon internal clients of metrics should use this interface. Other
|
||||
* clients should use Helidon BOMs or bundles which will use the appropriate
|
||||
* versions of Helidon metrics and MicroProfile Metrics.
|
||||
* <p>
|
||||
* Implementations provide for getting instances of these features:
|
||||
* <ul>
|
||||
* <li>registry factory
|
||||
* <li>metric registry
|
||||
* <li>metric ID
|
||||
* <li>metadata builder
|
||||
* <li>metadata
|
||||
* </ul>
|
||||
* This interface is organized accordingly. Each of these exposes a factory and
|
||||
* an instance of that factory. (The metadata builder from MP Metrics 2.0 is the
|
||||
* factory for metadata, and therefore is nested under metadata in this
|
||||
* interface. ) The top level of the bridge also exposes a few convenience
|
||||
* methods for getting new instances of a version-specific implementations of the types.
|
||||
*/
|
||||
public interface InternalBridge {
|
||||
|
||||
/**
|
||||
* Returns the singleton instance of the bridge.
|
||||
*/
|
||||
InternalBridge INSTANCE = Loader.internalBridge();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the singleton metric ID factory
|
||||
*/
|
||||
MetricID.Factory getMetricIDFactory();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the singleton metadata builder factory
|
||||
*/
|
||||
Metadata.MetadataBuilder.Factory getMetadataBuilderFactory();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the singleton registry factory
|
||||
*/
|
||||
MetricRegistry.RegistryFactory getRegistryFactory();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return a metadata builder
|
||||
*/
|
||||
static Metadata.MetadataBuilder newMetadataBuilder() {
|
||||
return INSTANCE.getMetadataBuilderFactory().newMetadataBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code RegistryFactory} with the default configuration, as
|
||||
* exposed through the {@code InternalBridge.RegistryFactory} interface.
|
||||
*
|
||||
* @return the new {@code RegistryFactory}
|
||||
*/
|
||||
MetricRegistry.RegistryFactory createRegistryFactory();
|
||||
|
||||
/**
|
||||
* Creates a new {@code RegistryFactory} with the specified configuration,
|
||||
* as exposed through the {@code InternalBridge.RegistryFactory} interface.
|
||||
*
|
||||
* @param config the Helidon {@link Config} to use in initializing the
|
||||
* factory.
|
||||
* @return the new {@code RegistryFactory}
|
||||
*/
|
||||
MetricRegistry.RegistryFactory createRegistryFactory(Config config);
|
||||
|
||||
/**
|
||||
* Abstraction of the {@code MetricRegistry} behavior used by internal
|
||||
* Helidon clients.
|
||||
* <p>
|
||||
* The exposed methods use version-neutral abstractions for
|
||||
* {@code Metadata}, {@code MetricID}, and {@code Tag} which are used by
|
||||
* MicroProfile Metrics. Some methods have {@code bridge} in their names because
|
||||
* the corresponding MicroProfile Metrics methods changed return type but
|
||||
* kept the same signature from 1.1 to 2.0, so here they need distinct names
|
||||
* to distinguish them from the spec-prescribed methods (that do not use the
|
||||
* version-neutral constructs).
|
||||
*/
|
||||
public interface MetricRegistry {
|
||||
|
||||
/**
|
||||
* Finds or creates a new {@code Counter} using the specified
|
||||
* version-neutral {@code Metadata}.
|
||||
*
|
||||
* @param metadata used in locating and, if needed, building the counter
|
||||
* @return the {@code Counter}
|
||||
*/
|
||||
Counter counter(Metadata metadata);
|
||||
|
||||
/**
|
||||
* Finds or creates a new {@code} Counter using the specified
|
||||
* version-neutral {@code Metadata} and version-neutral {@code Tag}s.
|
||||
*
|
||||
* @param metadata used in locating and, if needed, building the counter
|
||||
* @param tags used in locating and, if needed, building the counter
|
||||
* @return the {@code Counter}
|
||||
*/
|
||||
Counter counter(Metadata metadata, Map<String, String> tags);
|
||||
|
||||
/**
|
||||
* Finds or creates a new {@code Counter} using the specified name.
|
||||
*
|
||||
* @param name name for the new {@code Counter}
|
||||
* @return the {@code Counter}
|
||||
*/
|
||||
Counter counter(String name);
|
||||
|
||||
/**
|
||||
* Finds or creates a new {@code Meter} using the specified
|
||||
* version-neutral {@code Metadata}.
|
||||
*
|
||||
* @param metadata used in locating and, if needed, building the meter
|
||||
* @return the {@code Meter}
|
||||
*/
|
||||
Meter meter(Metadata metadata);
|
||||
|
||||
/**
|
||||
* Finds or creates a new {@code Meter} using the specified
|
||||
* version-neutral {@code Metadata} and version-neutral {@code Tag}s.
|
||||
*
|
||||
* @param metadata used in locating and, if needed, building the meter
|
||||
* @param tags used in locating and, if needed, building the meter
|
||||
* @return the {@code Meter}
|
||||
*/
|
||||
Meter meter(Metadata metadata, Map<String, String> tags);
|
||||
|
||||
/**
|
||||
* Finds or creates a new {@code Meter} using the specified name.
|
||||
*
|
||||
* @param name used in locating and, if needed, building the meter
|
||||
* @return the {@code Meter}
|
||||
*/
|
||||
Meter meter(String name);
|
||||
|
||||
/**
|
||||
* Finds or creates a new {@code Histogram} using the specified
|
||||
* version-neutral {@code Metadata}.
|
||||
*
|
||||
* @param metadata used in locating and, if needed, building the
|
||||
* histogram
|
||||
* @return the {@code Histogram}
|
||||
*/
|
||||
Histogram histogram(Metadata metadata);
|
||||
|
||||
/**
|
||||
* Finds or creates a new {@code Histogram} using the specified
|
||||
* version-neutral {@code Metadata} and version-neutral {@code Tag}s.
|
||||
*
|
||||
* @param metadata used in locating and, if needed, building the
|
||||
* histogram
|
||||
* @param tags used in locating and, if needed, building the histogram
|
||||
* @return the {@code Histogram}
|
||||
*/
|
||||
Histogram histogram(Metadata metadata, Map<String, String> tags);
|
||||
|
||||
/**
|
||||
* Finds or creates a new {@code Histogram} using the specified
|
||||
* {@code Metadata}.
|
||||
*
|
||||
* @param name used in locating and, if needed, building the histogram
|
||||
* @return the {@code Histogram}
|
||||
*/
|
||||
Histogram histogram(String name);
|
||||
|
||||
/**
|
||||
* Finds or creates a new {@code Timer} using the specified
|
||||
* version-neutral {@code Metadata}.
|
||||
*
|
||||
* @param metadata used in locating and, if needed, building the timer
|
||||
* @return the {@code Timer}
|
||||
*/
|
||||
Timer timer(Metadata metadata);
|
||||
|
||||
/**
|
||||
* Finds or creates a new {@code Timer} using the specified
|
||||
* version-neutral {@code Metadata} and version-neutral {@code Tag}s.
|
||||
*
|
||||
* @param metadata used in locating and, if needed, building the timer
|
||||
* @param tags used in locationg and, if needed, building the timer
|
||||
* @return the {@code Timer}
|
||||
*/
|
||||
Timer timer(Metadata metadata, Map<String, String> tags);
|
||||
|
||||
/**
|
||||
* Finds or creates a new {@code Timer} using the specified name.
|
||||
*
|
||||
* @param name used in locating and, if needed, building the timer
|
||||
* @return the {@code Timer}
|
||||
*/
|
||||
Timer timer(String name);
|
||||
|
||||
/**
|
||||
* Returns all metrics from the registry as a map of version-neutral
|
||||
* {@link MetricID}s to {@code Metric}s.
|
||||
*
|
||||
* @return the metrics
|
||||
*/
|
||||
Map<MetricID, Metric> getBridgeMetrics();
|
||||
|
||||
/**
|
||||
* Returns all metrics from the registry as a map of version-neutral
|
||||
* {@link MetricID}s to {@code Metric}s, filtered by the provided
|
||||
* {@link Predicate}.
|
||||
*
|
||||
* @param predicate for selecting which metrics to include in the result
|
||||
* @return the metrics matching the criteria expressed in the predicate
|
||||
*/
|
||||
Map<MetricID, Metric> getBridgeMetrics(
|
||||
Predicate<? super Map.Entry<? extends MetricID, ? extends Metric>> predicate);
|
||||
|
||||
/**
|
||||
* Returns an {@link Optional} of the {@code MetricID} and
|
||||
* {@link Metric} of the metric matching the given name. If multiple
|
||||
* metrics match on the name (this can happen in MP Metrics 2.0 if the
|
||||
* metrics were created with different tags) then the method returns the
|
||||
* first metric with that name, if any.
|
||||
*
|
||||
* @param metricName name of the metric to find
|
||||
* @return {@code Optional} of a {@code Map.Entry} for the matching ID
|
||||
* and metric
|
||||
*/
|
||||
Optional<Map.Entry<? extends MetricID, ? extends Metric>> getBridgeMetric(String metricName);
|
||||
|
||||
/**
|
||||
* Returns the names of all metrics in the registry.
|
||||
*
|
||||
* @return a {@code Set} containing the names
|
||||
*/
|
||||
SortedSet<String> getNames();
|
||||
|
||||
/**
|
||||
* Returns all {@code Counter} metrics in the registry as a map of
|
||||
* version-neutral {@link MetricID} to {@link Metric} entries.
|
||||
*
|
||||
* @return a map of all counters
|
||||
*/
|
||||
SortedMap<MetricID, Counter> getBridgeCounters();
|
||||
|
||||
/**
|
||||
* Returns all {@code Gauge} metrics in the registry as a map of
|
||||
* version-neutral {@link MetricID} to {@link Metric} entries.
|
||||
*
|
||||
* @return a map of all gauges
|
||||
*/
|
||||
SortedMap<MetricID, Gauge> getBridgeGauges();
|
||||
|
||||
/**
|
||||
* Returns all {@code Histogram} metrics in the registry as a map of
|
||||
* version-neutral {@link MetricID} to {@link Metric} entries.
|
||||
*
|
||||
* @return a map of all histograms
|
||||
*/
|
||||
SortedMap<MetricID, Histogram> getBridgeHistograms();
|
||||
|
||||
/**
|
||||
* Returns all {@code Meter} metrics in the registry as a map of
|
||||
* version-neutral {@link MetricID} to {@link Metric} entries.
|
||||
*
|
||||
* @return a map of all meters
|
||||
*/
|
||||
SortedMap<MetricID, Meter> getBridgeMeters();
|
||||
|
||||
/**
|
||||
* Returns all {@code Timer} metrics in the registry as a map of
|
||||
* version-neutral {@link MetricID} to {@link Metric} entries.
|
||||
*
|
||||
* @return a map of all timers
|
||||
*/
|
||||
SortedMap<MetricID, Timer> getBridgeTimers();
|
||||
|
||||
/**
|
||||
* Registers a new metric using the specified version-neutral
|
||||
* {@link Metadata} and the typed metric itself.
|
||||
*
|
||||
* @param <T> the metric type
|
||||
* @param metadata the metadata used in registering the metric
|
||||
* @param metric the metric to register
|
||||
* @return the registered metric
|
||||
* @throws IllegalArgumentException if a metric with the same name but
|
||||
* inconsistent metadata is already registered
|
||||
*/
|
||||
<T extends Metric> T register(Metadata metadata, T metric) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Registers a new metric using the specified version-neutral
|
||||
* {@link MetricID} and the typed metric itself.
|
||||
*
|
||||
* @param <T> the metric type
|
||||
* @param metricID the metric ID to be used in registering the metric
|
||||
* @param metric the metric to register
|
||||
* @return the registered metric
|
||||
* @throws IllegalArgumentException if a metric with the same identify
|
||||
* but inconsistent metadata is already registered
|
||||
*/
|
||||
<T extends Metric> T register(MetricID metricID, T metric) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Removes the metrics with matching name from the registry.
|
||||
*
|
||||
* @param name name of the metric
|
||||
* @return true if a matching metric was removed; false otherwise
|
||||
*/
|
||||
boolean remove(String name);
|
||||
|
||||
/**
|
||||
* Abstraction of the {@code RegistryFactory} behavior used by internal
|
||||
* Helidon clients.
|
||||
* <p>
|
||||
* Using the name {@code RegistryFactory} here instead of just {@code Factory}
|
||||
* should simplify changing the client code to use only the MP Metrics 2.0
|
||||
* implementation later.
|
||||
*/
|
||||
public interface RegistryFactory {
|
||||
|
||||
/**
|
||||
* The factory's singleton instance.
|
||||
*/
|
||||
RegistryFactory INSTANCE = Loader.registryFactory();
|
||||
|
||||
/**
|
||||
* Returns the MicroProfile metric {@code MetricRegistry} of the
|
||||
* indicated registry type typed as the internal abstraction.
|
||||
*
|
||||
* @param type registry type selected
|
||||
* @return {@code MetricRegistry} of the selected type
|
||||
*/
|
||||
MetricRegistry getBridgeRegistry(org.eclipse.microprofile.metrics.MetricRegistry.Type type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Version-neutral abstraction of a metric identifier.
|
||||
* <p>
|
||||
* Note that for a metric with tags, the tags are ALWAYS present in the
|
||||
* neutral {@code MetricID}. We want to encourage the internal clients to
|
||||
* use the newer programming style, retrieving tags from the ID rather than
|
||||
* the metadata (where it was stored in MP Metrics 1.1).
|
||||
*/
|
||||
public interface MetricID extends Comparable<MetricID> {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the name from the identifier
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the tags from the identifier, as a {@code Map}
|
||||
*/
|
||||
Map<String, String> getTags();
|
||||
|
||||
/**
|
||||
* Provides the tags as a {@code List}. The returned {@code Tag} objects
|
||||
* are separate from those associated with the ID so changes to the tags
|
||||
* made by the caller do not perturb the original ID.
|
||||
*
|
||||
* @return the {@code Tag}s
|
||||
*/
|
||||
default List<Tag> getTagsAsList() {
|
||||
return getTags().entrySet().stream()
|
||||
.map(entry -> Tag.newTag(entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the tags as a single string: name1=value1,name2=value2,...
|
||||
*
|
||||
* @return {@code String} containing the tags
|
||||
*/
|
||||
default String getTagsAsString() {
|
||||
return getTags().entrySet().stream()
|
||||
.map((entry) -> String.format("%s=%s", entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares this instance to another object (per {@code Comparable}.
|
||||
*
|
||||
* @param o the other object to compare to
|
||||
* @return -1, 0, +1 depending on whether this instance is less than,
|
||||
* equal to, or greater than the other object.
|
||||
*/
|
||||
@Override
|
||||
default int compareTo(MetricID o) {
|
||||
int result = getName().compareTo(Objects.requireNonNull(o).getName());
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
result = getTags().size() - o.getTags().size();
|
||||
if (result == 0) {
|
||||
Iterator<Map.Entry<String, String>> thisIterator = getTags().entrySet().iterator();
|
||||
Iterator<Map.Entry<String, String>> otherIterator = o.getTags().entrySet().iterator();
|
||||
while (thisIterator.hasNext() && otherIterator.hasNext()) {
|
||||
Map.Entry<String, String> thisEntry = thisIterator.next();
|
||||
Map.Entry<String, String> otherEntry = otherIterator.next();
|
||||
result = thisEntry.getKey().compareTo(otherEntry.getKey());
|
||||
if (result != 0) {
|
||||
return result;
|
||||
} else {
|
||||
result = thisEntry.getValue().compareTo(otherEntry.getValue());
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new {@code MetricID} instances.
|
||||
*/
|
||||
public interface Factory {
|
||||
|
||||
/**
|
||||
* Singleton instance of the factory.
|
||||
*/
|
||||
Factory INSTANCE = Loader.metricIDFactory();
|
||||
|
||||
/**
|
||||
* Creates a version-neutral {@code MetricID} initialized with the
|
||||
* specified name and any global tags.
|
||||
*
|
||||
* @param name name of the metric to create
|
||||
* @return the new {@code MetricID}
|
||||
*/
|
||||
InternalBridge.MetricID newMetricID(String name);
|
||||
|
||||
/**
|
||||
* Creates a version-neutral {@code MetricID} initializes with the
|
||||
* specified name and tags.
|
||||
*
|
||||
* @param name name of the metric to create
|
||||
* @param tags tags to associated with the new ID
|
||||
* @return the new {@code MetricID}
|
||||
*/
|
||||
InternalBridge.MetricID newMetricID(String name, Map<String, String> tags);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Version-neutral abstraction of metric metadata.
|
||||
* <p>
|
||||
* Although this interface supports tags, if you are using MicroProfile
|
||||
* Metrics 2.0 or later the system ignores tags associated with metadata.
|
||||
*/
|
||||
public interface Metadata {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the metric name stored in the metadata
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the display name
|
||||
*/
|
||||
String getDisplayName();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return an {@code Optional} of the metadata description
|
||||
*/
|
||||
Optional<String> getDescription();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the metric type as a {@code String}
|
||||
*/
|
||||
String getType();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the metric type as a MicroProfile Metrics {link MetricType}
|
||||
*/
|
||||
MetricType getTypeRaw();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return an {@code Optional} of the unit associated with this metadata
|
||||
*/
|
||||
Optional<String> getUnit();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return whether metrics described by this metadata are reusable or
|
||||
* not
|
||||
*/
|
||||
boolean isReusable();
|
||||
|
||||
/**
|
||||
* Returns the tags associated with the metadata.
|
||||
* <p>
|
||||
* Note that if you are using MicroProfile Metrics 2.0 and later the
|
||||
* tags associated with this version-neutral metadata are ignored.
|
||||
*
|
||||
* @return tags
|
||||
*/
|
||||
Map<String, String> getTags();
|
||||
|
||||
/**
|
||||
* Prepares a version-neutral {@link Metadata} instance using the
|
||||
* specified values, avoiding the need to create and act on a builder.
|
||||
* <p>
|
||||
* Note that although this method accepts tags, if you are using
|
||||
* MicroProfile Metrics 2.0 or later the returned metadata will not
|
||||
* include the tags.
|
||||
*
|
||||
* @param name name for the metrics associated with the metadata
|
||||
* @param displayName display name
|
||||
* @param description description of the metric
|
||||
* @param type {@code MetricType} of the metric
|
||||
* @param unit unit that applies to the metric
|
||||
* @param isReusable whether or not metrics based on this metadata
|
||||
* should be reusable
|
||||
* @param tags name/value pairs representing tags
|
||||
* @return the prepared version-neutral {@code Metadata}
|
||||
*/
|
||||
static InternalBridge.Metadata newMetadata(String name, String displayName, String description,
|
||||
MetricType type, String unit, boolean isReusable, Map<String, String> tags) {
|
||||
final MetadataBuilder builder = MetadataBuilder.Factory.INSTANCE.newMetadataBuilder()
|
||||
.withName(name)
|
||||
.withDescription(description)
|
||||
.withDisplayName(displayName)
|
||||
.withType(type)
|
||||
.withTags(tags)
|
||||
.withUnit(unit);
|
||||
return (isReusable ? builder.reusable() : builder.notReusable()).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a version-neutral {@link Metadata} instance using the
|
||||
* specified values, avoiding the need to create and act on a builder.
|
||||
* <p>
|
||||
* Note that although this method accepts tags, if you are using
|
||||
* MicroProfile Metrics 2.0 or later the returned metadata will not
|
||||
* include the tags.
|
||||
* <p>
|
||||
* Also note that whether the metadata is reusable relies on the
|
||||
* underlying MicroProfile Metrics version you are using.
|
||||
*
|
||||
* @param name name for the metrics associated with the metadata
|
||||
* @param displayName display name
|
||||
* @param description description of the metric
|
||||
* @param type {@code MetricType} of the metric
|
||||
* @param unit unit that applies to the metric
|
||||
* @param tags name/value pairs representing tags
|
||||
* @return the prepared version-neutral {@code Metadata}
|
||||
*/
|
||||
static InternalBridge.Metadata newMetadata(String name, String displayName, String description,
|
||||
MetricType type, String unit, Map<String, String> tags) {
|
||||
return MetadataBuilder.Factory.INSTANCE.newMetadataBuilder()
|
||||
.withName(name)
|
||||
.withDescription(description)
|
||||
.withDisplayName(displayName)
|
||||
.withType(type)
|
||||
.withTags(tags)
|
||||
.withUnit(unit)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a version-neutral {@link Metadata} instance using the
|
||||
* specified values, avoiding the need to create and act on a builder.
|
||||
* <p>
|
||||
* Note that whether the metadata is reusable relies on the underlying
|
||||
* MicroProfile Metrics version you are using.
|
||||
*
|
||||
* @param name name for the metrics associated with the metadata
|
||||
* @param displayName display name
|
||||
* @param description description of the metric
|
||||
* @param type {@code MetricType} of the metric
|
||||
* @param unit unit that applies to the metric
|
||||
* @return the prepared version-neutral {@code Metadata}
|
||||
*/
|
||||
static InternalBridge.Metadata newMetadata(String name, String displayName, String description,
|
||||
MetricType type, String unit) {
|
||||
return MetadataBuilder.Factory.INSTANCE.newMetadataBuilder()
|
||||
.withName(name)
|
||||
.withDescription(description)
|
||||
.withDisplayName(displayName)
|
||||
.withType(type)
|
||||
.withUnit(unit)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fluent-style builder for version-neutral {@link Metadata}.
|
||||
* <p>
|
||||
* The name is from MP Metrics but is actually the factory for {@code Metadata}
|
||||
* in the design of the bridge.
|
||||
*
|
||||
*/
|
||||
public interface MetadataBuilder {
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name name to be used in the metadata; cannot be null
|
||||
* @return the same builder
|
||||
*/
|
||||
MetadataBuilder withName(String name);
|
||||
|
||||
/**
|
||||
* Sets the display name.
|
||||
*
|
||||
* @param displayName display name to be used in the metadata;
|
||||
* cannot be null
|
||||
* @return the same builder
|
||||
*/
|
||||
MetadataBuilder withDisplayName(String displayName);
|
||||
|
||||
/**
|
||||
* Sets the description.
|
||||
*
|
||||
* @param description description to be used in the metadata; cannot
|
||||
* be null
|
||||
* @return the same builder
|
||||
*/
|
||||
MetadataBuilder withDescription(String description);
|
||||
|
||||
/**
|
||||
* Sets the metric type.
|
||||
*
|
||||
* @param type {@link MetricType} to be used in the metadata; cannot
|
||||
* be null
|
||||
* @return the same builder
|
||||
*/
|
||||
MetadataBuilder withType(MetricType type);
|
||||
|
||||
/**
|
||||
* Sets the unit.
|
||||
*
|
||||
* @param unit unit to be used in the metadata; cannot be null
|
||||
* @return the same builder
|
||||
*/
|
||||
MetadataBuilder withUnit(String unit);
|
||||
|
||||
/**
|
||||
* Sets that the resulting metadata will be reusable.
|
||||
*
|
||||
* @return the same builder
|
||||
*/
|
||||
MetadataBuilder reusable();
|
||||
|
||||
/**
|
||||
* Sets that the resulting metadata will not be reusable.
|
||||
*
|
||||
* @return the same builder
|
||||
*/
|
||||
MetadataBuilder notReusable();
|
||||
|
||||
/**
|
||||
* Sets the tags.
|
||||
* <p>
|
||||
* Note that when you use MicroProfile Metrics 2.0 or later, tags
|
||||
* associated with metadata are ignored except within the metadata
|
||||
* itself.
|
||||
*
|
||||
* @param tags map conveying the tags to be used in the metadata;
|
||||
* @return the same builder
|
||||
*/
|
||||
MetadataBuilder withTags(Map<String, String> tags);
|
||||
|
||||
/**
|
||||
* Creates a {@link Metadata} instance using the values set by
|
||||
* invocations of the various {@code withXXX} methods.
|
||||
*
|
||||
* @return the version-neutral {@code Metadata}
|
||||
* @throws IllegalStateException if the name was never set
|
||||
*/
|
||||
InternalBridge.Metadata build();
|
||||
|
||||
/**
|
||||
* Factory for {@code MetadataBuilder} instances.
|
||||
*/
|
||||
public interface Factory {
|
||||
|
||||
/**
|
||||
* The factory's singleton instance.
|
||||
*/
|
||||
Factory INSTANCE = Loader.metadataBuilderFactory();
|
||||
|
||||
/**
|
||||
* Returns a new version-specific {@code MetadataBuilder} that
|
||||
* implements the neutral interface.
|
||||
*
|
||||
* @return the builder
|
||||
*/
|
||||
MetadataBuilder newMetadataBuilder();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Version-neutral representation of a tag.
|
||||
*/
|
||||
public interface Tag {
|
||||
|
||||
/**
|
||||
* Creates a new version-neutral tag with the specified name and value.
|
||||
*
|
||||
* @param name name for the new tag
|
||||
* @param value value for the new tag
|
||||
* @return the new version-neutral tag
|
||||
*/
|
||||
static Tag newTag(String name, String value) {
|
||||
return new InternalTagImpl(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the tag's name
|
||||
*/
|
||||
String getTagName();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the tag's value
|
||||
*/
|
||||
String getTagValue();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
package io.helidon.common.metrics;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Version-neutral implementation of {@code Tag} expressing a name/value pair.
|
||||
* <p>
|
||||
* To create a new instance of this class, use the
|
||||
* {@link InternalBridge.Tag#newTag(java.lang.String, java.lang.String)} method.
|
||||
*/
|
||||
class InternalTagImpl implements InternalBridge.Tag {
|
||||
|
||||
private final String name;
|
||||
private final String value;
|
||||
|
||||
/**
|
||||
* Creates a new tag.
|
||||
*
|
||||
* @param name used for the tag
|
||||
* @param value used for the tag
|
||||
*/
|
||||
InternalTagImpl(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the name of the tag
|
||||
*/
|
||||
@Override
|
||||
public String getTagName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the value of the tag
|
||||
*/
|
||||
@Override
|
||||
public String getTagValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 59 * hash + Objects.hashCode(this.name);
|
||||
hash = 59 * hash + Objects.hashCode(this.value);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final InternalTagImpl other = (InternalTagImpl) obj;
|
||||
if (!Objects.equals(this.name, other.name)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.value, other.value)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Tag{%s=%s}", name, value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
package io.helidon.common.metrics;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* Uses the Java service loader mechanism to find an implementation of the
|
||||
* internal bridge and offer access to the various factories that implementation
|
||||
* provides.
|
||||
*/
|
||||
class Loader {
|
||||
private static final io.helidon.common.metrics.InternalBridge BRIDGE = loadInternalBridge();
|
||||
|
||||
static io.helidon.common.metrics.InternalBridge internalBridge() {
|
||||
return BRIDGE;
|
||||
}
|
||||
|
||||
static io.helidon.common.metrics.InternalBridge.MetricRegistry.RegistryFactory registryFactory() {
|
||||
return BRIDGE.getRegistryFactory();
|
||||
}
|
||||
|
||||
static io.helidon.common.metrics.InternalBridge.MetricID.Factory metricIDFactory() {
|
||||
return BRIDGE.getMetricIDFactory();
|
||||
}
|
||||
|
||||
static io.helidon.common.metrics.InternalBridge.Metadata.MetadataBuilder.Factory metadataBuilderFactory() {
|
||||
return BRIDGE.getMetadataBuilderFactory();
|
||||
}
|
||||
|
||||
private static io.helidon.common.metrics.InternalBridge loadInternalBridge() {
|
||||
for (Iterator<io.helidon.common.metrics.InternalBridge> it =
|
||||
ServiceLoader.load(io.helidon.common.metrics.InternalBridge.class).iterator();
|
||||
it.hasNext();) {
|
||||
return it.next();
|
||||
}
|
||||
throw new RuntimeException("Could not find implementation of bridge "
|
||||
+ io.helidon.common.metrics.InternalBridge.class.getName() + " to load");
|
||||
}
|
||||
|
||||
private Loader() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* A collection of version-neutral interfaces (and some implementations where they
|
||||
* apply to all versions) of constructs used in MicroProfile Metrics.
|
||||
* <p>
|
||||
* Note: Only Helidon internal clients of metrics should use the classes and
|
||||
* interfaces in this package. The abstracting interfaces expose only the bare
|
||||
* minimum surface area of their version-specific counterparts that are used by
|
||||
* the various internal Helidon clients of metrics.
|
||||
*/
|
||||
package io.helidon.common.metrics;
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
module io.helidon.common.metrics {
|
||||
|
||||
requires io.helidon.config;
|
||||
requires transitive microprofile.metrics.api;
|
||||
|
||||
exports io.helidon.common.metrics;
|
||||
|
||||
uses io.helidon.common.metrics.InternalBridge;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -39,7 +39,6 @@
|
||||
<module>service-loader</module>
|
||||
<module>context</module>
|
||||
<module>mapper</module>
|
||||
<module>metrics</module>
|
||||
<module>media-type</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
||||
@@ -40,10 +40,6 @@
|
||||
<artifactId>helidon-grpc-client</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.helidon.common</groupId>
|
||||
<artifactId>helidon-common-metrics</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.helidon.metrics</groupId>
|
||||
<artifactId>helidon-metrics</artifactId>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package io.helidon.grpc.metrics;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -25,12 +24,11 @@ import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Priority;
|
||||
|
||||
import io.helidon.common.HelidonFeatures;
|
||||
import io.helidon.common.metrics.InternalBridge;
|
||||
import io.helidon.common.metrics.InternalBridge.Metadata.MetadataBuilder;
|
||||
import io.helidon.grpc.core.GrpcHelper;
|
||||
import io.helidon.grpc.core.InterceptorPriorities;
|
||||
import io.helidon.grpc.server.MethodDescriptor;
|
||||
import io.helidon.grpc.server.ServiceDescriptor;
|
||||
import io.helidon.metrics.RegistryFactory;
|
||||
|
||||
import io.grpc.Context;
|
||||
import io.grpc.ForwardingServerCall;
|
||||
@@ -41,9 +39,11 @@ import io.grpc.ServerInterceptor;
|
||||
import io.grpc.Status;
|
||||
import org.eclipse.microprofile.metrics.Counter;
|
||||
import org.eclipse.microprofile.metrics.Histogram;
|
||||
import org.eclipse.microprofile.metrics.MetadataBuilder;
|
||||
import org.eclipse.microprofile.metrics.Meter;
|
||||
import org.eclipse.microprofile.metrics.MetricRegistry;
|
||||
import org.eclipse.microprofile.metrics.MetricType;
|
||||
import org.eclipse.microprofile.metrics.Tag;
|
||||
import org.eclipse.microprofile.metrics.Timer;
|
||||
|
||||
/**
|
||||
@@ -61,14 +61,14 @@ public class GrpcMetrics
|
||||
/**
|
||||
* The registry of vendor metrics.
|
||||
*/
|
||||
private static final io.helidon.common.metrics.InternalBridge.MetricRegistry VENDOR_REGISTRY =
|
||||
InternalBridge.INSTANCE.getRegistryFactory().getBridgeRegistry(MetricRegistry.Type.VENDOR);
|
||||
private static final MetricRegistry VENDOR_REGISTRY =
|
||||
RegistryFactory.getInstance().getRegistry(MetricRegistry.Type.VENDOR);
|
||||
|
||||
/**
|
||||
* The registry of application metrics.
|
||||
*/
|
||||
private static final io.helidon.common.metrics.InternalBridge.MetricRegistry APP_REGISTRY =
|
||||
InternalBridge.INSTANCE.getRegistryFactory().getBridgeRegistry(MetricRegistry.Type.APPLICATION);
|
||||
private static final MetricRegistry APP_REGISTRY =
|
||||
RegistryFactory.getInstance().getRegistry(MetricRegistry.Type.APPLICATION);
|
||||
|
||||
/**
|
||||
* The context key name to use to obtain rules to use when applying metrics.
|
||||
@@ -443,6 +443,9 @@ public class GrpcMetrics
|
||||
*/
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||
static class MetricsRules {
|
||||
|
||||
private static final Tag[] EMPTY_TAGS = new Tag[0];
|
||||
|
||||
/**
|
||||
* The metric type.
|
||||
*/
|
||||
@@ -518,9 +521,12 @@ public class GrpcMetrics
|
||||
* @param method the method name
|
||||
* @return the metrics metadata
|
||||
*/
|
||||
io.helidon.common.metrics.InternalBridge.Metadata metadata(ServiceDescriptor service, String method) {
|
||||
org.eclipse.microprofile.metrics.Metadata metadata(ServiceDescriptor service, String method) {
|
||||
String name = nameFunction.orElse(this::defaultName).createName(service, method, type);
|
||||
MetadataBuilder builder = InternalBridge.newMetadataBuilder().withName(name).withType(type);
|
||||
MetadataBuilder builder = org.eclipse.microprofile.metrics.Metadata.builder()
|
||||
.withName(name)
|
||||
.withType(type)
|
||||
.reusable(this.reusable);
|
||||
|
||||
this.description.ifPresent(builder::withDescription);
|
||||
this.units.ifPresent(builder::withUnit);
|
||||
@@ -528,8 +534,6 @@ public class GrpcMetrics
|
||||
String displayName = this.displayName;
|
||||
builder.withDisplayName(displayName == null ? name : displayName);
|
||||
|
||||
builder = this.reusable ? builder.reusable() : builder.notReusable();
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@@ -573,8 +577,12 @@ public class GrpcMetrics
|
||||
return rules;
|
||||
}
|
||||
|
||||
private Map<String, String> toTags() {
|
||||
return tags.isPresent() ? tags.get() : Collections.emptyMap();
|
||||
private Tag[] toTags() {
|
||||
return tags.isPresent()
|
||||
? tags.get().entrySet().stream()
|
||||
.map(entry -> new Tag(entry.getKey(), entry.getValue()))
|
||||
.toArray(Tag[]::new)
|
||||
: EMPTY_TAGS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,5 +26,4 @@ module io.helidon.grpc.metrics {
|
||||
requires transitive io.helidon.metrics;
|
||||
|
||||
requires microprofile.metrics.api;
|
||||
requires io.helidon.common.metrics;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019-2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,11 +18,11 @@ package io.helidon.grpc.metrics;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.helidon.common.metrics.InternalBridge.MetricID;
|
||||
import io.helidon.grpc.server.GrpcService;
|
||||
import io.helidon.grpc.server.MethodDescriptor;
|
||||
import io.helidon.grpc.server.ServiceDescriptor;
|
||||
import io.helidon.metrics.MetricsSupport;
|
||||
import io.helidon.metrics.RegistryFactory;
|
||||
import io.helidon.webserver.Routing;
|
||||
|
||||
import io.grpc.Context;
|
||||
@@ -32,10 +32,13 @@ import io.grpc.ServerCallHandler;
|
||||
import io.grpc.Status;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import java.util.HashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.microprofile.metrics.Counter;
|
||||
import org.eclipse.microprofile.metrics.Histogram;
|
||||
import org.eclipse.microprofile.metrics.Meter;
|
||||
import org.eclipse.microprofile.metrics.Metric;
|
||||
import org.eclipse.microprofile.metrics.MetricID;
|
||||
import org.eclipse.microprofile.metrics.MetricRegistry;
|
||||
import org.eclipse.microprofile.metrics.MetricUnits;
|
||||
import org.eclipse.microprofile.metrics.Timer;
|
||||
@@ -66,9 +69,9 @@ import static org.mockito.Mockito.when;
|
||||
@SuppressWarnings("unchecked")
|
||||
public class GrpcMetricsInterceptorIT {
|
||||
|
||||
private static io.helidon.common.metrics.InternalBridge.MetricRegistry vendorRegsistry;
|
||||
private static MetricRegistry vendorRegistry;
|
||||
|
||||
private static io.helidon.common.metrics.InternalBridge.MetricRegistry appRegistry;
|
||||
private static MetricRegistry appRegistry;
|
||||
|
||||
private static Meter vendorMeter;
|
||||
|
||||
@@ -83,10 +86,10 @@ public class GrpcMetricsInterceptorIT {
|
||||
Routing.Rules rules = Routing.builder().get("metrics");
|
||||
MetricsSupport.create().update(rules);
|
||||
|
||||
vendorRegsistry = io.helidon.common.metrics.InternalBridge.INSTANCE.getRegistryFactory().getBridgeRegistry(MetricRegistry.Type.VENDOR);
|
||||
appRegistry = io.helidon.common.metrics.InternalBridge.INSTANCE.getRegistryFactory().getBridgeRegistry(MetricRegistry.Type.APPLICATION);
|
||||
vendorMeter = vendorRegsistry.meter("grpc.requests.meter");
|
||||
vendorCounter = vendorRegsistry.counter("grpc.requests.count");
|
||||
vendorRegistry = RegistryFactory.getInstance().getRegistry(MetricRegistry.Type.VENDOR);
|
||||
appRegistry = RegistryFactory.getInstance().getRegistry(MetricRegistry.Type.APPLICATION);
|
||||
vendorMeter = vendorRegistry.meter("grpc.requests.meter");
|
||||
vendorCounter = vendorRegistry.counter("grpc.requests.count");
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@@ -188,8 +191,9 @@ public class GrpcMetricsInterceptorIT {
|
||||
call.close(Status.OK, new Metadata());
|
||||
|
||||
Map<MetricID, Metric> matchingMetrics =
|
||||
appRegistry.getBridgeMetrics(
|
||||
entry -> entry.getKey().getName().equals("Foo.barTags"));
|
||||
appRegistry.getMetrics().entrySet().stream()
|
||||
.filter(entry -> entry.getKey().getName().equals("Foo.barTags"))
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
|
||||
assertThat(matchingMetrics.size(), not(0));
|
||||
Map.Entry<MetricID, Metric> match = matchingMetrics.entrySet().stream()
|
||||
@@ -319,8 +323,8 @@ public class GrpcMetricsInterceptorIT {
|
||||
}
|
||||
|
||||
private void assertVendorMetrics() {
|
||||
Meter meter = vendorRegsistry.meter("grpc.requests.meter");
|
||||
Counter counter = vendorRegsistry.counter("grpc.requests.count");
|
||||
Meter meter = vendorRegistry.meter("grpc.requests.meter");
|
||||
Counter counter = vendorRegistry.counter("grpc.requests.count");
|
||||
|
||||
assertThat(meter.getCount(), is(vendorMeterCount + 1));
|
||||
assertThat(counter.getCount(), is(vendorCount + 1));
|
||||
|
||||
@@ -42,10 +42,6 @@
|
||||
<groupId>io.helidon.common</groupId>
|
||||
<artifactId>helidon-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.helidon.common</groupId>
|
||||
<artifactId>helidon-common-metrics</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.helidon.config</groupId>
|
||||
<artifactId>helidon-config-mp</artifactId>
|
||||
|
||||
@@ -56,27 +56,31 @@ final class BaseRegistry extends Registry {
|
||||
private static final String CONFIG_METRIC_ENABLED_BASE = "base.";
|
||||
static final String BASE_ENABLED_KEY = CONFIG_METRIC_ENABLED_BASE + "enabled";
|
||||
|
||||
private static final Metadata MEMORY_USED_HEAP =
|
||||
new HelidonMetadata("memory.usedHeap",
|
||||
"Used Heap Memory",
|
||||
"Displays the amount of used heap memory in bytes.",
|
||||
MetricType.GAUGE,
|
||||
MetricUnits.BYTES);
|
||||
private static final Metadata MEMORY_USED_HEAP = Metadata.builder()
|
||||
.withName("memory.usedHeap")
|
||||
.withDisplayName("Used Heap Memory")
|
||||
.withDescription("Displays the amount of used heap memory in bytes.")
|
||||
.withType(MetricType.GAUGE)
|
||||
.withUnit(MetricUnits.BYTES)
|
||||
.build();
|
||||
|
||||
private static final Metadata MEMORY_COMMITTED_HEAP =
|
||||
new HelidonMetadata("memory.committedHeap",
|
||||
"Committed Heap Memory",
|
||||
private static final Metadata MEMORY_COMMITTED_HEAP = Metadata.builder()
|
||||
.withName("memory.committedHeap")
|
||||
.withDisplayName("Committed Heap Memory")
|
||||
.withDescription(
|
||||
"Displays the amount of memory in bytes that is "
|
||||
+ "committed for the Java virtual "
|
||||
+ "machine to use. This amount of memory is "
|
||||
+ "guaranteed for the Java virtual "
|
||||
+ "machine to use.",
|
||||
MetricType.GAUGE,
|
||||
MetricUnits.BYTES);
|
||||
+ "machine to use.")
|
||||
.withType(MetricType.GAUGE)
|
||||
.withUnit(MetricUnits.BYTES)
|
||||
.build();
|
||||
|
||||
private static final Metadata MEMORY_MAX_HEAP =
|
||||
new HelidonMetadata("memory.maxHeap",
|
||||
"Max Heap Memory",
|
||||
private static final Metadata MEMORY_MAX_HEAP = Metadata.builder()
|
||||
.withName("memory.maxHeap")
|
||||
.withDisplayName("Max Heap Memory")
|
||||
.withDescription(
|
||||
"Displays the maximum amount of heap memory in bytes that can"
|
||||
+ " be used for "
|
||||
+ "memory management. This attribute displays -1 if "
|
||||
@@ -88,84 +92,94 @@ final class BaseRegistry extends Registry {
|
||||
+ "committed memory. The Java virtual machine may fail"
|
||||
+ " to allocate memory "
|
||||
+ "even if the amount of used memory does not exceed "
|
||||
+ "this maximum size.",
|
||||
MetricType.GAUGE,
|
||||
MetricUnits.BYTES);
|
||||
+ "this maximum size.")
|
||||
.withType(MetricType.GAUGE)
|
||||
.withUnit(MetricUnits.BYTES)
|
||||
.build();
|
||||
|
||||
private static final Metadata JVM_UPTIME =
|
||||
new HelidonMetadata("jvm.uptime",
|
||||
"JVM Uptime",
|
||||
private static final Metadata JVM_UPTIME = Metadata.builder()
|
||||
.withName("jvm.uptime")
|
||||
.withDisplayName("JVM Uptime")
|
||||
.withDescription(
|
||||
"Displays the start time of the Java virtual machine in "
|
||||
+ "milliseconds. This "
|
||||
+ "attribute displays the approximate time when the Java "
|
||||
+ "virtual machine "
|
||||
+ "started.",
|
||||
MetricType.GAUGE,
|
||||
MetricUnits.MILLISECONDS);
|
||||
+ "started.")
|
||||
.withType(MetricType.GAUGE)
|
||||
.withUnit(MetricUnits.MILLISECONDS)
|
||||
.build();
|
||||
|
||||
private static final Metadata THREAD_COUNT =
|
||||
new HelidonMetadata("thread.count",
|
||||
"Thread Count",
|
||||
"Displays the current number of live threads including both "
|
||||
+ "daemon and nondaemon threads",
|
||||
MetricType.GAUGE,
|
||||
MetricUnits.NONE);
|
||||
private static final Metadata THREAD_COUNT = Metadata.builder()
|
||||
.withName("thread.count")
|
||||
.withDisplayName("Thread Count")
|
||||
.withDescription("Displays the current number of live threads including both "
|
||||
+ "daemon and nondaemon threads")
|
||||
.withType(MetricType.GAUGE)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
|
||||
private static final Metadata THREAD_DAEMON_COUNT =
|
||||
new HelidonMetadata("thread.daemon.count",
|
||||
"Daemon Thread Count",
|
||||
"Displays the current number of live daemon threads.",
|
||||
MetricType.GAUGE,
|
||||
MetricUnits.NONE);
|
||||
private static final Metadata THREAD_DAEMON_COUNT = Metadata.builder()
|
||||
.withName("thread.daemon.count")
|
||||
.withDisplayName("Daemon Thread Count")
|
||||
.withDescription("Displays the current number of live daemon threads.")
|
||||
.withType(MetricType.GAUGE)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
|
||||
private static final Metadata THREAD_MAX_COUNT =
|
||||
new HelidonMetadata("thread.max.count",
|
||||
"Peak Thread Count",
|
||||
"Displays the peak live thread count since the Java "
|
||||
private static final Metadata THREAD_MAX_COUNT = Metadata.builder()
|
||||
.withName("thread.max.count")
|
||||
.withDisplayName("Peak Thread Count")
|
||||
.withDescription("Displays the peak live thread count since the Java "
|
||||
+ "virtual machine started or "
|
||||
+ "peak was reset. This includes daemon and "
|
||||
+ "non-daemon threads.",
|
||||
MetricType.GAUGE,
|
||||
MetricUnits.NONE);
|
||||
+ "non-daemon threads.")
|
||||
.withType(MetricType.GAUGE)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
|
||||
private static final Metadata CL_LOADED_COUNT =
|
||||
new HelidonMetadata("classloader.loadedClasses.count",
|
||||
"Current Loaded Class Count",
|
||||
"Displays the number of classes that are currently loaded in "
|
||||
+ "the Java virtual machine.",
|
||||
MetricType.GAUGE,
|
||||
MetricUnits.NONE);
|
||||
private static final Metadata CL_LOADED_COUNT = Metadata.builder()
|
||||
.withName("classloader.loadedClasses.count")
|
||||
.withDisplayName("Current Loaded Class Count")
|
||||
.withDescription("Displays the number of classes that are currently loaded in "
|
||||
+ "the Java virtual machine.")
|
||||
.withType(MetricType.GAUGE)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
|
||||
private static final Metadata CL_LOADED_TOTAL =
|
||||
new HelidonMetadata("classloader.loadedClasses.total",
|
||||
"Total Loaded Class Count",
|
||||
"Displays the total number of classes that have been loaded "
|
||||
+ "since the Java virtual machine has started execution.",
|
||||
MetricType.COUNTER,
|
||||
MetricUnits.NONE);
|
||||
private static final Metadata CL_LOADED_TOTAL = Metadata.builder()
|
||||
.withName("classloader.loadedClasses.total")
|
||||
.withDisplayName("Total Loaded Class Count")
|
||||
.withDescription("Displays the total number of classes that have been loaded "
|
||||
+ "since the Java virtual machine has started execution.")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
|
||||
private static final Metadata CL_UNLOADED_COUNT =
|
||||
new HelidonMetadata("classloader.unloadedClasses.total",
|
||||
"Total Unloaded Class Count",
|
||||
"Displays the total number of classes unloaded since the Java "
|
||||
+ "virtual machine has started execution.",
|
||||
MetricType.COUNTER,
|
||||
MetricUnits.NONE);
|
||||
private static final Metadata CL_UNLOADED_COUNT = Metadata.builder()
|
||||
.withName("classloader.unloadedClasses.total")
|
||||
.withDisplayName("Total Unloaded Class Count")
|
||||
.withDescription("Displays the total number of classes unloaded since the Java "
|
||||
+ "virtual machine has started execution.")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
|
||||
private static final Metadata OS_AVAILABLE_CPU =
|
||||
new HelidonMetadata("cpu.availableProcessors",
|
||||
"Available Processors",
|
||||
"Displays the number of processors available to the Java "
|
||||
private static final Metadata OS_AVAILABLE_CPU = Metadata.builder()
|
||||
.withName("cpu.availableProcessors")
|
||||
.withDisplayName("Available Processors")
|
||||
.withDescription("Displays the number of processors available to the Java "
|
||||
+ "virtual machine. This "
|
||||
+ "value may change during a particular invocation of"
|
||||
+ " the virtual machine.",
|
||||
MetricType.GAUGE,
|
||||
MetricUnits.NONE);
|
||||
+ " the virtual machine.")
|
||||
.withType(MetricType.GAUGE)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
|
||||
private static final Metadata OS_LOAD_AVERAGE =
|
||||
new HelidonMetadata("cpu.systemLoadAverage",
|
||||
"System Load Average",
|
||||
"Displays the system load average for the last minute. The "
|
||||
private static final Metadata OS_LOAD_AVERAGE = Metadata.builder()
|
||||
.withName("cpu.systemLoadAverage")
|
||||
.withDisplayName("System Load Average")
|
||||
.withDescription("Displays the system load average for the last minute. The "
|
||||
+ "system load average "
|
||||
+ "is the sum of the number of runnable entities "
|
||||
+ "queued to the available "
|
||||
@@ -182,9 +196,10 @@ final class BaseRegistry extends Registry {
|
||||
+ "and may be queried frequently. The load average may"
|
||||
+ " be unavailable on some "
|
||||
+ "platforms where it is expensive to implement this "
|
||||
+ "method.",
|
||||
MetricType.GAUGE,
|
||||
MetricUnits.NONE);
|
||||
+ "method.")
|
||||
.withType(MetricType.GAUGE)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
|
||||
private final Config config;
|
||||
|
||||
@@ -237,25 +252,31 @@ final class BaseRegistry extends Registry {
|
||||
}
|
||||
|
||||
private static Metadata gcTimeMeta() {
|
||||
return new HelidonMetadata("gc.time",
|
||||
"Garbage Collection Time",
|
||||
return Metadata.builder()
|
||||
.withName("gc.time")
|
||||
.withDisplayName("Garbage Collection Time")
|
||||
.withDescription(
|
||||
"Displays the approximate accumulated collection elapsed time in milliseconds. "
|
||||
+ "This attribute displays -1 if the collection elapsed time is undefined for this "
|
||||
+ "collector. The Java virtual machine implementation may use a high resolution "
|
||||
+ "timer to measure the elapsed time. This attribute may display the same value "
|
||||
+ "even if the collection count has been incremented if the collection elapsed "
|
||||
+ "time is very short.",
|
||||
MetricType.GAUGE,
|
||||
MetricUnits.MILLISECONDS);
|
||||
+ "time is very short.")
|
||||
.withType(MetricType.GAUGE)
|
||||
.withUnit(MetricUnits.MILLISECONDS)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static Metadata gcCountMeta() {
|
||||
return new HelidonMetadata("gc.total",
|
||||
"Garbage Collection Count",
|
||||
return Metadata.builder()
|
||||
.withName("gc.total")
|
||||
.withDisplayName("Garbage Collection Count")
|
||||
.withDescription(
|
||||
"Displays the total number of collections that have occurred. This attribute lists "
|
||||
+ "-1 if the collection count is undefined for this collector.",
|
||||
MetricType.COUNTER,
|
||||
MetricUnits.NONE);
|
||||
+ "-1 if the collection count is undefined for this collector.")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static void register(BaseRegistry registry, Metadata meta, Metric metric, Tag... tags) {
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.helidon.metrics;
|
||||
|
||||
import org.eclipse.microprofile.metrics.DefaultMetadata;
|
||||
import org.eclipse.microprofile.metrics.MetricType;
|
||||
import org.eclipse.microprofile.metrics.MetricUnits;
|
||||
|
||||
/**
|
||||
* Class HelidonMetadata. In MP Metrics 2.0, {@link org.eclipse.microprofile.metrics.Metadata}
|
||||
* is now immutable and a builder was added. This class allows creation of metadata
|
||||
* directly using a constructor to avoid switching to a builder in dozens of locations.
|
||||
* Can be used from other packages unfortunately.
|
||||
*/
|
||||
public class HelidonMetadata extends DefaultMetadata {
|
||||
|
||||
/**
|
||||
* Construct immutable metadata.
|
||||
*
|
||||
* @param name Metric name.
|
||||
* @param type Metric type.
|
||||
*/
|
||||
public HelidonMetadata(String name, MetricType type) {
|
||||
super(name, null, null, type, MetricUnits.NONE, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct immutable metadata.
|
||||
*
|
||||
* @param name Metric name.
|
||||
* @param displayName Metric display name.
|
||||
* @param description Metric description.
|
||||
* @param type Metric type.
|
||||
* @param unit Metric unit.
|
||||
* @param reusable Reusable flag.
|
||||
*/
|
||||
public HelidonMetadata(String name, String displayName, String description, MetricType type,
|
||||
String unit, boolean reusable) {
|
||||
super(name, displayName, description, type, unit, reusable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct immutable metadata.
|
||||
*
|
||||
* @param name Metric name.
|
||||
* @param displayName Metric display name.
|
||||
* @param description Metric description.
|
||||
* @param type Metric type.
|
||||
* @param unit Metric unit.
|
||||
*/
|
||||
public HelidonMetadata(String name, String displayName, String description, MetricType type, String unit) {
|
||||
super(name, displayName, description, type, unit, true);
|
||||
}
|
||||
}
|
||||
@@ -280,8 +280,14 @@ final class HelidonTimer extends MetricImpl implements Timer {
|
||||
private final Clock clock;
|
||||
|
||||
TimerImpl(String repoType, String name, Clock clock) {
|
||||
this.meter = HelidonMeter.create(repoType, new HelidonMetadata(name, MetricType.METERED), clock);
|
||||
this.histogram = HelidonHistogram.create(repoType, new HelidonMetadata(name, MetricType.HISTOGRAM));
|
||||
this.meter = HelidonMeter.create(repoType, Metadata.builder()
|
||||
.withName(name)
|
||||
.withType(MetricType.METERED)
|
||||
.build(), clock);
|
||||
this.histogram = HelidonHistogram.create(repoType, Metadata.builder()
|
||||
.withName(name)
|
||||
.withType(MetricType.HISTOGRAM)
|
||||
.build());
|
||||
this.clock = clock;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
package io.helidon.metrics;
|
||||
|
||||
import io.helidon.common.metrics.InternalBridge;
|
||||
import io.helidon.common.metrics.InternalBridge.Metadata.MetadataBuilder;
|
||||
import io.helidon.config.Config;
|
||||
|
||||
/**
|
||||
* Implements the metrics bridge interface based on MP Metrics 2.0.
|
||||
*/
|
||||
public class InternalBridgeImpl implements InternalBridge {
|
||||
|
||||
@Override
|
||||
public RegistryFactory getRegistryFactory() {
|
||||
return io.helidon.metrics.RegistryFactory.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryFactory createRegistryFactory() {
|
||||
return io.helidon.metrics.RegistryFactory.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryFactory createRegistryFactory(Config config) {
|
||||
return io.helidon.metrics.RegistryFactory.create(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetricID.Factory getMetricIDFactory() {
|
||||
return new InternalMetricIDImpl.FactoryImpl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder.Factory getMetadataBuilderFactory() {
|
||||
return new InternalMetadataBuilderImpl.FactoryImpl();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
package io.helidon.metrics;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.helidon.common.metrics.InternalBridge;
|
||||
import io.helidon.common.metrics.InternalBridge.Metadata;
|
||||
import io.helidon.common.metrics.InternalBridge.Metadata.MetadataBuilder;
|
||||
|
||||
import org.eclipse.microprofile.metrics.MetricType;
|
||||
|
||||
/**
|
||||
* Fluent-style builder for version-neutral {@link Metadata}.
|
||||
*
|
||||
*/
|
||||
class InternalMetadataBuilderImpl implements MetadataBuilder {
|
||||
|
||||
private final org.eclipse.microprofile.metrics.MetadataBuilder delegate;
|
||||
|
||||
InternalMetadataBuilderImpl() {
|
||||
delegate = new org.eclipse.microprofile.metrics.MetadataBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder withName(String name) {
|
||||
delegate.withName(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder withDisplayName(String displayName) {
|
||||
delegate.withDisplayName(displayName);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder withDescription(String description) {
|
||||
delegate.withDescription(description);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder withType(MetricType type) {
|
||||
delegate.withType(type);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder withUnit(String unit) {
|
||||
delegate.withUnit(unit);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder reusable() {
|
||||
delegate.reusable();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder notReusable() {
|
||||
delegate.notReusable();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Metadata.MetadataBuilder withTags(Map<String, String> tags) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InternalBridge.Metadata build() {
|
||||
return new InternalMetadataImpl(delegate.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return delegate.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj != null)
|
||||
&& (this.getClass().isAssignableFrom(obj.getClass()))
|
||||
&& delegate.equals(((InternalMetadataBuilderImpl) obj).delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return delegate.toString();
|
||||
}
|
||||
|
||||
static class FactoryImpl implements Factory {
|
||||
|
||||
@Override
|
||||
public Metadata.MetadataBuilder newMetadataBuilder() {
|
||||
return new InternalMetadataBuilderImpl();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
package io.helidon.metrics;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import io.helidon.common.metrics.InternalBridge.Metadata;
|
||||
|
||||
import org.eclipse.microprofile.metrics.MetricType;
|
||||
|
||||
/**
|
||||
* Metrics 2.0-based implementation of the version-neutral {@code Metadata} interface.
|
||||
*/
|
||||
class InternalMetadataImpl implements Metadata {
|
||||
|
||||
private final org.eclipse.microprofile.metrics.Metadata delegate;
|
||||
|
||||
/**
|
||||
* Creates a new metadata instance, delegating to the specified 2.0 metadata.
|
||||
* @param delegate
|
||||
*/
|
||||
InternalMetadataImpl(org.eclipse.microprofile.metrics.Metadata delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return delegate.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return delegate.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> getDescription() {
|
||||
return delegate.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return delegate.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetricType getTypeRaw() {
|
||||
return delegate.getTypeRaw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> getUnit() {
|
||||
return delegate.getUnit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReusable() {
|
||||
return delegate.isReusable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getTags() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return delegate.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj != null)
|
||||
&& (this.getClass().isAssignableFrom(obj.getClass()))
|
||||
&& delegate.equals(((InternalMetadataImpl) obj).delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return delegate.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
package io.helidon.metrics;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.helidon.common.metrics.InternalBridge;
|
||||
|
||||
import org.eclipse.microprofile.metrics.MetricID;
|
||||
import org.eclipse.microprofile.metrics.Tag;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class InternalMetricIDImpl implements InternalBridge.MetricID {
|
||||
|
||||
private final MetricID delegate;
|
||||
|
||||
InternalMetricIDImpl(String name) {
|
||||
delegate = new org.eclipse.microprofile.metrics.MetricID(name);
|
||||
}
|
||||
|
||||
InternalMetricIDImpl(String name, Map<String, String> tags) {
|
||||
delegate = new org.eclipse.microprofile.metrics.MetricID(name, toTagArray(tags));
|
||||
}
|
||||
|
||||
private Tag[] toTagArray(Map<String, String> tags) {
|
||||
return tags.entrySet().stream()
|
||||
.map(entry -> new Tag(entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.toList())
|
||||
.toArray(new Tag[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return delegate.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getTags() {
|
||||
return delegate.getTags();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 37 * hash + Objects.hashCode(this.delegate);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final InternalMetricIDImpl other = (InternalMetricIDImpl) obj;
|
||||
return Objects.equals(this.delegate, other.delegate);
|
||||
}
|
||||
|
||||
static class FactoryImpl implements Factory {
|
||||
|
||||
@Override
|
||||
public io.helidon.common.metrics.InternalBridge.MetricID newMetricID(String name) {
|
||||
return new InternalMetricIDImpl(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public io.helidon.common.metrics.InternalBridge.MetricID newMetricID(String name, Map<String, String> tags) {
|
||||
return new InternalMetricIDImpl(name, tags);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,7 @@ import io.helidon.webserver.cors.CorsEnabledServiceHelper;
|
||||
import io.helidon.webserver.cors.CrossOriginConfig;
|
||||
|
||||
import org.eclipse.microprofile.metrics.Counter;
|
||||
import org.eclipse.microprofile.metrics.Metadata;
|
||||
import org.eclipse.microprofile.metrics.Meter;
|
||||
import org.eclipse.microprofile.metrics.Metric;
|
||||
import org.eclipse.microprofile.metrics.MetricID;
|
||||
@@ -342,29 +343,37 @@ public final class MetricsSupport implements Service {
|
||||
* tags.
|
||||
*/
|
||||
Registry vendor = rf.getARegistry(MetricRegistry.Type.VENDOR);
|
||||
Counter totalCount = vendor.counter(new HelidonMetadata(metricPrefix + "count",
|
||||
"Total number of HTTP requests",
|
||||
"Each request (regardless of HTTP method) will increase this counter",
|
||||
MetricType.COUNTER,
|
||||
MetricUnits.NONE));
|
||||
Counter totalCount = vendor.counter(Metadata.builder()
|
||||
.withName(metricPrefix + "count")
|
||||
.withDisplayName("Total number of HTTP requests")
|
||||
.withDescription("Each request (regardless of HTTP method) will increase this counter")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build());
|
||||
|
||||
Meter totalMeter = vendor.meter(new HelidonMetadata(metricPrefix + "meter",
|
||||
"Meter for overall HTTP requests",
|
||||
"Each request will mark the meter to see overall throughput",
|
||||
MetricType.METERED,
|
||||
MetricUnits.NONE));
|
||||
Meter totalMeter = vendor.meter(Metadata.builder()
|
||||
.withName(metricPrefix + "meter")
|
||||
.withDisplayName("Meter for overall HTTP requests")
|
||||
.withDescription("Each request will mark the meter to see overall throughput")
|
||||
.withType(MetricType.METERED)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build());
|
||||
|
||||
vendor.counter(new HelidonMetadata("grpc.requests.count",
|
||||
"Total number of gRPC requests",
|
||||
"Each gRPC request (regardless of the method) will increase this counter",
|
||||
MetricType.COUNTER,
|
||||
MetricUnits.NONE));
|
||||
vendor.counter(Metadata.builder()
|
||||
.withName("grpc.requests.count")
|
||||
.withDisplayName("Total number of gRPC requests")
|
||||
.withDescription("Each gRPC request (regardless of the method) will increase this counter")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build());
|
||||
|
||||
vendor.meter(new HelidonMetadata("grpc.requests.meter",
|
||||
"Meter for overall gRPC requests",
|
||||
"Each gRPC request will mark the meter to see overall throughput",
|
||||
MetricType.METERED,
|
||||
MetricUnits.NONE));
|
||||
vendor.meter(Metadata.builder()
|
||||
.withName("grpc.requests.meter")
|
||||
.withDisplayName("Meter for overall gRPC requests")
|
||||
.withDescription("Each gRPC request will mark the meter to see overall throughput")
|
||||
.withType(MetricType.METERED)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build());
|
||||
|
||||
rules.any((req, res) -> {
|
||||
totalCount.inc();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,6 @@ import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -41,7 +40,6 @@ import org.eclipse.microprofile.metrics.Counter;
|
||||
import org.eclipse.microprofile.metrics.Gauge;
|
||||
import org.eclipse.microprofile.metrics.Histogram;
|
||||
import org.eclipse.microprofile.metrics.Metadata;
|
||||
import org.eclipse.microprofile.metrics.MetadataBuilder;
|
||||
import org.eclipse.microprofile.metrics.Meter;
|
||||
import org.eclipse.microprofile.metrics.Metric;
|
||||
import org.eclipse.microprofile.metrics.MetricFilter;
|
||||
@@ -54,7 +52,7 @@ import org.eclipse.microprofile.metrics.Timer;
|
||||
/**
|
||||
* Metrics registry.
|
||||
*/
|
||||
public class Registry extends MetricRegistry implements io.helidon.common.metrics.InternalBridge.MetricRegistry {
|
||||
public class Registry extends MetricRegistry {
|
||||
|
||||
private static final Tag[] NO_TAGS = new Tag[0];
|
||||
private static final Map<Class<? extends HelidonMetric>, MetricType> METRIC_TO_TYPE_MAP = prepareMetricToTypeMap();
|
||||
@@ -108,16 +106,6 @@ public class Registry extends MetricRegistry implements io.helidon.common.metric
|
||||
return counter(metadata, NO_TAGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Counter counter(io.helidon.common.metrics.InternalBridge.Metadata metadata) {
|
||||
return counter(toMetadata(metadata));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Counter counter(io.helidon.common.metrics.InternalBridge.Metadata metadata, Map<String, String> tags) {
|
||||
return counter(toMetadata(metadata), toTags(tags));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Counter counter(String name, Tag... tags) {
|
||||
return getOrRegisterMetric(name, HelidonCounter::create, HelidonCounter.class, tags);
|
||||
@@ -138,16 +126,6 @@ public class Registry extends MetricRegistry implements io.helidon.common.metric
|
||||
return histogram(metadata, NO_TAGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Histogram histogram(io.helidon.common.metrics.InternalBridge.Metadata metadata) {
|
||||
return histogram(toMetadata(metadata));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Histogram histogram(io.helidon.common.metrics.InternalBridge.Metadata metadata, Map<String, String> tags) {
|
||||
return histogram(toMetadata(metadata), toTags(tags));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Histogram histogram(String name, Tag... tags) {
|
||||
return getOrRegisterMetric(name, HelidonHistogram::create, HelidonHistogram.class, tags);
|
||||
@@ -168,16 +146,6 @@ public class Registry extends MetricRegistry implements io.helidon.common.metric
|
||||
return meter(metadata, NO_TAGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Meter meter(io.helidon.common.metrics.InternalBridge.Metadata metadata) {
|
||||
return meter(toMetadata(metadata));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Meter meter(io.helidon.common.metrics.InternalBridge.Metadata metadata, Map<String, String> tags) {
|
||||
return meter(toMetadata(metadata), toTags(tags));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Meter meter(String name, Tag... tags) {
|
||||
return getOrRegisterMetric(name, HelidonMeter::create, HelidonMeter.class, tags);
|
||||
@@ -198,16 +166,6 @@ public class Registry extends MetricRegistry implements io.helidon.common.metric
|
||||
return timer(metadata, NO_TAGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Timer timer(io.helidon.common.metrics.InternalBridge.Metadata metadata) {
|
||||
return timer(toMetadata(metadata));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Timer timer(io.helidon.common.metrics.InternalBridge.Metadata metadata, Map<String, String> tags) {
|
||||
return timer(toMetadata(metadata), toTags(tags));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Timer timer(String name, Tag... tags) {
|
||||
return getOrRegisterMetric(name, HelidonTimer::create, HelidonTimer.class, tags);
|
||||
@@ -364,81 +322,6 @@ public class Registry extends MetricRegistry implements io.helidon.common.metric
|
||||
return Collections.unmodifiableMap(allMetrics);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<io.helidon.common.metrics.InternalBridge.MetricID, Metric> getBridgeMetrics(
|
||||
Predicate<? super Map.Entry<? extends io.helidon.common.metrics.InternalBridge.MetricID,
|
||||
? extends Metric>> predicate) {
|
||||
|
||||
final Map<io.helidon.common.metrics.InternalBridge.MetricID, Metric> result = new HashMap<>();
|
||||
|
||||
allMetrics.entrySet().stream()
|
||||
.map(Registry::toBridgeEntry)
|
||||
.filter(predicate)
|
||||
.forEach(entry -> result.put(entry.getKey(), entry.getValue()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<io.helidon.common.metrics.InternalBridge.MetricID, Metric> getBridgeMetrics() {
|
||||
return getBridgeMetrics(entry -> true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<io.helidon.common.metrics.InternalBridge.MetricID, Gauge> getBridgeGauges() {
|
||||
return getBridgeMetrics(getGauges(), Gauge.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<io.helidon.common.metrics.InternalBridge.MetricID, Counter> getBridgeCounters() {
|
||||
return getBridgeMetrics(getCounters(), Counter.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<io.helidon.common.metrics.InternalBridge.MetricID, Histogram> getBridgeHistograms() {
|
||||
return getBridgeMetrics(getHistograms(), Histogram.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<io.helidon.common.metrics.InternalBridge.MetricID, Meter> getBridgeMeters() {
|
||||
return getBridgeMetrics(getMeters(), Meter.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<io.helidon.common.metrics.InternalBridge.MetricID, Timer> getBridgeTimers() {
|
||||
return getBridgeMetrics(getTimers(), Timer.class);
|
||||
}
|
||||
|
||||
private static <T extends Metric> SortedMap<io.helidon.common.metrics.InternalBridge.MetricID, T> getBridgeMetrics(
|
||||
SortedMap<MetricID, T> metrics, Class<T> clazz) {
|
||||
return metrics.entrySet().stream()
|
||||
.map(Registry::toBridgeEntry)
|
||||
.filter(entry -> clazz.isAssignableFrom(entry.getValue().getClass()))
|
||||
.collect(TreeMap::new,
|
||||
(map, entry) -> map.put(entry.getKey(), clazz.cast(entry.getValue())),
|
||||
Map::putAll);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T extends Metric> T register(
|
||||
io.helidon.common.metrics.InternalBridge.Metadata metadata, T metric) throws IllegalArgumentException {
|
||||
return register(toMetadata(metadata), metric);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Metric> T register(
|
||||
io.helidon.common.metrics.InternalBridge.MetricID metricID, T metric) throws IllegalArgumentException {
|
||||
return register(toMetadata(metricID.getName(), metric), metric, toTags(metricID.getTags()));
|
||||
}
|
||||
|
||||
private static Map.Entry<? extends io.helidon.common.metrics.InternalBridge.MetricID,
|
||||
? extends Metric> toBridgeEntry(
|
||||
Map.Entry<? extends MetricID, ? extends Metric> entry) {
|
||||
return new AbstractMap.SimpleEntry<>(new InternalMetricIDImpl(
|
||||
entry.getKey().getName(), entry.getKey().getTags()),
|
||||
entry.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Access a metric by name. Used by FT library.
|
||||
*
|
||||
@@ -449,13 +332,6 @@ public class Registry extends MetricRegistry implements io.helidon.common.metric
|
||||
return getOptionalMetricEntry(metricName).map(Map.Entry::getValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Map.Entry<? extends io.helidon.common.metrics.InternalBridge.MetricID,
|
||||
? extends Metric>> getBridgeMetric(String metricName) {
|
||||
return getOptionalMetricEntry(metricName)
|
||||
.map(Registry::toBridgeEntry);
|
||||
}
|
||||
|
||||
// -- Public not overridden -----------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -492,18 +368,6 @@ public class Registry extends MetricRegistry implements io.helidon.common.metric
|
||||
|
||||
// -- Package private -----------------------------------------------------
|
||||
|
||||
static Metadata toMetadata(io.helidon.common.metrics.InternalBridge.Metadata metadata) {
|
||||
final MetadataBuilder builder = new MetadataBuilder();
|
||||
builder.withName(metadata.getName())
|
||||
.withDisplayName(metadata.getDisplayName())
|
||||
.withType(metadata.getTypeRaw())
|
||||
.reusable(metadata.isReusable());
|
||||
|
||||
metadata.getDescription().ifPresent(builder::withDescription);
|
||||
metadata.getUnit().ifPresent(builder::withUnit);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<Map.Entry<MetricID, HelidonMetric>> getOptionalMetricEntry(String metricName) {
|
||||
return getOptionalMetricWithIDsEntry(metricName).map(entry -> {
|
||||
final MetricID metricID = entry.getValue().get(0);
|
||||
@@ -649,7 +513,10 @@ public class Registry extends MetricRegistry implements io.helidon.common.metric
|
||||
return getOptionalMetric(metricName, clazz, tags)
|
||||
.orElseGet(() -> {
|
||||
final Metadata metadata = getOrRegisterMetadata(metricName, newType,
|
||||
() -> new HelidonMetadata(metricName, newType), tags);
|
||||
() -> Metadata.builder()
|
||||
.withName(metricName)
|
||||
.withType(newType)
|
||||
.build(), tags);
|
||||
return registerMetric(metricName, metricFactory.apply(type.getName(), metadata),
|
||||
tags);
|
||||
});
|
||||
@@ -675,7 +542,10 @@ public class Registry extends MetricRegistry implements io.helidon.common.metric
|
||||
final MetricType metricType = MetricType.from(metric.getClass());
|
||||
|
||||
final Metadata metadata = getOrRegisterMetadata(metricName, metricType,
|
||||
() -> new HelidonMetadata(metricName, metricType), NO_TAGS);
|
||||
() -> Metadata.builder()
|
||||
.withName(metricName)
|
||||
.withType(metricType)
|
||||
.build(), NO_TAGS);
|
||||
registerMetric(metricName, toImpl(metadata, metric), NO_TAGS);
|
||||
return metric;
|
||||
}
|
||||
@@ -840,8 +710,8 @@ public class Registry extends MetricRegistry implements io.helidon.common.metric
|
||||
.orElse(MetricType.INVALID);
|
||||
}
|
||||
|
||||
private static <T extends Metric> HelidonMetadata toMetadata(String name, T metric) {
|
||||
return new HelidonMetadata(name, toType(metric));
|
||||
private static <T extends Metric> Metadata toMetadata(String name, T metric) {
|
||||
return Metadata.builder().withName(name).withType(toType(metric)).build();
|
||||
}
|
||||
|
||||
private static MetricType toType(Metric metric) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,7 +42,7 @@ import org.eclipse.microprofile.metrics.MetricRegistry.Type;
|
||||
*/
|
||||
// this class is not immutable, as we may need to update registries with configuration post creation
|
||||
// see Github issue #360
|
||||
public final class RegistryFactory implements io.helidon.common.metrics.InternalBridge.MetricRegistry.RegistryFactory {
|
||||
public final class RegistryFactory {
|
||||
private static final RegistryFactory INSTANCE = create();
|
||||
|
||||
private final EnumMap<Type, Registry> registries = new EnumMap<>(Type.class);
|
||||
@@ -156,11 +156,6 @@ public final class RegistryFactory implements io.helidon.common.metrics.Internal
|
||||
return publicRegistries.get(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public io.helidon.common.metrics.InternalBridge.MetricRegistry getBridgeRegistry(Type type) {
|
||||
return io.helidon.common.metrics.InternalBridge.MetricRegistry.class.cast(getRegistry(type));
|
||||
}
|
||||
|
||||
private void update(Config config) {
|
||||
this.config.set(config);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ module io.helidon.metrics {
|
||||
requires java.logging;
|
||||
|
||||
requires io.helidon.common;
|
||||
requires io.helidon.common.metrics;
|
||||
requires io.helidon.webserver.cors;
|
||||
|
||||
requires transitive microprofile.metrics.api;
|
||||
@@ -32,8 +31,5 @@ module io.helidon.metrics {
|
||||
requires io.helidon.config.mp;
|
||||
requires microprofile.config.api;
|
||||
|
||||
provides io.helidon.common.metrics.InternalBridge
|
||||
with io.helidon.metrics.InternalBridgeImpl;
|
||||
|
||||
exports io.helidon.metrics;
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
io.helidon.metrics.InternalBridgeImpl
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -63,11 +63,13 @@ public class HelidonConcurrentGaugeTest {
|
||||
|
||||
@BeforeAll
|
||||
static void initClass() {
|
||||
meta = new HelidonMetadata("aConcurrentGauge",
|
||||
"aConcurrentGauge",
|
||||
"aConcurrentGauge",
|
||||
MetricType.CONCURRENT_GAUGE,
|
||||
MetricUnits.NONE);
|
||||
meta = Metadata.builder()
|
||||
.withName("aConcurrentGauge")
|
||||
.withDisplayName("aConcurrentGauge")
|
||||
.withDescription("aConcurrentGauge")
|
||||
.withType(MetricType.CONCURRENT_GAUGE)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
System.out.println("Minimum required seconds within minute is " + MIN_REQUIRED_SECONDS
|
||||
+ ", so SECONDS_THRESHOLD is " + SECONDS_THRESHOLD);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,11 +47,13 @@ class HelidonCounterTest {
|
||||
|
||||
@BeforeAll
|
||||
static void initClass() {
|
||||
meta = new HelidonMetadata("theName",
|
||||
"theDisplayName",
|
||||
"theDescription",
|
||||
MetricType.COUNTER,
|
||||
MetricUnits.NONE);
|
||||
meta = Metadata.builder()
|
||||
.withName("theName")
|
||||
.withDisplayName("theDisplayName")
|
||||
.withDescription("theDescription")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,11 +45,13 @@ public class HelidonGaugeTest {
|
||||
|
||||
@BeforeAll
|
||||
static void initClass() {
|
||||
meta = new HelidonMetadata("aGauge",
|
||||
"aGauge",
|
||||
"aGauge",
|
||||
MetricType.GAUGE,
|
||||
MetricUnits.NONE);
|
||||
meta = Metadata.builder()
|
||||
.withName("aGauge")
|
||||
.withDisplayName("aGauge")
|
||||
.withDescription("aGauge")
|
||||
.withType(MetricType.GAUGE)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -124,11 +124,13 @@ class HelidonHistogramTest {
|
||||
|
||||
@BeforeAll
|
||||
static void initClass() {
|
||||
meta = new HelidonMetadata("file_sizes",
|
||||
"theDisplayName",
|
||||
"Users file size",
|
||||
MetricType.HISTOGRAM,
|
||||
MetricUnits.KILOBYTES);
|
||||
meta = Metadata.builder()
|
||||
.withName("file_sizes")
|
||||
.withDisplayName("theDisplayName")
|
||||
.withDescription("Users file size")
|
||||
.withType(MetricType.HISTOGRAM)
|
||||
.withUnit(MetricUnits.KILOBYTES)
|
||||
.build();
|
||||
|
||||
histoInt = HelidonHistogram.create("application", meta);
|
||||
histoIntID = new MetricID("file_sizes");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -53,11 +53,13 @@ class HelidonMeterTest {
|
||||
|
||||
@BeforeAll
|
||||
static void initClass() throws InterruptedException {
|
||||
Metadata meta = new HelidonMetadata("requests",
|
||||
"Requests",
|
||||
"Tracks the number of requests to the server",
|
||||
MetricType.METERED,
|
||||
MetricUnits.PER_SECOND);
|
||||
Metadata meta = Metadata.builder()
|
||||
.withName("requests")
|
||||
.withDisplayName("Requests")
|
||||
.withDescription("Tracks the number of requests to the server")
|
||||
.withType(MetricType.METERED)
|
||||
.withUnit(MetricUnits.PER_SECOND)
|
||||
.build();
|
||||
|
||||
LongAdder nanoTime = new LongAdder();
|
||||
LongAdder milliTime = new LongAdder();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -66,11 +66,13 @@ class HelidonTimerTest {
|
||||
|
||||
@BeforeAll
|
||||
static void initClass() {
|
||||
meta = new HelidonMetadata("response_time",
|
||||
"Responses",
|
||||
"Server response time for /index.html",
|
||||
MetricType.TIMER,
|
||||
MetricUnits.NANOSECONDS);
|
||||
meta = Metadata.builder()
|
||||
.withName("response_time")
|
||||
.withDisplayName("Responses")
|
||||
.withDescription("Server response time for /index.html")
|
||||
.withType(MetricType.TIMER)
|
||||
.withUnit(MetricUnits.NANOSECONDS)
|
||||
.build();
|
||||
|
||||
dataSetTimer = HelidonTimer.create("application", meta, dataSetTimerClock);
|
||||
dataSetTimerID = new MetricID("response_time");
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
package io.helidon.metrics;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.helidon.common.metrics.InternalBridge;
|
||||
import io.helidon.common.metrics.InternalBridge.Metadata;
|
||||
|
||||
import org.eclipse.microprofile.metrics.Counter;
|
||||
import org.eclipse.microprofile.metrics.MetricID;
|
||||
import org.eclipse.microprofile.metrics.MetricRegistry;
|
||||
import org.eclipse.microprofile.metrics.MetricType;
|
||||
import org.eclipse.microprofile.metrics.MetricUnits;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class InternalBridgeTest {
|
||||
|
||||
private static io.helidon.common.metrics.InternalBridge ib;
|
||||
private static io.helidon.common.metrics.InternalBridge.MetricRegistry.RegistryFactory ibFactory;
|
||||
private static RegistryFactory factory;
|
||||
private static io.helidon.common.metrics.InternalBridge.MetricRegistry ibVendor;
|
||||
private static MetricRegistry vendor;
|
||||
private static io.helidon.common.metrics.InternalBridge.MetricRegistry ibApp;
|
||||
private static MetricRegistry app;
|
||||
|
||||
public InternalBridgeTest() {
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
private static void loadFactory() {
|
||||
ib = io.helidon.common.metrics.InternalBridge.INSTANCE;
|
||||
ibFactory = ib.getRegistryFactory();
|
||||
factory = RegistryFactory.getInstance();
|
||||
ibVendor = ibFactory.getBridgeRegistry(MetricRegistry.Type.VENDOR);
|
||||
vendor = factory.getRegistry(MetricRegistry.Type.VENDOR);
|
||||
ibApp = ibFactory.getBridgeRegistry(MetricRegistry.Type.APPLICATION);
|
||||
app = factory.getRegistry(MetricRegistry.Type.APPLICATION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBridgeRegistryFactory() {
|
||||
assertSame(factory, ibFactory, "Factory and neutral factory do not match");
|
||||
assertSame(vendor, ibVendor, "Vendor registries via the two factories do not match");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTags() {
|
||||
String globalTags = System.getenv(MetricID.GLOBAL_TAGS_VARIABLE);
|
||||
Map<String, String> expectedTags = new HashMap<>();
|
||||
expectedTags.put("t1", "one");
|
||||
expectedTags.put("t2", "two");
|
||||
|
||||
if (globalTags != null) {
|
||||
Arrays.stream(globalTags.split(","))
|
||||
.map(expr -> {
|
||||
final int eq = expr.indexOf("=");
|
||||
if (eq <= 0) {
|
||||
return null;
|
||||
}
|
||||
String tag = expr.substring(0, eq);
|
||||
String value = expr.substring(eq + 1);
|
||||
return new AbstractMap.SimpleEntry<>(tag, value);
|
||||
})
|
||||
.filter(entry -> entry != null)
|
||||
.forEach(entry -> expectedTags.put(entry.getKey(), entry.getValue()));
|
||||
|
||||
}
|
||||
|
||||
org.eclipse.microprofile.metrics.Tag[] expectedTagsArray =
|
||||
expectedTags.entrySet().stream()
|
||||
.map(entry -> new org.eclipse.microprofile.metrics.Tag(entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.toList())
|
||||
.toArray(new org.eclipse.microprofile.metrics.Tag[0]);
|
||||
|
||||
Metadata internalMetadata = InternalBridge.newMetadataBuilder()
|
||||
.withName("MyCounter")
|
||||
.withDisplayName("MyCounter display")
|
||||
.withDescription("This is a test counter")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
|
||||
org.eclipse.microprofile.metrics.Metadata metadata = new org.eclipse.microprofile.metrics.MetadataBuilder()
|
||||
.withName("MyCounter")
|
||||
.withDisplayName("MyCounter display")
|
||||
.withDescription("This is a test counter")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
|
||||
Counter counter = ibApp.counter(internalMetadata, expectedTags);
|
||||
|
||||
org.eclipse.microprofile.metrics.MetricID expectedMetricID =
|
||||
new org.eclipse.microprofile.metrics.MetricID("MyCounter", expectedTagsArray);
|
||||
|
||||
SortedMap<MetricID, Counter> matchedCounters = app.getCounters(
|
||||
(metricID, metric) -> metricID.getName().equals("MyCounter"));
|
||||
|
||||
assertEquals(1, matchedCounters.size());
|
||||
assertEquals(counter, matchedCounters.get(expectedMetricID));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -69,11 +69,13 @@ class MetricImplTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void initClass() {
|
||||
Metadata meta = new HelidonMetadata("theName",
|
||||
"theDisplayName",
|
||||
"theDescription",
|
||||
MetricType.COUNTER,
|
||||
MetricUnits.NONE);
|
||||
Metadata meta = Metadata.builder()
|
||||
.withName("theName")
|
||||
.withDisplayName("theDisplayName")
|
||||
.withDescription("theDescription")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
|
||||
impl = new MetricImpl("base", meta) {
|
||||
@Override
|
||||
@@ -88,7 +90,10 @@ class MetricImplTest {
|
||||
};
|
||||
implID = new MetricID(meta.getName());
|
||||
|
||||
meta = new HelidonMetadata("counterWithoutDescription", MetricType.COUNTER);
|
||||
meta = Metadata.builder()
|
||||
.withName("counterWithoutDescription")
|
||||
.withType(MetricType.COUNTER)
|
||||
.build();
|
||||
|
||||
implWithoutDescription = new MetricImpl("base", meta) {
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -60,8 +60,14 @@ public class RegistryTest {
|
||||
|
||||
@Test
|
||||
void testSameNameDifferentTagsDifferentTypes() {
|
||||
Metadata metadata1 = new HelidonMetadata("counter2", MetricType.COUNTER);
|
||||
Metadata metadata2 = new HelidonMetadata("counter2", MetricType.TIMER);
|
||||
Metadata metadata1 = Metadata.builder()
|
||||
.withName("counter2")
|
||||
.withType(MetricType.COUNTER)
|
||||
.build();
|
||||
Metadata metadata2 = Metadata.builder()
|
||||
.withName("counter2")
|
||||
.withType(MetricType.TIMER)
|
||||
.build();
|
||||
registry.counter(metadata1, tag1);
|
||||
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
|
||||
() -> registry.timer(metadata2, tag2));
|
||||
@@ -70,10 +76,22 @@ public class RegistryTest {
|
||||
|
||||
@Test
|
||||
void testIncompatibleReuseNoTags() {
|
||||
Metadata metadata1 = new HelidonMetadata("counter3", "display name",
|
||||
"description", MetricType.COUNTER, MetricUnits.NONE, true);
|
||||
Metadata metadata2 = new HelidonMetadata("counter3", "display name",
|
||||
"description", MetricType.COUNTER, MetricUnits.NONE, false);
|
||||
Metadata metadata1 = Metadata.builder()
|
||||
.withName("counter3")
|
||||
.withDisplayName("display name")
|
||||
.withDescription("description")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.reusable(true)
|
||||
.build();
|
||||
Metadata metadata2 = Metadata.builder()
|
||||
.withName("counter3")
|
||||
.withDisplayName("display name")
|
||||
.withDescription("description")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.reusable(false)
|
||||
.build();
|
||||
|
||||
registry.counter(metadata1);
|
||||
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
|
||||
@@ -83,10 +101,22 @@ public class RegistryTest {
|
||||
|
||||
@Test
|
||||
void testIncompatibleReuseWithTags() {
|
||||
Metadata metadata1 = new HelidonMetadata("counter4", "display name",
|
||||
"description", MetricType.COUNTER, MetricUnits.NONE, true);
|
||||
Metadata metadata2 = new HelidonMetadata("counter4", "display name",
|
||||
"description", MetricType.COUNTER, MetricUnits.NONE, false);
|
||||
Metadata metadata1 = Metadata.builder()
|
||||
.withName("counter4")
|
||||
.withDisplayName("display name")
|
||||
.withDescription("description")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.reusable(true)
|
||||
.build();
|
||||
Metadata metadata2 = Metadata.builder()
|
||||
.withName("counter4")
|
||||
.withDisplayName("display name")
|
||||
.withDescription("description")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.reusable(false)
|
||||
.build();
|
||||
|
||||
registry.counter(metadata1, tag1);
|
||||
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
|
||||
@@ -96,10 +126,22 @@ public class RegistryTest {
|
||||
|
||||
@Test
|
||||
void testSameIDSameReuseDifferentOtherMetadata() {
|
||||
Metadata metadata1 = new HelidonMetadata("counter5", "display name",
|
||||
"description", MetricType.COUNTER, MetricUnits.NONE, true);
|
||||
Metadata metadata2 = new HelidonMetadata("counter5", "OTHER display name",
|
||||
"description", MetricType.COUNTER, MetricUnits.NONE, true);
|
||||
Metadata metadata1 = Metadata.builder()
|
||||
.withName("counter5")
|
||||
.withDisplayName("display name")
|
||||
.withDescription("description")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.reusable(true)
|
||||
.build();
|
||||
Metadata metadata2 = Metadata.builder()
|
||||
.withName("counter5")
|
||||
.withDisplayName("OTHER display name")
|
||||
.withDescription("description")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.reusable(true)
|
||||
.build();
|
||||
|
||||
registry.counter(metadata1, tag1);
|
||||
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -58,10 +58,6 @@
|
||||
<groupId>org.eclipse.microprofile.fault-tolerance</groupId>
|
||||
<artifactId>microprofile-fault-tolerance-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.helidon.common</groupId>
|
||||
<artifactId>helidon-common-metrics</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.microprofile.metrics</groupId>
|
||||
<artifactId>microprofile-metrics-api</artifactId>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,21 +17,19 @@
|
||||
package io.helidon.microprofile.faulttolerance;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.enterprise.inject.spi.CDI;
|
||||
|
||||
import io.helidon.common.metrics.InternalBridge.MetricID;
|
||||
import io.helidon.common.metrics.InternalBridge.MetricRegistry;
|
||||
|
||||
import org.eclipse.microprofile.metrics.Counter;
|
||||
import org.eclipse.microprofile.metrics.Gauge;
|
||||
import org.eclipse.microprofile.metrics.Histogram;
|
||||
import org.eclipse.microprofile.metrics.Metadata;
|
||||
import org.eclipse.microprofile.metrics.Metric;
|
||||
import org.eclipse.microprofile.metrics.MetricID;
|
||||
import org.eclipse.microprofile.metrics.MetricRegistry;
|
||||
import org.eclipse.microprofile.metrics.MetricType;
|
||||
import org.eclipse.microprofile.metrics.MetricUnits;
|
||||
|
||||
import static io.helidon.common.metrics.InternalBridge.Metadata.newMetadata;
|
||||
import static io.helidon.microprofile.faulttolerance.FaultToleranceExtension.getRealClass;
|
||||
import static io.helidon.microprofile.faulttolerance.FaultToleranceExtension.isFaultToleranceMetricsEnabled;
|
||||
|
||||
@@ -63,7 +61,7 @@ class FaultToleranceMetrics {
|
||||
MetricID metricID = newMetricID(String.format(METRIC_NAME_TEMPLATE,
|
||||
method.getDeclaringClass().getName(),
|
||||
method.getName(), name));
|
||||
return (T) getMetricRegistry().getBridgeMetrics().get(metricID);
|
||||
return (T) getMetricRegistry().getMetrics().get(metricID);
|
||||
}
|
||||
|
||||
static Counter getCounter(Method method, String name) {
|
||||
@@ -305,7 +303,7 @@ class FaultToleranceMetrics {
|
||||
private static Counter registerCounter(String name, String description) {
|
||||
return getMetricRegistry().counter(
|
||||
newMetadata(name, name, description, MetricType.COUNTER, MetricUnits.NONE,
|
||||
true, Collections.emptyMap()));
|
||||
true));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,7 +316,7 @@ class FaultToleranceMetrics {
|
||||
static Histogram registerHistogram(String name, String description) {
|
||||
return getMetricRegistry().histogram(
|
||||
newMetadata(name, name, description, MetricType.HISTOGRAM, MetricUnits.NANOSECONDS,
|
||||
true, Collections.emptyMap()));
|
||||
true));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -335,18 +333,29 @@ class FaultToleranceMetrics {
|
||||
method.getDeclaringClass().getName(),
|
||||
method.getName(),
|
||||
metricName));
|
||||
Gauge<T> existing = getMetricRegistry().getBridgeGauges().get(metricID);
|
||||
Gauge<T> existing = getMetricRegistry().getGauges().get(metricID);
|
||||
if (existing == null) {
|
||||
getMetricRegistry().register(
|
||||
newMetadata(metricID.getName(), metricID.getName(), description, MetricType.GAUGE, MetricUnits.NANOSECONDS,
|
||||
true, Collections.emptyMap()),
|
||||
true),
|
||||
gauge);
|
||||
}
|
||||
return existing;
|
||||
}
|
||||
|
||||
private static MetricID newMetricID(String name) {
|
||||
return MetricID.Factory.INSTANCE.newMetricID(name);
|
||||
return new MetricID(name);
|
||||
}
|
||||
|
||||
private static Metadata newMetadata(String name, String displayName, String description, MetricType metricType,
|
||||
String metricUnits, boolean isReusable) {
|
||||
return Metadata.builder()
|
||||
.withName(name)
|
||||
.withDisplayName(displayName)
|
||||
.withDescription(description)
|
||||
.withType(metricType)
|
||||
.withUnit(metricUnits)
|
||||
.reusable(isReusable)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,7 +25,6 @@ module io.helidon.microprofile.faulttolerance {
|
||||
|
||||
requires io.helidon.common.context;
|
||||
requires io.helidon.common.configurable;
|
||||
requires io.helidon.common.metrics;
|
||||
requires io.helidon.microprofile.config;
|
||||
requires io.helidon.microprofile.server;
|
||||
requires io.helidon.microprofile.metrics;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,11 +19,9 @@ package io.helidon.microprofile.faulttolerance;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import io.helidon.common.metrics.InternalBridge;
|
||||
import io.helidon.common.metrics.InternalBridge.Metadata.MetadataBuilder;
|
||||
import io.helidon.common.metrics.InternalBridge.MetricRegistry;
|
||||
|
||||
import org.eclipse.microprofile.faulttolerance.exceptions.CircuitBreakerOpenException;
|
||||
import org.eclipse.microprofile.metrics.Metadata;
|
||||
import org.eclipse.microprofile.metrics.MetricRegistry;
|
||||
import org.eclipse.microprofile.metrics.MetricType;
|
||||
import org.eclipse.microprofile.metrics.MetricUnits;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -81,7 +79,7 @@ public class MetricsTest extends FaultToleranceTest {
|
||||
@Test
|
||||
public void testInjectCounterProgrammatically() {
|
||||
MetricRegistry metricRegistry = getMetricRegistry();
|
||||
metricRegistry.counter(newMetadataBuilder()
|
||||
metricRegistry.counter(Metadata.builder()
|
||||
.withName("dcounter")
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
@@ -370,8 +368,4 @@ public class MetricsTest extends FaultToleranceTest {
|
||||
BULKHEAD_EXECUTION_DURATION, long.class).getCount(),
|
||||
is((long)BulkheadBean.MAX_CONCURRENT_CALLS));
|
||||
}
|
||||
|
||||
private static MetadataBuilder newMetadataBuilder() {
|
||||
return InternalBridge.newMetadataBuilder();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,8 +28,6 @@ import javax.enterprise.context.ApplicationScoped;
|
||||
import javax.enterprise.inject.Produces;
|
||||
import javax.enterprise.inject.spi.InjectionPoint;
|
||||
|
||||
import io.helidon.metrics.HelidonMetadata;
|
||||
|
||||
import org.eclipse.microprofile.metrics.ConcurrentGauge;
|
||||
import org.eclipse.microprofile.metrics.Counter;
|
||||
import org.eclipse.microprofile.metrics.Gauge;
|
||||
@@ -54,16 +52,20 @@ import org.eclipse.microprofile.metrics.annotation.Timed;
|
||||
class MetricProducer {
|
||||
|
||||
private static Metadata newMetadata(InjectionPoint ip, Metric metric, MetricType metricType) {
|
||||
return metric == null ? new HelidonMetadata(getName(ip),
|
||||
"",
|
||||
"",
|
||||
metricType,
|
||||
chooseDefaultUnit(metricType))
|
||||
: new HelidonMetadata(getName(metric, ip),
|
||||
metric.displayName(),
|
||||
metric.description(),
|
||||
metricType,
|
||||
metric.unit());
|
||||
return metric == null ? Metadata.builder()
|
||||
.withName(getName(ip))
|
||||
.withDisplayName("")
|
||||
.withDescription("")
|
||||
.withType(metricType)
|
||||
.withUnit(chooseDefaultUnit(metricType))
|
||||
.build()
|
||||
: Metadata.builder()
|
||||
.withName(getName(metric, ip))
|
||||
.withDisplayName(metric.displayName())
|
||||
.withDescription(metric.description())
|
||||
.withType(metricType)
|
||||
.withUnit(metric.unit())
|
||||
.build();
|
||||
}
|
||||
|
||||
private static String chooseDefaultUnit(MetricType metricType) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,7 +56,6 @@ import io.helidon.common.HelidonFeatures;
|
||||
import io.helidon.common.HelidonFlavor;
|
||||
import io.helidon.config.Config;
|
||||
import io.helidon.config.ConfigValue;
|
||||
import io.helidon.metrics.HelidonMetadata;
|
||||
import io.helidon.metrics.MetricsSupport;
|
||||
import io.helidon.microprofile.server.ServerCdiExtension;
|
||||
import io.helidon.webserver.Routing;
|
||||
@@ -124,12 +123,14 @@ public class MetricsCdiExtension implements Extension {
|
||||
String metricName = getMetricName(element, clazz, lookupResult.getType(), counted.name().trim(),
|
||||
counted.absolute());
|
||||
String displayName = counted.displayName().trim();
|
||||
Metadata meta = new HelidonMetadata(metricName,
|
||||
displayName.isEmpty() ? metricName : displayName,
|
||||
counted.description().trim(),
|
||||
MetricType.COUNTER,
|
||||
counted.unit().trim(),
|
||||
counted.reusable());
|
||||
Metadata meta = Metadata.builder()
|
||||
.withName(metricName)
|
||||
.withDisplayName(displayName.isEmpty() ? metricName : displayName)
|
||||
.withDescription(counted.description().trim())
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(counted.unit().trim())
|
||||
.reusable(counted.reusable())
|
||||
.build();
|
||||
registry.counter(meta, tags(counted.tags()));
|
||||
LOGGER.log(Level.FINE, () -> "Registered counter " + metricName);
|
||||
} else if (annotation instanceof Metered) {
|
||||
@@ -137,12 +138,14 @@ public class MetricsCdiExtension implements Extension {
|
||||
String metricName = getMetricName(element, clazz, lookupResult.getType(), metered.name().trim(),
|
||||
metered.absolute());
|
||||
String displayName = metered.displayName().trim();
|
||||
Metadata meta = new HelidonMetadata(metricName,
|
||||
displayName.isEmpty() ? metricName : displayName,
|
||||
metered.description().trim(),
|
||||
MetricType.METERED,
|
||||
metered.unit().trim(),
|
||||
metered.reusable());
|
||||
Metadata meta = Metadata.builder()
|
||||
.withName(metricName)
|
||||
.withDisplayName(displayName.isEmpty() ? metricName : displayName)
|
||||
.withDescription(metered.description().trim())
|
||||
.withType(MetricType.METERED)
|
||||
.withUnit(metered.unit().trim())
|
||||
.reusable(metered.reusable())
|
||||
.build();
|
||||
registry.meter(meta, tags(metered.tags()));
|
||||
LOGGER.log(Level.FINE, () -> "Registered meter " + metricName);
|
||||
} else if (annotation instanceof Timed) {
|
||||
@@ -150,12 +153,14 @@ public class MetricsCdiExtension implements Extension {
|
||||
String metricName = getMetricName(element, clazz, lookupResult.getType(), timed.name().trim(),
|
||||
timed.absolute());
|
||||
String displayName = timed.displayName().trim();
|
||||
Metadata meta = new HelidonMetadata(metricName,
|
||||
displayName.isEmpty() ? metricName : displayName,
|
||||
timed.description().trim(),
|
||||
MetricType.TIMER,
|
||||
timed.unit().trim(),
|
||||
timed.reusable());
|
||||
Metadata meta = Metadata.builder()
|
||||
.withName(metricName)
|
||||
.withDisplayName(displayName.isEmpty() ? metricName : displayName)
|
||||
.withDescription(timed.description().trim())
|
||||
.withType(MetricType.TIMER)
|
||||
.withUnit(timed.unit().trim())
|
||||
.reusable(timed.reusable())
|
||||
.build();
|
||||
registry.timer(meta, tags(timed.tags()));
|
||||
LOGGER.log(Level.FINE, () -> "Registered timer " + metricName);
|
||||
} else if (annotation instanceof ConcurrentGauge) {
|
||||
@@ -163,12 +168,14 @@ public class MetricsCdiExtension implements Extension {
|
||||
String metricName = getMetricName(element, clazz, lookupResult.getType(), concurrentGauge.name().trim(),
|
||||
concurrentGauge.absolute());
|
||||
String displayName = concurrentGauge.displayName().trim();
|
||||
Metadata meta = new HelidonMetadata(metricName,
|
||||
displayName.isEmpty() ? metricName : displayName,
|
||||
concurrentGauge.description().trim(),
|
||||
MetricType.CONCURRENT_GAUGE,
|
||||
concurrentGauge.unit().trim(),
|
||||
concurrentGauge.reusable());
|
||||
Metadata meta = Metadata.builder()
|
||||
.withName(metricName)
|
||||
.withDisplayName(displayName.isEmpty() ? metricName : displayName)
|
||||
.withDescription(concurrentGauge.description().trim())
|
||||
.withType(MetricType.CONCURRENT_GAUGE)
|
||||
.withUnit(concurrentGauge.unit().trim())
|
||||
.reusable(concurrentGauge.reusable())
|
||||
.build();
|
||||
registry.concurrentGauge(meta, tags(concurrentGauge.tags()));
|
||||
LOGGER.log(Level.FINE, () -> "Registered concurrent gauge " + metricName);
|
||||
}
|
||||
@@ -356,12 +363,14 @@ public class MetricsCdiExtension implements Extension {
|
||||
MetricUtil.MatchingType.METHOD,
|
||||
metric.name(), metric.absolute());
|
||||
T instance = getReference(bm, entry.getValue().getBaseType(), entry.getKey());
|
||||
Metadata md = new HelidonMetadata(metricName,
|
||||
metric.displayName(),
|
||||
metric.description(),
|
||||
getMetricType(instance),
|
||||
metric.unit(),
|
||||
false);
|
||||
Metadata md = Metadata.builder()
|
||||
.withName(metricName)
|
||||
.withDisplayName(metric.displayName())
|
||||
.withDescription(metric.description())
|
||||
.withType(getMetricType(instance))
|
||||
.withUnit(metric.unit())
|
||||
.reusable(false)
|
||||
.build();
|
||||
registry.register(md, instance);
|
||||
}
|
||||
});
|
||||
@@ -474,12 +483,14 @@ public class MetricsCdiExtension implements Extension {
|
||||
dg = buildDelegatingGauge(gaugeID.getName(), site,
|
||||
bm);
|
||||
Gauge gaugeAnnotation = site.getAnnotated().getAnnotation(Gauge.class);
|
||||
Metadata md = new HelidonMetadata(gaugeID.getName(),
|
||||
gaugeAnnotation.displayName(),
|
||||
gaugeAnnotation.description(),
|
||||
MetricType.GAUGE,
|
||||
gaugeAnnotation.unit(),
|
||||
false);
|
||||
Metadata md = Metadata.builder()
|
||||
.withName(gaugeID.getName())
|
||||
.withDisplayName(gaugeAnnotation.displayName())
|
||||
.withDescription(gaugeAnnotation.description())
|
||||
.withType(MetricType.GAUGE)
|
||||
.withUnit(gaugeAnnotation.unit())
|
||||
.reusable(false)
|
||||
.build();
|
||||
LOGGER.log(Level.FINE, () -> String.format("Registering gauge with metadata %s", md.toString()));
|
||||
registry.register(md, dg, gaugeID.getTagsAsList().toArray(new Tag[0]));
|
||||
} catch (Throwable t) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,8 +19,7 @@ package io.helidon.microprofile.metrics;
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
import javax.enterprise.inject.Produces;
|
||||
|
||||
import io.helidon.common.metrics.InternalBridge.MetricRegistry;
|
||||
|
||||
import org.eclipse.microprofile.metrics.MetricRegistry;
|
||||
import org.eclipse.microprofile.metrics.MetricRegistry.Type;
|
||||
import org.eclipse.microprofile.metrics.annotation.RegistryType;
|
||||
|
||||
@@ -36,29 +35,6 @@ final class RegistryProducer {
|
||||
private RegistryProducer() {
|
||||
}
|
||||
|
||||
@Produces
|
||||
public static MetricRegistry getDefaultRegistryInternal() {
|
||||
return getApplicationRegistryInternal();
|
||||
}
|
||||
|
||||
@Produces
|
||||
@RegistryType(type = Type.APPLICATION)
|
||||
public static MetricRegistry getApplicationRegistryInternal() {
|
||||
return REGISTRY_FACTORY.getBridgeRegistry(Type.APPLICATION);
|
||||
}
|
||||
|
||||
@Produces
|
||||
@RegistryType(type = Type.BASE)
|
||||
public static MetricRegistry getBaseRegistryInternal() {
|
||||
return REGISTRY_FACTORY.getBridgeRegistry(Type.BASE);
|
||||
}
|
||||
|
||||
@Produces
|
||||
@RegistryType(type = Type.VENDOR)
|
||||
public static MetricRegistry getVendorRegistryInternal() {
|
||||
return REGISTRY_FACTORY.getBridgeRegistry(Type.VENDOR);
|
||||
}
|
||||
|
||||
@Produces
|
||||
public static org.eclipse.microprofile.metrics.MetricRegistry getDefaultRegistry() {
|
||||
return getApplicationRegistry();
|
||||
@@ -87,7 +63,7 @@ final class RegistryProducer {
|
||||
* all run on the same VM and must not interfere with each other.
|
||||
*/
|
||||
static void clearApplicationRegistry() {
|
||||
MetricRegistry applicationRegistry = getApplicationRegistryInternal();
|
||||
MetricRegistry applicationRegistry = getApplicationRegistry();
|
||||
applicationRegistry.getNames().forEach(applicationRegistry::remove);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,7 +29,6 @@ module io.helidon.microprofile.metrics {
|
||||
requires io.helidon.microprofile.server;
|
||||
requires io.helidon.microprofile.config;
|
||||
requires transitive io.helidon.metrics;
|
||||
requires io.helidon.common.metrics;
|
||||
|
||||
requires transitive microprofile.config.api;
|
||||
requires microprofile.metrics.api;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,6 @@ package io.helidon.microprofile.metrics;
|
||||
import javax.ws.rs.client.Client;
|
||||
import javax.ws.rs.client.ClientBuilder;
|
||||
|
||||
import io.helidon.metrics.HelidonMetadata;
|
||||
import io.helidon.metrics.RegistryFactory;
|
||||
import io.helidon.microprofile.server.Server;
|
||||
|
||||
@@ -68,11 +67,13 @@ public class MetricsMpServiceTest {
|
||||
}
|
||||
|
||||
protected static void registerCounter(String name) {
|
||||
Metadata meta = new HelidonMetadata(name,
|
||||
name,
|
||||
name,
|
||||
MetricType.COUNTER,
|
||||
MetricUnits.NONE);
|
||||
Metadata meta = Metadata.builder()
|
||||
.withName(name)
|
||||
.withDisplayName(name)
|
||||
.withDescription(name)
|
||||
.withType(MetricType.COUNTER)
|
||||
.withUnit(MetricUnits.NONE)
|
||||
.build();
|
||||
registry.counter(meta);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user