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

MP Metrics 5.0 support for 4.x #7139

Merged
merged 67 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
b3d1193
Initial commit of MP based on Micrometer
tjquinno Jun 16, 2023
88e75c1
More tests; start feature work; start CDI work
tjquinno Jun 19, 2023
a0a8324
More tests; start feature work; start CDI work
tjquinno Jun 19, 2023
9d1ce27
Added basics for timers, gauges
tjquinno Jun 19, 2023
b19be5a
Improve formatter API; fix and expand tests; plug feature in; start o…
tjquinno Jun 20, 2023
97dc30d
Finish missing method impls in metric registry impl; improve formatte…
tjquinno Jun 20, 2023
e4a9a67
Fix some checkstyle, JavaDoc comments, etc.
tjquinno Jun 21, 2023
4693d83
Further style, etc. fixes
tjquinno Jun 21, 2023
c7b178e
metrics/api stable; metrics/metrics WIP
tjquinno Jun 22, 2023
ea53e8d
More improvements to metrics/api and metrics/metrics
tjquinno Jun 22, 2023
c08c7ce
Fixes to metrics/api and metrics/metrics mostly
tjquinno Jun 22, 2023
8cef669
Copyright, spotbugs fixes
tjquinno Jun 22, 2023
8aa27f2
Fix KPI metrics
tjquinno Jun 23, 2023
9002585
Rebasing
tjquinno Jun 23, 2023
f7b7b0e
Copyright and style fixes mostly
tjquinno Jun 23, 2023
3bdb3f6
Try older Prom client version
tjquinno Jun 23, 2023
093cd13
Further small fixes to accomodate MP metrics API changes
tjquinno Jun 23, 2023
318aa71
Fix isolated Prometheus support to deal with later release
tjquinno Jun 23, 2023
dc43b78
Remove temp metrics feature under MP metrics from bom
tjquinno Jun 23, 2023
eff3ade
Clean up tag handling and Prom. formatting
tjquinno Jun 23, 2023
07b0409
Centralize tag handling in existing SystemTagsManager
tjquinno Jun 24, 2023
608a2ce
Some MP clean-up; more to come - push for safekeeping
tjquinno Jun 24, 2023
aa2cc62
Improvements in tag handling for scopes, reject options requests now …
tjquinno Jun 25, 2023
5a24b46
More changes adapting to change in metrics API
tjquinno Jun 25, 2023
f929d00
Fix some tag handling and Prometheus output filtering
tjquinno Jun 25, 2023
c7c1a37
Add back JSON formatting; related fixes
tjquinno Jun 26, 2023
f2fb1eb
Fixes in JSON output rework; various fixes in examples and tests
tjquinno Jun 26, 2023
ea62a4b
A few more fixes in other components and style clean-up
tjquinno Jun 26, 2023
32e8038
A few more edits to FT
tjquinno Jun 26, 2023
18c562e
Fix dead store
tjquinno Jun 26, 2023
c459516
Return to using the deprecated RegistryType annotation (which is a qu…
tjquinno Jun 26, 2023
536debe
Add cross-scope validation of metadata and tag name sets for same-nam…
tjquinno Jun 27, 2023
7608958
Add metric name to error message for more clarity
tjquinno Jun 27, 2023
5f45d77
Enforce same-named metric restrictions within scope only, not across …
tjquinno Jun 27, 2023
9bc9d65
Fix some meter filtering for output; temporarily disable enforcement …
tjquinno Jun 27, 2023
62d8790
Add functional counter support
tjquinno Jun 28, 2023
f47739c
Improve system tag handling
tjquinno Jun 28, 2023
9e20514
Uncomment stringent consistency checking for tag name sets; try arq. …
tjquinno Jun 28, 2023
57f5169
Remove meters from archetype (meters are no longer part of metrics)
tjquinno Jun 28, 2023
73ad2b9
Restore JSON output to MetricsSupport for now
tjquinno Jun 28, 2023
3bcf1ec
Disable exemplar sample check for exemplar while we migrate exemplar …
tjquinno Jun 28, 2023
a7e0722
Fix KPI examples; it needs to look for gauge values now
tjquinno Jun 28, 2023
6ce3654
Add missing verison spec for Helidon artifact
tjquinno Jun 28, 2023
b326082
More fixes; change native test to check timers instead of simple time…
tjquinno Jun 28, 2023
b39de03
Need to use MP FT 4.0.2 to depend on correct MP metrics release
tjquinno Jun 28, 2023
b6f0eea
Adjust to removal of scope tag from JSON output
tjquinno Jun 28, 2023
f368262
Fix bug in deletion; add test (not the cause of the TCK problems, tho…
tjquinno Jun 28, 2023
08f08a4
Fix up JavaDoc link to match changes I made to the referenced method …
tjquinno Jun 28, 2023
4a0f8fc
Minor fix to JSON formatting and to bookstore functional test (to be …
tjquinno Jun 29, 2023
21da420
Handle per-metric enable/disable in formatting
tjquinno Jun 29, 2023
2f2a429
Make sure to return 404 if selective metrics retrieval finds no match…
tjquinno Jun 29, 2023
22a26a6
Add back EOF filtering from Prom. output; fix Optional issue
tjquinno Jun 29, 2023
0151c96
Remove obsolete metrics usage
tjquinno Jun 29, 2023
d67a736
Remove refc to now-removed min value for timer
tjquinno Jun 30, 2023
f5de4d3
Fix bad change for registry type qualification on injection
tjquinno Jun 30, 2023
fc0e002
Various clean-up changes; pruning unneeded files and directories
tjquinno Jun 30, 2023
d187627
Style
tjquinno Jun 30, 2023
8bf9659
Handle injections modified with @RegistryScope as well as @RegistryType
tjquinno Jun 30, 2023
add80e3
Bug fixes
tjquinno Jun 30, 2023
7916312
Further fine-tune regex to exclude TCK jars from Weld scanning
tjquinno Jul 1, 2023
d706ce9
Refine the Arq config
tjquinno Jul 1, 2023
60785d4
Add logic to clear data structures between same-JVM TCK tests (essent…
tjquinno Jul 1, 2023
26c4cc1
Restore metrics TCK runs
tjquinno Jul 1, 2023
21ae6ab
Report 'base' as a scope, even if that registry has not been on-deman…
tjquinno Jul 3, 2023
9438aee
Move clean-out of registries from afterStart to beforeStop; some othe…
tjquinno Jul 11, 2023
ec5fd30
Move per-Arquillian cleanup from before bean discovery to before CDI …
tjquinno Jul 12, 2023
e138b14
Fix copyright date
tjquinno Jul 12, 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
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ particularly the following relevant sections:
2. `Application-Specific Metrics Data` - allows application-specific metrics to be created using CDI.

As part of the example, some of the methods in src.main.java.{{package}}.server.GreetResource.java
where annotated with Application-Specific metrics such as @Counted, @Metered and @Timed as shown below:
where annotated with Application-Specific metrics such as @Counted and @Timed as shown below:
```java
@Counted(name = "getDefaultMessage", absolute = true)
@Override
Expand All @@ -171,14 +171,6 @@ where annotated with Application-Specific metrics such as @Counted, @Metered and
return createGreetResponse("World");
}

@Metered(absolute = true, unit = MetricUnits.MILLISECONDS)
@Override
public GreetResponse getMessage(String name) {
LOGGER.info("getMessage(" + name + ") is invoked");
publishMetricAndLog("getMessage");
return createGreetResponse(name);
}

@Timed(name = "updateGreeting", absolute = true, unit = MetricUnits.MILLISECONDS)
@Override
public void updateGreeting(@Valid @NotNull GreetUpdate body) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import com.oracle.bmc.loggingingestion.requests.PutLogsRequest;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.metrics.MetricUnits;
import org.eclipse.microprofile.metrics.annotation.Counted;
import org.eclipse.microprofile.metrics.annotation.Metered;
import org.eclipse.microprofile.metrics.annotation.Timed;

import {{package}}.server.api.GreetService;
Expand Down Expand Up @@ -118,7 +117,6 @@ public class GreetResource implements GreetService {
* @param name the name to greet
* @return {@link GreetResponse}
*/
@Metered(absolute = true, unit = MetricUnits.MILLISECONDS)
@Override
public GreetResponse getMessage(String name) {
LOGGER.info("getMessage(" + name + ") is invoked");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 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.
Expand Down Expand Up @@ -34,6 +34,7 @@ enum MediaTypeEnum implements MediaType {
TEXT_PLAIN("text", "plain"),
TEXT_XML("text", "xml"),
TEXT_HTML("text", "html"),
APPLICATION_OPENMETRICS_TEXT("application", "openmetrics-text"),
APPLICATION_OPENAPI_YAML("application", "vnd.oai.openapi"),
APPLICATION_OPENAPI_JSON("application", "vnd.oai.openapi+json"),
APPLICATION_X_YAML("application", "x-yaml"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public final class MediaTypes {
* {@code application/vnd.oai.openapi+json} media type.
*/
public static final MediaType APPLICATION_OPENAPI_JSON = MediaTypeEnum.APPLICATION_OPENAPI_JSON;
/**
* {@code application/openmetrics-text} media type.
*/
public static final MediaType APPLICATION_OPENMETRICS_TEXT = MediaTypeEnum.APPLICATION_OPENMETRICS_TEXT;
/**
* {@code application/x-yaml} media type.
*/
Expand Down
16 changes: 11 additions & 5 deletions dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,19 @@
<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.6.6</version.lib.micrometer>
<version.lib.micrometer>1.11.1</version.lib.micrometer>
<version.lib.micrometer-prometheus>1.11.1</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>
<!-- FIXME upgrade to 3.1 when it is released in Maven -->
<version.lib.microprofile-config>3.0.1</version.lib.microprofile-config>
<!-- FIXME upgrade to 4.1 when it is released in Maven -->
<version.lib.microprofile-fault-tolerance-api>4.0</version.lib.microprofile-fault-tolerance-api>
<version.lib.microprofile-fault-tolerance-api>4.0.2</version.lib.microprofile-fault-tolerance-api>
<version.lib.microprofile-graphql>2.0</version.lib.microprofile-graphql>
<version.lib.microprofile-health>4.0</version.lib.microprofile-health>
<version.lib.microprofile-jwt>2.1</version.lib.microprofile-jwt>
<version.lib.microprofile-metrics-api>4.0</version.lib.microprofile-metrics-api>
<version.lib.microprofile-metrics-api>5.0.1</version.lib.microprofile-metrics-api>
<version.lib.microprofile-openapi-api>3.1</version.lib.microprofile-openapi-api>
<version.lib.microprofile-reactive-messaging-api>3.0</version.lib.microprofile-reactive-messaging-api>
<version.lib.microprofile-reactive-streams-operators-api>3.0</version.lib.microprofile-reactive-streams-operators-api>
Expand Down Expand Up @@ -141,7 +142,7 @@
<version.lib.perfmark-api>0.25.0</version.lib.perfmark-api>
<version.lib.parsson>1.0.2</version.lib.parsson>
<version.lib.postgresql>42.4.3</version.lib.postgresql>
<version.lib.prometheus>0.9.0</version.lib.prometheus>
<version.lib.prometheus>0.16.0</version.lib.prometheus>
<version.lib.slf4j>2.0.0</version.lib.slf4j>
<version.lib.smallrye-openapi>3.3.4</version.lib.smallrye-openapi>
<version.lib.snakeyaml>2.0</version.lib.snakeyaml>
Expand Down Expand Up @@ -495,6 +496,11 @@
<artifactId>simpleclient</artifactId>
<version>${version.lib.prometheus}</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_common</artifactId>
<version>${version.lib.prometheus}</version>
</dependency>
<dependency>
<groupId>io.zipkin.zipkin2</groupId>
<artifactId>zipkin</artifactId>
Expand Down Expand Up @@ -620,7 +626,7 @@
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>${version.lib.micrometer}</version>
<version>${version.lib.micrometer-prometheus}</version>
</dependency>

<!-- Microprofile related -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021 Oracle and/or its affiliates.
* Copyright (c) 2020, 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.
Expand All @@ -24,7 +24,7 @@
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import org.eclipse.microprofile.metrics.annotation.SimplyTimed;
import org.eclipse.microprofile.metrics.annotation.Timed;

/**
* JAX-RS resource, and the MicroProfile entry point to manage pet owners.
Expand Down Expand Up @@ -63,7 +63,7 @@ public Iterable<Owner> getAll() {
*/
@Path("/{name}")
@GET
@SimplyTimed
@Timed
public Owner owner(@PathParam("name") @Pattern(regexp = "\\w+[\\w+\\s?]*\\w") String name) {
return ownerRepository.findByName(name)
.orElseThrow(() -> new NotFoundException("Owner by name " + name + " does not exist"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2021 Oracle and/or its affiliates.
* Copyright (c) 2020, 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.
Expand All @@ -24,7 +24,7 @@
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import org.eclipse.microprofile.metrics.annotation.SimplyTimed;
import org.eclipse.microprofile.metrics.annotation.Timed;

/**
* JAX-RS resource, and the MicroProfile entry point to manage pets.
Expand Down Expand Up @@ -63,7 +63,7 @@ public Iterable<Pet> getAll() {
*/
@Path("/{name}")
@GET
@SimplyTimed
@Timed
public Pet pet(@PathParam("name") @Pattern(regexp = "\\w+[\\w+\\s?]*\\w") String name) {
return petRepository.findByName(name)
.orElseThrow(() -> new NotFoundException("Pet by name " + name + " does not exist"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 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.
Expand All @@ -23,6 +23,7 @@

import io.helidon.common.http.Http;
import io.helidon.config.Config;
import io.helidon.metrics.api.Registry;
import io.helidon.metrics.api.RegistryFactory;
import io.helidon.reactive.webserver.Routing;
import io.helidon.reactive.webserver.ServerRequest;
Expand All @@ -36,7 +37,6 @@
import org.eclipse.microprofile.metrics.Counter;
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.eclipse.microprofile.metrics.Timer;

Expand Down Expand Up @@ -78,18 +78,16 @@ public class GreetService implements Service {
GreetService(Config config) {
this.config = config;
greeting.set(config.get("app.greeting").asString().orElse("Ciao"));
MetricRegistry registry = RegistryFactory.getInstance().getRegistry(MetricRegistry.Type.APPLICATION);
MetricRegistry registry = RegistryFactory.getInstance().getRegistry(Registry.APPLICATION_SCOPE);
Metadata metadata = Metadata.builder()
.withName(TIMER_FOR_GETS)
.withUnit(MetricUnits.NANOSECONDS)
.withType(MetricType.TIMER)
.build();
timerForGets = registry.timer(metadata);

metadata = Metadata.builder()
.withName(COUNTER_FOR_PERSONALIZED_GREETINGS)
.withUnit(MetricUnits.NONE)
.withType(MetricType.COUNTER)
.build();
personalizedGreetingsCounter = registry.counter(metadata);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,14 @@ public void testMetrics() {

}

// TODO Helidon will be delegating exemplar handling to the underlying implementation. This is a work in progress.
private static String valueMatcher(String statName) {
// application_timerForGets_mean_seconds 0.010275403147594316 # {trace_id="cfd13196e6a9fb0c"} 0.002189822 1617799841.963000
return "application_" + GreetService.TIMER_FOR_GETS
+ "_" + statName + "_seconds [\\d\\.]+ # \\{trace_id=\"[^\"]+\"\\} [\\d\\.]+ [\\d\\.]+";
// TODO Following is the original, exemplar-matching pattern. Suppressed temporarily while we migrate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you place the issue number here as part of the follow-up

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update in this PR if there are other, functional, changes as well.

// exemplar support.
// + "_" + statName + "_seconds [\\d\\.]+ # \\{trace_id=\"[^\"]+\"\\} [\\d\\.]+ [\\d\\.]+";
+ "_" + statName + "_seconds [\\d\\.]+.*";
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021 Oracle and/or its affiliates.
# Copyright (c) 2021, 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.
Expand All @@ -21,5 +21,5 @@ config_ordinal=1000
server.port=8080
server.host=0.0.0.0

metrics.registries.0.type = application
metrics.registries.0.scope = application
metrics.registries.0.filter.exclude = .*Gets
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 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.
Expand All @@ -23,6 +23,7 @@

import io.helidon.common.http.Http;
import io.helidon.config.Config;
import io.helidon.metrics.api.Registry;
import io.helidon.metrics.api.RegistryFactory;
import io.helidon.reactive.webserver.Routing;
import io.helidon.reactive.webserver.ServerRequest;
Expand All @@ -36,7 +37,6 @@
import org.eclipse.microprofile.metrics.Counter;
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.eclipse.microprofile.metrics.Timer;

Expand Down Expand Up @@ -81,18 +81,16 @@ public class GreetService implements Service {
this.config = config;
this.appRegistry = appRegistry;
greeting.set(config.get("app.greeting").asString().orElse("Ciao"));
MetricRegistry registry = RegistryFactory.getInstance().getRegistry(MetricRegistry.Type.APPLICATION);
MetricRegistry registry = RegistryFactory.getInstance().getRegistry(Registry.APPLICATION_SCOPE);
Metadata metadata = Metadata.builder()
.withName(TIMER_FOR_GETS)
.withUnit(MetricUnits.NANOSECONDS)
.withType(MetricType.TIMER)
.build();
timerForGets = registry.timer(metadata);

metadata = Metadata.builder()
.withName(COUNTER_FOR_PERSONALIZED_GREETINGS)
.withUnit(MetricUnits.NONE)
.withType(MetricType.COUNTER)
.build();
personalizedGreetingsCounter = registry.counter(metadata);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 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.
Expand All @@ -20,6 +20,7 @@
import io.helidon.config.Config;
import io.helidon.logging.common.LogConfig;
import io.helidon.metrics.api.MetricsSettings;
import io.helidon.metrics.api.Registry;
import io.helidon.metrics.api.RegistryFactory;
import io.helidon.metrics.api.RegistryFilterSettings;
import io.helidon.metrics.api.RegistrySettings;
Expand Down Expand Up @@ -69,7 +70,7 @@ static Single<WebServer> startServer() {
.filterSettings(registryFilterSettingsBuilder);

MetricsSettings.Builder metricsSettingsBuilder = MetricsSettings.builder()
.registrySettings(MetricRegistry.Type.APPLICATION, registrySettingsBuilder.build());
.registrySettings(Registry.APPLICATION_SCOPE, registrySettingsBuilder.build());

WebServer server = WebServer.builder()
.routing(createRouting(config, metricsSettingsBuilder))
Expand Down Expand Up @@ -104,7 +105,7 @@ private static Routing createRouting(Config config, MetricsSettings.Builder metr
.metricsSettings(metricsSettingsBuilder)
.build();
MetricRegistry appRegistry = RegistryFactory.getInstance(metricsSettingsBuilder.build())
.getRegistry(MetricRegistry.Type.APPLICATION);
.getRegistry(Registry.APPLICATION_SCOPE);

GreetService greetService = new GreetService(config, appRegistry);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 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.
Expand All @@ -17,6 +17,7 @@

import java.util.concurrent.atomic.AtomicInteger;

import io.helidon.metrics.api.Registry;
import io.helidon.metrics.api.RegistryFactory;
import io.helidon.reactive.webserver.Routing;
import io.helidon.reactive.webserver.ServerRequest;
Expand All @@ -26,7 +27,6 @@
import org.eclipse.microprofile.metrics.Counter;
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.eclipse.microprofile.metrics.Tag;

Expand Down Expand Up @@ -54,12 +54,10 @@ static HttpStatusMetricService create() {
}

private HttpStatusMetricService() {
MetricRegistry appRegistry = RegistryFactory.getInstance().getRegistry(MetricRegistry.Type.APPLICATION);
MetricRegistry appRegistry = RegistryFactory.getInstance().getRegistry(Registry.APPLICATION_SCOPE);
Metadata metadata = Metadata.builder()
.withName(STATUS_COUNTER_NAME)
.withDisplayName("HTTP response values")
.withDescription("Counts the number of HTTP responses in each status category (1xx, 2xx, etc.)")
.withType(MetricType.COUNTER)
.withUnit(MetricUnits.NONE)
.build();
// Declare the counters and keep references to them.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 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.
Expand All @@ -19,6 +19,7 @@
import java.util.logging.Logger;

import io.helidon.config.Config;
import io.helidon.metrics.api.Registry;
import io.helidon.metrics.api.RegistryFactory;
import io.helidon.reactive.webserver.Routing;
import io.helidon.reactive.webserver.ServerRequest;
Expand All @@ -45,7 +46,7 @@ public class SimpleGreetService implements Service {
private static final JsonBuilderFactory JSON = Json.createBuilderFactory(Collections.emptyMap());

private final MetricRegistry registry = RegistryFactory.getInstance()
.getRegistry(MetricRegistry.Type.APPLICATION);
.getRegistry(Registry.APPLICATION_SCOPE);
private final Counter accessCtr = registry.counter("accessctr");

private final String greeting;
Expand Down
Loading