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

4.x: Neutral metrics API - revise MetricsFeature and rework Prometheus and JSON formatting #1

Open
wants to merge 41 commits into
base: neutral-metrics-api
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2cae629
Initial commit of neutral metrics API with high-level interfaces; mor…
tjquinno Jul 27, 2023
e95f9d7
Some clean-up of earlier push; add more API interfaces and no-op impl…
tjquinno Jul 28, 2023
ecfdc6c
Incorporate some review comments: move micrometer impl under provider…
tjquinno Jul 31, 2023
8ecc842
Other review comment; change recordCallable to record
tjquinno Jul 31, 2023
d66f959
More review comment changes; fix up temporary dep. in service-api on …
tjquinno Aug 1, 2023
1b97b01
Temporary for successful build while adding the neutral metrics API
tjquinno Aug 1, 2023
6cf2041
Two intermixed changes: trimming the API exposed by Metrics and Meter…
tjquinno Aug 3, 2023
166cedd
Some clean-up of checkstyle, spotbugs.
tjquinno Aug 3, 2023
e136ba1
Adapt to change in Prototype.Blueprint
tjquinno Aug 3, 2023
3de8ade
Add more tests of the neutral API; add some convenience methods
tjquinno Aug 3, 2023
5dee845
Neutral API tests
tjquinno Aug 3, 2023
cf8ed36
WIP adding Micrometer implementation; pushing for safekeeping even th…
tjquinno Aug 5, 2023
861be1d
Fix API for remove to return Optional; more Micrometer implementation…
tjquinno Aug 7, 2023
4ba7508
Further work on Micrometer impl; some changes to API as well
tjquinno Aug 8, 2023
c863de4
Various clean-up, remove some TODOs
tjquinno Aug 8, 2023
713dc45
Some tests for the Micrometer implementation; working on exposing con…
tjquinno Aug 10, 2023
66812f4
Try workaround for providing visibility to config
tjquinno Aug 10, 2023
c493712
Fix from Tomas for builder
tjquinno Aug 11, 2023
51c732b
Adding more tests in the Micrometer implementation based on the old u…
tjquinno Aug 11, 2023
563c195
Add straggler new file
tjquinno Aug 11, 2023
74ccb46
Add a missing requires clause
tjquinno Aug 11, 2023
bb3632c
More tests and associated code changes
tjquinno Aug 11, 2023
cfc5469
More tests; push for safe keeping
tjquinno Aug 13, 2023
6539869
Add common unit tests for implementations
tjquinno Aug 13, 2023
cf9baff
Remove commented unneeded lines; clarify comments
tjquinno Aug 13, 2023
acb05a5
Expand tests; corresponding changes to interfaces and implementations
tjquinno Aug 14, 2023
d279bb7
Further gauge tests
tjquinno Aug 14, 2023
52a104d
Adopt Tomas's changes for two builder classes rather than the interim…
tjquinno Aug 14, 2023
ed7f0e3
Adapt to recent changes in support for config method in builder/gener…
tjquinno Aug 14, 2023
abd65cf
Some simplification of the API; use longs not doubles for counts, etc.
tjquinno Aug 14, 2023
dd8573d
Add tests; fix some timer/sample problems
tjquinno Aug 15, 2023
67ac9a0
Some clean-up
tjquinno Aug 15, 2023
995956a
Clean up bom
tjquinno Aug 15, 2023
d9a9ec9
Fix line length
tjquinno Aug 15, 2023
de8b5ff
Rename Wrapped to Wrapper
tjquinno Aug 15, 2023
ee7a8bb
Review comments; some other clean-up
tjquinno Aug 15, 2023
e584665
adopt latest Micrometer release 1.11.3
tjquinno Aug 15, 2023
895ef93
Update release of Micrometer Prometheus registry as well
tjquinno Aug 15, 2023
e086ce2
Metrics feature changes - prometheus formatting; code for JSON format…
tjquinno Aug 16, 2023
63e60f7
Refactor formatting (Prometheus and JSON) and add tests
tjquinno Aug 16, 2023
4500576
A few style fixes, make JSON formatting selection only if the media t…
tjquinno Aug 16, 2023
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: 10 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,16 @@
<artifactId>helidon-metrics-api</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.metrics</groupId>
<artifactId>helidon-metrics-testing</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.metrics</groupId>
<artifactId>helidon-metrics-micrometer</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.metrics</groupId>
<artifactId>helidon-metrics-service-api</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
<version.lib.logback>1.4.0</version.lib.logback>
<version.lib.mariadb-java-client>2.6.2</version.lib.mariadb-java-client>
<version.lib.maven-wagon>2.10</version.lib.maven-wagon>
<version.lib.micrometer>1.11.1</version.lib.micrometer>
<version.lib.micrometer-prometheus>1.11.1</version.lib.micrometer-prometheus>
<version.lib.micrometer>1.11.3</version.lib.micrometer>
<version.lib.micrometer-prometheus>1.11.3</version.lib.micrometer-prometheus>
<version.lib.micronaut>3.4.3</version.lib.micronaut>
<version.lib.micronaut.data>3.3.0</version.lib.micronaut.data>
<version.lib.micronaut.sql>4.4.0</version.lib.micronaut.sql>
Expand Down
34 changes: 30 additions & 4 deletions metrics/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@
<groupId>io.helidon.common</groupId>
<artifactId>helidon-common-config</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.builder</groupId>
<artifactId>helidon-builder-api</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.inject.configdriven</groupId>
<artifactId>helidon-inject-configdriven-api</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.helidon.inject.configdriven</groupId>
<artifactId>helidon-inject-configdriven-runtime</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config-metadata</artifactId>
Expand All @@ -50,13 +64,10 @@
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.common.testing</groupId>
<artifactId>helidon-common-testing-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down Expand Up @@ -88,11 +99,26 @@
<configuration>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<annotationProcessorPaths>
<path>
<groupId>io.helidon.common.features</groupId>
<artifactId>helidon-common-features-processor</artifactId>
<version>${helidon.version}</version>
</path>
<path>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config-metadata-processor</artifactId>
<version>${helidon.version}</version>
</path>
<path>
<groupId>io.helidon.inject.configdriven</groupId>
<artifactId>helidon-inject-configdriven-processor</artifactId>
<version>${helidon.version}</version>
</path>
<path>
<groupId>io.helidon.builder</groupId>
<artifactId>helidon-builder-processor</artifactId>
<version>${helidon.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
Expand Down
51 changes: 51 additions & 0 deletions metrics/api/src/main/java/io/helidon/metrics/api/Bucket.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2023 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.metrics.api;

import java.util.concurrent.TimeUnit;

/**
* Representation of a histogram bucket, including the boundary value and the count of observations in that bucket.
* <p>
* The boundary value is an upper bound on the observation values that can occupy the bucket.
* That is, an observation occupies a bucket if its value is less than or equal to the bucket's boundary value.
* </p>
*/
public interface Bucket extends Wrapper {

/**
* Returns the bucket boundary.
*
* @return bucket boundary value
*/
double boundary();

/**
* Returns the bucket boundary interpreted as a time in nanoseconds and expressed in the specified
* {@link java.util.concurrent.TimeUnit}.
*
* @param unit time unit in which to express the bucket boundary
* @return bucket boundary value
*/
double boundary(TimeUnit unit);

/**
* Returns the number of observations in the bucket.
*
* @return observation count for the bucket
*/
long count();
}
72 changes: 72 additions & 0 deletions metrics/api/src/main/java/io/helidon/metrics/api/Clock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2023 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.metrics.api;

/**
* Reports absolute time (and, therefore, is also useful in computing elapsed times).
*/
public interface Clock extends Wrapper {

/**
* Returns the system clock for the Helidon metrics implementation.
* <p>
* The system clock methods are functionally equivalent to {@link System#currentTimeMillis()}
* and {@link System#nanoTime()}.
* </p>
*
* @return the system clock
*/
static Clock system() {
return MetricsFactoryManager.getInstance().clockSystem();
}

/**
* Returns the current wall time in milliseconds since the epoch.
*
* <p>
* Typically equivalent to {@link System#currentTimeMillis()}. Should not be used to determine durations.
* For that use {@link #monotonicTime()} instead.
* </p>
*
* @return wall time in milliseconds
*/
long wallTime();

/**
* Returns the current time in nanoseconds from a monotonic clock source.
*
* <p>
* The value is only meaningful when compared with another value returned from this method to determine the elapsed time
* for an operation. The difference between two samples will have a unit of nanoseconds. The returned value is
* typically equivalent to {@link System#nanoTime()}.
* </p>
*
* @return monotonic time in nanoseconds
*/
long monotonicTime();

/**
* Unwraps the clock to the specified type (typically not needed for custom clocks).
*
* @param c {@link Class} to which to cast this object
* @return unwrapped clock
* @param <R> the type of the unwrapped clock
*/
@Override
default <R> R unwrap(Class<? extends R> c) {
throw new UnsupportedOperationException();
}
}
58 changes: 58 additions & 0 deletions metrics/api/src/main/java/io/helidon/metrics/api/Counter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2023 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.metrics.api;

/**
* Records a monotonically increasing value.
*/
public interface Counter extends Meter {

/**
* Creates a new builder for a counter.
*
* @param name counter name
* @return new builder
*/
static Builder builder(String name) {
return MetricsFactory.getInstance().counterBuilder(name);
}


/**
* Updates the counter by one.
*/
void increment();

/**
* Updates the counter by the specified amount which should be non-negative.
*
* @param amount amount to add to the counter.
*/
void increment(long amount);

/**
* Returns the cumulative count since this counter was registered.
*
* @return cumulative count since this counter was registered
*/
long count();

/**
* Builder for a new counter.
*/
interface Builder extends Meter.Builder<Builder, Counter> {
}
}
Loading