Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metrics 4.0 implementation #3847

Merged
merged 17 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions examples/metrics/exemplar/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2021 Oracle and/or its affiliates.
Copyright (c) 2021, 2022 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.
Expand All @@ -15,7 +15,8 @@
See the License for the specific language governing permissions and
limitations under the License.

--><project xmlns="http://maven.apache.org/POM/4.0.0"
-->
<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">
<parent>
Expand Down Expand Up @@ -62,6 +63,11 @@
<artifactId>helidon-tracing-zipkin</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config-yaml</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
7 changes: 6 additions & 1 deletion examples/metrics/filtering/se/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2021 Oracle and/or its affiliates.
Copyright (c) 2021, 2022 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.
Expand Down Expand Up @@ -46,6 +46,11 @@
<groupId>io.helidon.metrics</groupId>
<artifactId>helidon-metrics</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config-yaml</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
7 changes: 6 additions & 1 deletion examples/metrics/kpi/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2021 Oracle and/or its affiliates.
Copyright (c) 2021, 2022 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.
Expand Down Expand Up @@ -46,6 +46,11 @@
<groupId>io.helidon.metrics</groupId>
<artifactId>helidon-metrics</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config-yaml</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,16 @@ public <T extends Metric> T getMetric(MetricID metricID, Class<T> asType) {
return asType.cast(metricStore.metric(metricID));
}

/**
* Update the registry settings for this registry.
*
* @param registrySettings new settings to use going forward
*/
public void update(RegistrySettings registrySettings) {
metricStore.update(registrySettings);
}


/**
* Returns type of this registry.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class MetricStore<M extends HelidonMetric> {
private final Map<String, List<MetricID>> allMetricIDsByName = new ConcurrentHashMap<>();
private final Map<String, Metadata> allMetadata = new ConcurrentHashMap<>(); // metric name -> metadata

private final RegistrySettings registrySettings;
private RegistrySettings registrySettings;
tjquinno marked this conversation as resolved.
Show resolved Hide resolved
private final Map<MetricType, BiFunction<String, Metadata, M>> metricFactories;
private final AbstractRegistry.GaugeFactory.SupplierBased supplierBasedGaugeFactory;
private final AbstractRegistry.GaugeFactory.FunctionBased functionBasedGaugeFactory;
Expand Down Expand Up @@ -108,6 +108,10 @@ private MetricStore(RegistrySettings registrySettings,
this.toImpl = toImpl;
}

void update(RegistrySettings registrySettings) {
this.registrySettings = registrySettings;
}

<U extends Metric> U getOrRegisterMetric(MetricID metricID, Class<U> clazz) {
return getOrRegisterMetric(metricID.getName(),
clazz,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,9 @@ public static Registry create(Type type, RegistrySettings registrySettings) {
return new Registry(type, registrySettings);
}

/**
* Update the registry settings for this registry.
*
* @param registrySettings new settings to use going forward
*/
@Override
public void update(RegistrySettings registrySettings) {
super.update(registrySettings);
this.registrySettings.set(registrySettings);
}

Expand Down