Giter VIP home page Giter VIP logo

smallrye-metrics's Introduction

Contributing

Want to contribute? Great! We try to make it easy, and all contributions, even the smaller ones, are greatly welcome. This includes bug reports, fixes, documentation.

All SmallRye projects use GitHub Issues to manage issues. Open an issue directly in GitHub within the appropriate SmallRye project repository.

Becoming a Project Committer

Through continued contributions to SmallRye projects, other committers on the project can nominate you to become a committer too!

Check out the nomination process for full details.

All original contributions to SmallRye projects are licensed under the ASL - Apache License, version 2.0 or later, or, if another license is specified as governing the file or directory being modified, such other license.

All contributions are subject to the Developer Certificate of Origin (DCO). The DCO text is also included verbatim in the dco.txt file in the root directory of each repository.

Before you Contribute

To contribute, use GitHub Pull Requests, from your own fork.

Code Reviews

All submissions, including submissions by project members, need to be reviewed before they are merged.

Continuous Integration

We’re all human, so SmallRye projects use continuous integration to ensure consistency, particularly as most SmallRye projects need to pass the applicable MicroProfile TCK for that specification. Each pull request triggers a full build of the project. Please make sure to monitor the output of the build and act accordingly.

Tests and Documentation are not optional

Don’t forget to include tests in your pull requests. Also, don’t forget the documentation (Javadoc).

Setup

If you have not done so on your machine, you need to:

  • Install Git and configure your GitHub access

  • Install Java SDK (OpenJDK recommended)

  • Install Maven

IDE Config and Code Style

SmallRye projects have a strictly enforced code style. Code formatting is done by the Eclipse code formatter, using the config files found in Code Rules. By default when you run mvn install the code will be formatted automatically. When submitting a pull request the CI build will fail if running the formatter results in any code changes, so it is recommended that you always run a full Maven build before submitting a pull request.

Eclipse Setup

Open the Preferences window, and then navigate to JavaCode StyleFormatter. Click Import and then select the eclipse-format.xml file in the coderules directory.

Next navigate to JavaCode StyleOrganize Imports. Click Import and select the eclipse.importorder file.

IDEA Setup

Open the Preferences window, navigate to Plugins and install the [Eclipse Code Formatter Plugin](https://plugins.jetbrains.com/plugin/6546-eclipse-code-formatter).

Restart your IDE, open the Preferences window again and navigate to Other SettingsEclipse Code Formatter.

Select Use the Eclipse Code Formatter, then change the Eclipse Java Formatter Config File to point to the eclipse-format.xml file in the coderules directory. Make sure the Optimize Imports box is ticked, and select the eclipse.importorder file as the import order config file.

Signing Commits

Signing commits is required to make sure that the contributor matches the author. To be able to sign commits, use the following instructions: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

The small print

This project is an open source project, please act responsibly, be nice, polite, and enjoy!

smallrye-metrics's People

Contributors

antoinesd avatar bstansberry avatar channyboy avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar jaikiran avatar jasondlee avatar jmartisk avatar jmesnil avatar kenfinnigan avatar lasrik avatar mcserra avatar michalszynkiewicz avatar mikecroft avatar pe-st avatar pedroigor avatar pilhuhn avatar radcortez avatar sberyozkin avatar smallrye-ci avatar spyrkob avatar thorstenkunz avatar ys-kalyakin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smallrye-metrics's Issues

MetricRegistry.counter("name") fails if a reusable counter "name" already exists

I'm trying to use myMetricRegistry.counter("name.of.the.counter") to get hold of an already existing counter. However, I'm getting an exception: java.lang.IllegalArgumentException: Previously registered metric name.of.the.counter was flagged as reusable, while current request is not. I'm looking at the javadoc of MetricRegistry.counter(String) and my understanding is that if a counter already exists, it should just return it, no matter how it was created.

Lookign at the implementation, it seems to me that the checks performed in MetricsRegistryImpl.get(Metadata, MetricType) in case of an already existing metric are overly restrictive. Even the MetricRegistry.counter(Metadata) method (and it's the same for other kinds of metrics) is documented to "Return the Counter registered under the Metadata's name" (note that it only mentions name, no other characteristics of the metric!).

Histogram - registry.histogram(metadata) - IllegalArgumentException

Histogram - registry.histogram(metadata) returns IllegalArgumentException on second invocation of the endpoint. The same app works fine on Open Liberty.

JavaDoc of public abstract Histogram histogram(Metadata metadata); says @return a new or pre-existing {@link Histogram} so on second invocation I should get the pre-existing histogram.

    @GET
    @Path("/add/{numberOfItems}")
    public Response addItems(@PathParam("numberOfItems") String numberOfItems) {
        Metadata metadata = new Metadata("itemsAdded", MetricType.HISTOGRAM);
        Histogram histogram = registry.histogram(metadata);
        histogram.update(Long.valueOf(numberOfItems));
        return Response.ok().build();
    }

Error:

Caused by: java.lang.IllegalArgumentException:
   Previously registered metric itemsAdded was not flagged as reusable

SmallRye Metrics via WF:

curl http://localhost:8080/hello-prometheus/resources/coffee/add/5
curl http://localhost:8080/hello-prometheus/resources/coffee/add/5
<html><head><title>ERROR</title><style>
...
Caused by: java.lang.IllegalArgumentException: Previously registered metric itemsAdded was not flagged as reusable
...

OpenLiberty

curl http://localhost:9080/hello-prometheus/resources/coffee/add/5
curl http://localhost:9080/hello-prometheus/resources/coffee/add/5
curl http://localhost:9080/hello-prometheus/resources/coffee/add/2
curl http://localhost:9080/hello-prometheus/resources/coffee/add/1

curl https://localhost:9443/metrics/application/itemsAdded -H "Accept: application/json" --insecure -u theUser:thePassword 2>/dev/null | jq
{
  "itemsAdded": {
    "p99": 5,
    "min": 1,
    "max": 5,
    "mean": 3.2434621395610694,
    "count": 4,
    "p50": 2,
    "p999": 5,
    "stddev": 1.7854759159429268,
    "p95": 5,
    "p98": 5,
    "p75": 5
  }
}

curl https://localhost:9443/metrics/application/itemsAdded --insecure -u theUser:thePassword 2>/dev/null | grep -v TYPE | grep -v HELP
application:items_added_mean 3.2434621395610694
application:items_added_max 5.0
application:items_added_min 1.0
application:items_added_stddev 1.7854759159429268
application:items_added_count 4
application:items_added{quantile="0.5"} 2.0
application:items_added{quantile="0.75"} 5.0
application:items_added{quantile="0.95"} 5.0
application:items_added{quantile="0.98"} 5.0
application:items_added{quantile="0.99"} 5.0
application:items_added{quantile="0.999"} 5.0

Code: https://github.com/rsvoboda/rsvoboda-playground/blob/master/microprofile-metrics-hello-prometheus/src/main/java/com/sebastian_daschner/hello_prometheus/CoffeesResource.java#L95

MetricsInterceptor is doing reflection without privileged blocks

... causing issues with metric annotation scanning when SR Metrics is running with security manager enabled

2019-01-10 13:32:29,976 ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
	at java.security.AccessController.checkPermission(AccessController.java:884)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
	at java.lang.Class.checkMemberAccess(Class.java:2348)
	at java.lang.Class.getDeclaredMethods(Class.java:1974)
	at io.smallrye.metrics.interceptors.MetricsInterceptor.metrics(MetricsInterceptor.java:66)
(...)

Make MetricsRegistryImpl more robust

during code review, we identified several improvements in the MetricsRegistryImpl class:

Method removeMatching is iterating over metricMap. If there is a match remove method is called. This method removes entry from metricMap and from metadataMap.
It seems to be a bat pattern that the entry is removed from the map by external method while the map is currently iterated by the removeMatching method.
I think https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html#remove-- should be called in removeMatching for metricMap entry + invocation of metadataMap.remove(entry.getKey()) + log mesasge;

HTTP Verb OPTIONS requires to have Accept header defined, response should provide some guidance about this

HTTP Verb OPTIONS requires to have Accept header defined, response should provide some guidance about this.

I was expecting to get information that json has to be requested in HTTP Accept header, but I received only:

$ curl -X OPTIONS http://$HOST:$PORT/metrics
No exporter found for method OPTIONS and media type

OpenLiberty returns Error 406: CWMMC0000I: The accept header format */* is incorrect. which at least points user to define proper header

This issue originates in https://issues.jboss.org/browse/WFWIP-151

Metrics are improperly unregistered when application is undeployed

The code in

is problement when smallrye-metrics is used in a application server that has a longer lifecycle than application deployment.

Since MetricRegistries is @ApplicationScoped, when the application deployment is undeployed, its cleanUp method is invoked and all 3 registries are cleared (without actually unregistering the metrics inside them btw).

Imagine that an application server that support redeployment is running:

  • its base and vendor metrics are registered
  • when the deployment is deployed, its application metrics are registered
  • during redeployment (i.e. undeploy + deploy), the MetricsRegistries#cleanUp method is invoked
    => there are no longer any base and vendor metrics.

Proposed fix:

The `@ApplicationScoped' MetricRegistries should only clean up the application registry and leave the base and vendor ones untouched when it is destroyed.

In addition, I am not sure that the getBaseRegistry() and getVendorRegistry() should be @ApplicationScoped. By definition, their scope is wider than the application as they provides metrics for the whole base (JVM) and vendor (app server) whose lifecycle is longer than application deployment.

Ambiguous dependencies error when using injection and producers in the same app

When an application contains metric injection as well as metric producers, it will encounter an ambiguous dependencies error.

Example:

    @Inject
    @Metric(name = "injected-counter", absolute = true)
    private Counter counter;

... and in a different class:

    @Produces
    @Metric(name = "producerfield-counter", absolute = true, description = "Counter from producer field.")
    Counter counter = new CounterImpl();

(The injection point and the producer field have to be for the same metric type, in this case it is counter)
If the application contains just one of these two things, it will work fine.

the error looks like this (this is from Thorntail):

019-04-24 12:53:21,376 ERROR [stderr] (main)     Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001409: Ambiguous dependencies for type Counter with qualifiers @Default
2019-04-24 12:53:21,376 ERROR [stderr] (main)   at injection point [BackedAnnotatedField] @Inject @Metric private com.example.metrics.InjectResource.counter
2019-04-24 12:53:21,377 ERROR [stderr] (main)   at com.example.metrics.InjectResource.counter(InjectResource.java:0)
2019-04-24 12:53:21,377 ERROR [stderr] (main)   Possible dependencies: 
2019-04-24 12:53:21,377 ERROR [stderr] (main)   - Producer Method [Counter] with qualifiers [@Any @Default] declared as [[UnbackedAnnotatedMethod] @Produces io.smallrye.metrics.MetricProducer.getCounter(InjectionPoint)],
2019-04-24 12:53:21,377 ERROR [stderr] (main)   - Producer Method [Counter] with qualifiers [@Any @Default] declared as [[BackedAnnotatedMethod] @Produces @Metric com.example.metrics.ProducersMethodsResource.counter()],
2019-04-24 12:53:21,377 ERROR [stderr] (main)   - Producer Field [Counter] with qualifiers [@Any @Default] declared as [[BackedAnnotatedField] @Produces @Metric com.example.metrics.ProducersFieldsResource.counter]
2019-04-24 12:53:21,377 ERROR [stderr] (main) "}}
2019-04-24 12:53:21,377 ERROR [stderr] (main) 	at org.wildfly.swarm.container.runtime.RuntimeDeployer.deploy(RuntimeDeployer.java:296)

Counter - registry.counter(metadata)- IllegalArgumentException

Counter - registry.counter(metadata) returns IllegalArgumentException on second invocation of the endpoint. The same app works fine on Open Liberty.

JavaDoc for counter(Metadata metadata) says @return a new or pre-existing @link Counter.
Second invocation should return the pre-existing counter.

Code:

@GET
@Path("/stats")
public String getTotalDonations() {
    registry.counter(statsHitsCounterMetadata).inc();
    return "12345";
}

Error:

Caused by: java.lang.IllegalArgumentException:
  Previously registered metric statsHits was not flagged as reusable

OpenLiberty:

curl http://localhost:9080/hello-prometheus/resources/coffee/stats
curl http://localhost:9080/hello-prometheus/resources/coffee/stats
curl http://localhost:9080/hello-prometheus/resources/coffee/stats

curl -k -u theUser:thePassword -H "Accept: application/json" https://localhost:9443/metrics/application/statsHits
{"statsHits":3}

https://github.com/rsvoboda/rsvoboda-playground/blob/master/microprofile-metrics-hello-prometheus/src/main/java/com/sebastian_daschner/hello_prometheus/CoffeesResource.java#L106

MetricsRequestHandler expects certain endpoint name length

https://github.com/smallrye/smallrye-metrics/blob/master/implementation/src/main/java/io/smallrye/metrics/MetricsRequestHandler.java#L78 (String scopePath = requestPath.substring(8);) expects certain length of the name of the endpoint which exposes metrics data.

So when I attach metrics data to /me endpoint I get following results

curl  -H "Accept: application/json" 'http://localhost:8080/me/trics'
Bad scope requested: sScope s not found

curl  -H "Accept: application/json" 'http://localhost:8080/me/tricvendor'
{
  "thread.count" : 18,
  "memory.heap.usage" : 154778168,
  "memory.nonHeap.usage" : 55497072
}

curl  -H "Accept: application/json" 'http://localhost:8080/me'
   Internal Server Error
server throws:
java.lang.StringIndexOutOfBoundsException: String index out of range: -5
	at java.lang.String.substring(String.java:1931)
	at io.smallrye.metrics.MetricsRequestHandler.handleRequest(MetricsRequestHandler.java:71)

Metrics exporter should be more robust

Both JSON and Prometheus exporters iterate over the metrics without acknowledging that failures may occur when the value is fetched.
A single Metric that fails will result in a HTTP 500 error.

I think that in that case, that'd be better to remove the failing metric from the export (and log the error) so that other metrics can still be retrieved from the HTTP endpoint.

Can not run Metrics TCK

On my pristine new laptop, I'm not able to run the TCK.
It is passing on semaphore so my issue is likely environmental but I have some doubt.

When I run the tck, it fails with:

$ mvn clean package
...
[INFO] ---------------< io.smallrye:smallrye-metrics-rest-tck >----------------
[INFO] Building SmallRye: MicroProfile Metrics TCK 1.1.2-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ smallrye-metrics-rest-tck ---
[INFO] Deleting /Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ smallrye-metrics-rest-tck ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ smallrye-metrics-rest-tck ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ smallrye-metrics-rest-tck ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ smallrye-metrics-rest-tck ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/test-classes
[INFO]
[INFO] --- maven-dependency-plugin:2.8:unpack (unpack) @ smallrye-metrics-rest-tck ---
[INFO] Configured Artifact: org.wildfly:wildfly-servlet-dist:13.0.0.Final:zip
[INFO] Unpacking /Users/jmesnil/.m2/repository/org/wildfly/wildfly-servlet-dist/13.0.0.Final/wildfly-servlet-dist-13.0.0.Final.zip to /Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target with includes "" and excludes ""
[INFO]
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ smallrye-metrics-rest-tck ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.eclipse.microprofile.metrics.test.MpMetricTest
Sep 27, 2018 2:42:17 PM org.jboss.as.arquillian.container.managed.ManagedDeployableContainer startInternal
WARNING: Bundles path is deprecated and no longer used.
Sep 27, 2018 2:42:17 PM org.jboss.as.arquillian.container.managed.ManagedDeployableContainer startInternal
INFO: Starting container with: [/Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home/bin/java, -D[Standalone], -Xms64m, -Xmx512m, -Djava.net.preferIPv4Stack=true, -Djava.awt.headless=true, -Djboss.modules.system.pkgs=org.jboss.byteman, -ea, -Djboss.home.dir=/Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final, -Dorg.jboss.boot.log.file=/Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final/standalone/log/server.log, -Dlogging.configuration=file:/Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final/standalone/configuration/logging.properties, -jar, /Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final/jboss-modules.jar, -mp, /Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final/modules, org.jboss.as.standalone, -Djboss.home.dir=/Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final, -Djboss.server.base.dir=/Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final/standalone, -Djboss.server.log.dir=/Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final/standalone/log, -Djboss.server.config.dir=/Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final/standalone/configuration]
Sep 27, 2018 2:42:17 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 5.0.0.Final
Sep 27, 2018 2:42:17 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.5.1.Final
Sep 27, 2018 2:42:17 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.5.1.Final
Sep 27, 2018 2:42:17 PM org.wildfly.security.Version <clinit>
INFO: ELY00001: WildFly Elytron version 1.1.0.Final
14:42:18,027 INFO  [org.jboss.modules] (main) JBoss Modules version 1.8.5.Final
14:42:22,146 INFO  [org.jboss.msc] (main) JBoss MSC version 1.4.2.Final
14:42:22,154 INFO  [org.jboss.threads] (main) JBoss Threads version 2.3.2.Final
14:42:22,260 INFO  [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: WildFly Servlet 13.0.0.Final (WildFly Core 5.0.0.Final) starting
14:42:22,835 INFO  [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/core-service=management/management-interface=http-interface' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
14:42:22,854 INFO  [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 11) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/subsystem=undertow/server=default-server/https-listener=https' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
14:42:22,854 INFO  [org.wildfly.security] (ServerService Thread Pool -- 9) ELY00001: WildFly Elytron version 1.3.3.Final
14:42:22,881 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
14:42:22,894 INFO  [org.xnio] (MSC service thread 1-7) XNIO version 3.6.3.Final
14:42:22,901 INFO  [org.xnio.nio] (MSC service thread 1-7) XNIO NIO Implementation Version 3.6.3.Final
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (jar:file:/Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final/modules/system/layers/base/org/jboss/xnio/nio/main/xnio-nio-3.6.3.Final.jar!/) to constructor sun.nio.ch.KQueueSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
14:42:22,926 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 21) WFLYNAM0001: Activating Naming Subsystem
14:42:22,927 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 19) WFLYIO001: Worker 'default' has auto-configured to 24 core threads with 192 task threads based on your 12 available processors
14:42:22,931 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 23) WFLYSEC0002: Activating Security Subsystem
14:42:22,931 INFO  [org.jboss.as.ee] (ServerService Thread Pool -- 17) WFLYEE0119: The system property 'ee8.preview.mode' is NOT set to 'true'. For provided EE 8 APIs where the EE 8 version of the API differs from what is supported in EE 7, the EE 7 variant of the API will be used. Support for this setting will be removed once all EE 8 APIs are provided and certified.
14:42:22,933 INFO  [org.jboss.as.security] (MSC service thread 1-2) WFLYSEC0001: Current PicketBox version=5.0.2.Final
14:42:22,950 INFO  [org.jboss.as.naming] (MSC service thread 1-1) WFLYNAM0003: Starting Naming Service
14:42:22,961 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0003: Undertow 2.0.9.Final starting
14:42:22,964 INFO  [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 5.0.7.Final
14:42:22,988 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 25) WFLYUT0014: Creating file handler for path '/Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
14:42:22,993 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0012: Started server default-server.
14:42:22,995 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) WFLYUT0018: Host default-host starting
14:42:23,041 INFO  [org.jboss.as.patching] (MSC service thread 1-3) WFLYPAT0050: WildFly Servlet cumulative patch ID is: base, one-off patches include: none
14:42:23,050 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
14:42:23,054 WARN  [org.jboss.as.domain.management.security] (MSC service thread 1-8) WFLYDM0111: Keystore /Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final/standalone/configuration/application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
14:42:23,058 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) WFLYDS0013: Started FileSystemDeploymentService for directory /Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final/standalone/deployments
14:42:23,071 WARN  [org.jboss.as.domain.http.api.undertow] (MSC service thread 1-1) WFLYDMHTTP0003: Unable to load console module for slot main, disabling console
14:42:23,108 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
14:42:23,150 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
14:42:23,152 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
14:42:23,152 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
14:42:23,152 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Servlet 13.0.0.Final (WildFly Core 5.0.0.Final) started in 5482ms - Started 137 of 141 services (36 services are lazy, passive or on-demand)
e9e944f7-e20c-406a-935a-bc42ab121c72.jar:
/org/
/org/eclipse/
/org/eclipse/microprofile/
/org/eclipse/microprofile/metrics/
/org/eclipse/microprofile/metrics/test/
/org/eclipse/microprofile/metrics/test/MetricAppBean.class
/META-INF/
/META-INF/beans.xml
14:42:24,600 INFO  [org.jboss.as.repository] (management-handler-thread - 1) WFLYDR0001: Content added at location /Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final/standalone/data/content/fe/dccd5738c8f5fc143e15305d3bf6f592918087/content
14:42:24,616 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0027: Starting deployment of "test.war" (runtime-name: "test.war")
14:42:25,375 INFO  [org.jboss.weld.environment.servletWeldServlet] (ServerService Thread Pool -- 11) WELD-ENV-001008: Initialize Weld using ServletContainerInitializer
14:42:25,384 INFO  [org.jboss.weld.Version] (ServerService Thread Pool -- 11) WELD-000900: 2.4.7 (Final)
14:42:25,461 INFO  [org.jboss.weld.environment.deployment.discovery.DefaultBeanArchiveScanner] (ServerService Thread Pool -- 11) Unable to adapt URL: vfs:/content/test.war/WEB-INF/lib/e9e944f7-e20c-406a-935a-bc42ab121c72.jar/META-INF/beans.xml, using its external form instead
14:42:25,518 INFO  [org.jboss.weld.Bootstrap] (ServerService Thread Pool -- 11) WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
14:42:25,631 INFO  [io.smallrye.metrics] (ServerService Thread Pool -- 11) MicroProfile: Metrics activated
14:42:25,709 INFO  [org.jboss.weld.environment.servletUndertow] (ServerService Thread Pool -- 11) WELD-ENV-001302: Undertow detected, CDI injection will be available in Servlets, Filters and Listeners.
14:42:25,896 INFO  [io.smallrye.metrics] (ServerService Thread Pool -- 11) Converted [2] config entries and added [4] replacements
14:42:25,898 INFO  [io.smallrye.metrics] (ServerService Thread Pool -- 11) Converted [3] config entries and added [18] replacements
14:42:25,922 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 11) WFLYUT0021: Registered web context: '/' for server 'default-server'
14:42:26,366 INFO  [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0010: Deployed "test.war" (runtime-name : "test.war")
14:42:26,670 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 11) WFLYUT0022: Unregistered web context: '/' from server 'default-server'
14:42:26,700 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0028: Stopped deployment test.war (runtime-name: test.war) in 33ms
14:42:26,759 INFO  [org.jboss.as.repository] (management-handler-thread - 1) WFLYDR0002: Content removed from location /Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final/standalone/data/content/fe/dccd5738c8f5fc143e15305d3bf6f592918087/content
14:42:26,759 INFO  [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0009: Undeployed "test.war" (runtime-name: "test.war")
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 9.719 s <<< FAILURE! - in org.eclipse.microprofile.metrics.test.MpMetricTest
[ERROR] org.eclipse.microprofile.metrics.test.MpMetricTest  Time elapsed: 9.718 s  <<< ERROR!
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
        at org.eclipse.microprofile.metrics.test.MpMetricTest.setup(MpMetricTest.java:101)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
        at org.eclipse.microprofile.metrics.test.MpMetricTest.setup(MpMetricTest.java:101)

[INFO] Running org.eclipse.microprofile.metrics.test.ReusableMetricsTest
14:42:27,319 INFO  [org.jboss.as.repository] (management-handler-thread - 1) WFLYDR0001: Content added at location /Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final/standalone/data/content/c8/757a98bdbe8979b0c41f20a8ade55be56432e6/content
14:42:27,326 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "test.war" (runtime-name: "test.war")
14:42:27,784 INFO  [org.jboss.weld.environment.servletWeldServlet] (ServerService Thread Pool -- 9) WELD-ENV-001008: Initialize Weld using ServletContainerInitializer
14:42:27,793 INFO  [org.jboss.weld.Version] (ServerService Thread Pool -- 9) WELD-000900: 2.4.7 (Final)
14:42:27,817 INFO  [org.jboss.weld.environment.deployment.discovery.DefaultBeanArchiveScanner] (ServerService Thread Pool -- 9) Unable to adapt URL: vfs:/content/test.war/WEB-INF/lib/d23cf348-a136-44c0-9a0e-8142a55ceb56.jar/META-INF/beans.xml, using its external form instead
14:42:27,857 INFO  [org.jboss.weld.Bootstrap] (ServerService Thread Pool -- 9) WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
14:42:27,963 INFO  [io.smallrye.metrics] (ServerService Thread Pool -- 9) MicroProfile: Metrics activated
14:42:28,019 INFO  [org.jboss.weld.environment.servletUndertow] (ServerService Thread Pool -- 9) WELD-ENV-001302: Undertow detected, CDI injection will be available in Servlets, Filters and Listeners.
14:42:28,187 INFO  [io.smallrye.metrics] (ServerService Thread Pool -- 9) Converted [2] config entries and added [4] replacements
14:42:28,189 INFO  [io.smallrye.metrics] (ServerService Thread Pool -- 9) Converted [3] config entries and added [18] replacements
14:42:28,190 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 9) WFLYUT0021: Registered web context: '/' for server 'default-server'
14:42:28,230 INFO  [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0010: Deployed "test.war" (runtime-name : "test.war")
14:42:28,242 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 9) WFLYUT0022: Unregistered web context: '/' from server 'default-server'
14:42:28,269 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0028: Stopped deployment test.war (runtime-name: test.war) in 28ms
14:42:28,280 INFO  [org.jboss.as.repository] (management-handler-thread - 1) WFLYDR0002: Content removed from location /Users/jmesnil/Developer/smallrye-metrics/testsuite/rest-tck/target/wildfly-servlet-13.0.0.Final/standalone/data/content/c8/757a98bdbe8979b0c41f20a8ade55be56432e6/content
14:42:28,280 INFO  [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0009: Undeployed "test.war" (runtime-name: "test.war")
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.486 s <<< FAILURE! - in org.eclipse.microprofile.metrics.test.ReusableMetricsTest
[ERROR] org.eclipse.microprofile.metrics.test.ReusableMetricsTest  Time elapsed: 1.485 s  <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class com.jayway.restassured.RestAssured
        at org.eclipse.microprofile.metrics.test.ReusableMetricsTest.setup(ReusableMetricsTest.java:75)

14:42:28,289 INFO  [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0236: Suspending server with no timeout.
14:42:28,290 INFO  [org.jboss.as.server] (Management Triggered Shutdown) WFLYSRV0241: Shutting down in response to management operation 'shutdown'
14:42:28,298 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) WFLYUT0008: Undertow HTTP listener default suspending
14:42:28,299 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0008: Undertow HTTPS listener https suspending
14:42:28,301 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0019: Host default-host stopping
14:42:28,304 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-3) WFLYUT0007: Undertow HTTP listener default stopped, was bound to 127.0.0.1:8080
14:42:28,304 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0007: Undertow HTTPS listener https stopped, was bound to 127.0.0.1:8443
14:42:28,306 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0004: Undertow 2.0.9.Final stopping
14:42:28,316 INFO  [org.jboss.as] (MSC service thread 1-6) WFLYSRV0050: WildFly Servlet 13.0.0.Final (WildFly Core 5.0.0.Final) stopped in 20ms
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR]   MpMetricTest.setup:101 » NoClassDefFound javax/xml/bind/JAXBException
[ERROR]   ReusableMetricsTest.setup:75 NoClassDefFound Could not initialize class com.ja...
[INFO]
[ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.190 s
[INFO] Finished at: 2018-09-27T14:42:28+02:00
[INFO] ------------------------------------------------------------------------

The NoClassDefFound error on com.jayway.restassured.RestAssured seems genuine to me.
The dependency to com.jayway.restassured:rest-assured in the Metrics TCK is using the compile scope:

$ mvn dependency:tree
...
[INFO] +- org.eclipse.microprofile.metrics:microprofile-metrics-rest-tck:jar:1.1:compile
[INFO] |  +- com.jayway.restassured:rest-assured:jar:2.4.0:compile

That seems normal that the class is not found at runtime during the test.

SmallRye: MicroProfile Metrics TCK execution fails on Java 11

SmallRye: MicroProfile Metrics TCK execution fails on Java 11

org.jboss.arquillian.container.spi.client.container.LifecycleException: 
  The java process starting the managed server exited unexpectedly with code [1]

org.jboss.modules.ModuleNotFoundException: java.se

This exception usually means that --add-modules=java.se needs to be added to invoked process

Fix time unit conversion

While monitoring the jvm.uptime I found out that smallrye-metrics incorrectly convert time metrics in the prometheus exporter.

E.g. with JSON:

$ curl -H "accept: application/json" http://127.0.0.1:9990/metrics/base/jvm.uptime
{  "jvm.uptime" : 12628
}

=> uptime is 12682 (in milliseconds)

and then just after with Prometheus output:

$ curl http://127.0.0.1:9990/metrics/base/jvm.uptime
# HELP base:jvm_uptime_seconds Displays the start time of the Java virtual machine in milliseconds. This attribute displays the approximate time when the Java virtual machine started.
# TYPE base:jvm_uptime_seconds gauge
base:jvm_uptime_seconds 1.3629E-5

=> uptime is reported as 1.3629E-5 (in seconds)
This is not corrected, the reported value in seconds should be 13.629' (i.e 13629ms)

The code in PrometheusUnit#scaleToBase is not correct as it expects the value to be always in nanoseconds but the value unit may differ (e.g. for jvm.uptime it is in milliseconds).

Ugly JSON output format when exporting multiple scopes

It does something like this (reproduce with curl -H"Accept: application/json" localhost:8080/metrics):

{"application" :
{
  "Greetings count" : 1
}
,"base" :
{
  "classloader.totalLoadedClass.count" : 13259,
  "cpu.systemLoadAverage" : 1.01,
  "thread.count" : 55,
  "classloader.currentLoadedClass.count" : 13231,
  "jvm.uptime" : 40531,
  "gc.PS MarkSweep.count" : 3,
  "memory.committedHeap" : 1497366528,
  "thread.max.count" : 84,
  "gc.PS Scavenge.count" : 9,
  "cpu.availableProcessors" : 8,
  "thread.daemon.count" : 9,
  "classloader.totalUnloadedClass.count" : 28,
  "memory.maxHeap" : 7369392128,
  "memory.usedHeap" : 275541176,
  "gc.PS MarkSweep.time" : 267,
  "gc.PS Scavenge.time" : 112
}
.....

MetricsRegistryImpl.register(Metadata, T) ignores Metadata.tags

Hi!

I'm using smallrye-metrics as part of wildfly 15 and noticed that I cannot have multiple instances of a metric (with the same name) distinguished only by tags. For example, with the original prometheus implementation allows for measuring load-times per page by means of a servlet filter, which uses one and the same metric but with different tag values to distinguish between multiple URLs.

According to the spec for 1.1.1 MetricsRegistry.register(Metadata, T) is supposed to "register it under the provided Metadata". Wouldn't that include tags as well?

metric registration log spam

I often see a lot of log messages about metric registration, such as

Kvě 20, 2019 6:15:58 ODP. io.smallrye.metrics.MetricsRegistryImpl get
INFO: Register metric [metricId: MetricID{name='ft.org.eclipse.microprofile.fault.tolerance.tck.fallback.clientserver.FallbackOnlyClient.serviceB.fallback.calls.total', tags=[]}, type: counter]

I consider them log spam. Is the INFO level intentional? I'd personally say it should be DEBUG.

(1.1.x) Unit is appended to counters in Prometheus exporter

Definition:

@Counted(name = "metricTest.test1.countMeB", monotonic = true, absolute = true, unit = "jellybean")
public long countMeB() {
    return 666666;
}

Spec says:

Implementors must not convert the unit of Counters or append the unit suffix to the metric.

Prometheus export - expected:
TYPE application:metric_test_test1_count_me_b counter

Prometheus export - actual:
TYPE application:metric_test_test1_count_me_b_jellybean counter

2.0 requires a _total suffix instead, this will be handled separately.
For 1.1 this is covered by TCK test coming from eclipse/microprofile-metrics#295

Wrong name translation in OpenMetrics export if metric name ends with _total

The specification says this about OpenMetrics export of counters:

The exposed metric name must have a _total suffix. The suffix is not appended if the (translated) original metric name already ends in _total.

However, in the current implementation, we check for _total at the end of the original metric name, not the translated name, so if a metric name ends with (for example) .total, the _total will still be appeneded and the key in the OpenMetrics export will end with _total_total.

snake case conversion is not producing expected name

In the Prometheus exporter, the MP Metric name is converted to snake case to match Prometheus format.

However, while testing it, I found out that there were issues when the metric name was having succeeding upper case characters:

  • FRAG3 became f_ra_g3
  • UNICAST3 became u_ni_ca_st3

The conversion should be fixed to output correct snake case names (in my case, frag3 and unicast3).

The type casts in the exporters are too restrictive

For the types METERED, TIMER and HISTOGRAM the type casts in

  • io.smallrye.metrics.exporters.JsonExporter#writeMetricsForMap and
  • io.smallrye.metrics.exporters.PrometheusExporter#exposeEntries

are too strict, they allow only the XxxImpl types, but an application might want to register another metrics type implementing the given interfaces.

Collapse TCK modules into one, or rename

Not sure if there's a particular reason for /testsuite/api and testsuite/rest being separate as their all part of TCK testing.

If it's necessary for them to be separate, I would suggest renaming to /api-tck and /rest-tck.

Otherwise I would collapse them both into a single /testsuite/tck

Eager initialization of metrics

Currently, metrics from annotated methods are initialized only when their CDI bean is first constructed. This is bad especially for Quarkus where we try to initialize as much as possible at build time.
Problem will probably remain with Gauges which need to be tied to a particular bean instance, but we shouldn't eagerly instantiate application's CDI beans just for the sake of being able to register a gauge. Either we find a solution how to register a gauge but 'bind' it to an object later at runtime, or we leave gauges out of this and keep their registration lazy.

HTTP code change to be considered for unsupported request types

When using unsupported request type - e.g. PUT I receive HTTP/1.1 406 Not Acceptable, OpenLiberty returns HTTP/1.1 405 Method Not Allowed which feels more appropriate.

curl https://localhost:9443/metrics/ --insecure -u theUser:thePassword -X PUT
Error 405: CWMMC0001I: The method request type must be GET or OPTIONS.

Spec speaks only about 404 and 406.

  • 404 if a directly-addressed item does not exist. This may be a non-existing sub-tree or non- existing object
  • 406 if the HTTP Accept Header in the request cannot be handled by the server.

But 406 only mentions Accept Header, not the HTTP request methods.
I think smallrye-metrics should be safe (from spec perspective) to switch from 406 Not Acceptable to 405 Method Not Allowed for not allowed HTTP request methods.

This is slightly related to #32
This issue originates in https://issues.jboss.org/browse/WFWIP-152

Metered - difference between Prometheus and JSON format

There are differences in reported results between Prometheus and JSON format.
When using the same deployment with OpenLiberty there are no differences in reported results between Prometheus and JSON format.

Code:

    @Metered(name = "itemsSold",
            unit = MetricUnits.MINUTES,
            description = "Metrics to monitor sold method - @Metered.",
            absolute = true)
    @GET
    @Path("/sold")
    public Response itemSold() {
        return Response.ok().build();
}

SmallRye Metrics via WF:

$ curl http://127.0.0.1:9990/metrics/application/itemsSold -H "Accept: application/json"
{  "itemsSold" : {
    "count": 2,
    "meanRate": 0.04008729595250973,
    "oneMinRate": 0.10268342380651845,
    "fiveMinRate": 0.1750346638085895,
    "fifteenMinRate": 0.19130574782060583
  }}

$ curl http://127.0.0.1:9990/metrics/application/itemsSold 2>/dev/null | grep -v TYPE | grep -v HELP
application:items_sold_total 120.0
application:items_sold_rate_per_second 2.394402679418024
application:items_sold_one_min_rate_per_second 6.6278656573403
application:items_sold_five_min_rate_per_second 10.526838271241285
application:items_sold_fifteen_min_rate_per_second 11.481234917949807

OpenLiberty:

curl https://localhost:9443/metrics/application/itemsSold -H "Accept: application/json" --insecure -u theUser:thePassword 2>/dev/null | jq
{
  "itemsSold": {
    "fiveMinRate": 0.1934432200964012,
    "fifteenMinRate": 0.19779007785878447,
    "meanRate": 0.12195642084943523,
    "count": 2,
    "oneMinRate": 0.16929634497812282
  }
}

$ curl https://localhost:9443/metrics/application/itemsSold --insecure -u theUser:thePassword 2>/dev/null | grep -v TYPE | grep -v HELP
application:items_sold_total 2
application:items_sold_rate_per_second 0.12012122656287032
application:items_sold_one_min_rate_per_second 0.16929634497812282
application:items_sold_five_min_rate_per_second 0.1934432200964012
application:items_sold_fifteen_min_rate_per_second 0.19779007785878447

Code: https://github.com/rsvoboda/rsvoboda-playground/blob/master/microprofile-metrics-hello-prometheus/src/main/java/com/sebastian_daschner/hello_prometheus/CoffeesResource.java#L47

moving scope into metrics metadata?

What is the rationale between having base:, vendor: and application: prefix in the Prometheus output format?

I have a system with existing "vendor" metrics exposed to Prometheus directly. I would like to use smallrye-metrics but preserve my metric names.
Ideally, I'd prefer to have the microprofile-metrics scope being a label attached to the metrics, so that instead of:

vendor:my_existing_metric{foo="bar"}

I would have something like:

my_existing_metric{foo="bar", microprofile-scope="vendor"}

Timed - difference between Prometheus and JSON format

There are differences in reported results between Prometheus and JSON format.
When using the same deployment with OpenLiberty there are no differences in reported results between Prometheus and JSON format.

Code

    @Timed(name = "itemsProcessed",
            description = "Metrics to monitor the times of processItem method. - @Timed",
            unit = MetricUnits.MINUTES,
            absolute = true)
    @GET
    @Path("/process")
    public Response processItem() {
        return Response.ok().build();
    }

SmallRye Metrics via WF:

curl http://127.0.0.1:9990/metrics/application/itemsProcessed -H "Accept: application/json"
{  "itemsProcessed" : {
    "p50": 5.619833333333334E-7,
    "p75": 5.619833333333334E-7,
    "p95": 5.619833333333334E-7,
    "p98": 5.619833333333334E-7,
    "p99": 5.619833333333334E-7,
    "p999": 5.619833333333334E-7,
    "min": 5.619833333333334E-7,
    "mean": 5.619833333333334E-7,
    "max": 5.619833333333334E-7,
    "stddev": 0.0,
    "count": 1,
    "meanRate": 7.975289185818699E-4,
    "oneMinRate": 0.0,
    "fiveMinRate": 0.0,
    "fifteenMinRate": 0.0
  }}

curl http://127.0.0.1:9990/metrics/application/itemsProcessed 2>/dev/null | grep -v TYPE | grep -v HELP
application:items_processed_rate_per_second 0.04784228234858272
application:items_processed_one_min_rate_per_second 0.0
application:items_processed_five_min_rate_per_second 0.0
application:items_processed_fifteen_min_rate_per_second 0.0
application:items_processed_min_seconds 2023140.0
application:items_processed_max_seconds 2023140.0
application:items_processed_mean_seconds 2023140.0
application:items_processed_stddev_seconds 0.0
application:items_processed_seconds_count 1.0
application:items_processed_seconds{quantile="0.5"} 2023140.0
application:items_processed_seconds{quantile="0.75"} 2023140.0
application:items_processed_seconds{quantile="0.95"} 2023140.0
application:items_processed_seconds{quantile="0.98"} 2023140.0
application:items_processed_seconds{quantile="0.99"} 2023140.0
application:items_processed_seconds{quantile="0.999"} 2023140.0

OpenLiberty:

curl https://localhost:9443/metrics/application/itemsProcessed -H "Accept: application/json" --insecure -u theUser:thePassword 2>/dev/null | jq
{
  "itemsProcessed": {
    "fiveMinRate": 0,
    "max": 38369,
    "count": 1,
    "p50": 38369,
    "p95": 38369,
    "p98": 38369,
    "p75": 38369,
    "p99": 38369,
    "min": 38369,
    "fifteenMinRate": 0,
    "meanRate": 0.0007829386932720206,
    "mean": 38369,
    "p999": 38369,
    "oneMinRate": 0,
    "stddev": 0
  }
}

curl https://localhost:9443/metrics/application/itemsProcessed --insecure -u theUser:thePassword 2>/dev/null | grep -v TYPE | grep -v HELP
application:items_processed_rate_per_second 7.827878570352143E-4
application:items_processed_one_min_rate_per_second 0.0
application:items_processed_five_min_rate_per_second 0.0
application:items_processed_fifteen_min_rate_per_second 0.0
application:items_processed_mean_seconds 3.8369000000000005E-5
application:items_processed_max_seconds 3.8369000000000005E-5
application:items_processed_min_seconds 3.8369000000000005E-5
application:items_processed_stddev_seconds 0.0
application:items_processed_seconds_count 1
application:items_processed_seconds{quantile="0.5"} 3.8369000000000005E-5
application:items_processed_seconds{quantile="0.75"} 3.8369000000000005E-5
application:items_processed_seconds{quantile="0.95"} 3.8369000000000005E-5
application:items_processed_seconds{quantile="0.98"} 3.8369000000000005E-5
application:items_processed_seconds{quantile="0.99"} 3.8369000000000005E-5
application:items_processed_seconds{quantile="0.999"} 3.8369000000000005E-5

Code: https://github.com/rsvoboda/rsvoboda-playground/blob/master/microprofile-metrics-hello-prometheus/src/main/java/com/sebastian_daschner/hello_prometheus/CoffeesResource.java#L69

Reuse of annotation based metrics is accepted even without reusability flag

Bean with such metrics will be accepted even though it should not:

    @Counted(name = "countedMethod", absolute = true)
    public void countedMethodOne() {
    }

    @Counted(name = "countedMethod", absolute = true)
    public void countedMethodOne2() {
    }

The problem is that OriginTrackedMetadata only tracks the annotation itself and doesn't track the place (AnnotatedElement) where the annotation is used, so with declarations like this (where the annotations have exactly the same content), the haveCompatibleOrigins check will pass.

Prometheus endpoint does not provide metric name

While playing with the jvm.uptime metric, I noticed that the Prometheus endpoint does not contain the actual name of the metric.

$ curl http://127.0.0.1:9990/metrics/base/
...
# HELP base:jvm_uptime_seconds Displays the start time of the Java virtual machine in milliseconds. This attribute displays the approximate time when the Java virtual machine started.
# TYPE base:jvm_uptime_seconds gauge
base:jvm_uptime_seconds 3.277E-4
...

When I tried to get the metric only for `jvm.uptime, I tried the name from the previous result:

$ curl http://127.0.0.1:9990/metrics/base/jvm_uptime_seconds
Metric base/jvm_uptime_seconds not found
$ curl http://127.0.0.1:9990/metrics/base/jvm_uptime
Metric base/jvm_uptime not found

It turns ou that I need to use the original metric name jvm.uptime (which is obvious in retrospect):

$ curl http://127.0.0.1:9990/metrics/base/jvm.uptime
# HELP base:jvm_uptime_seconds Displays the start time of the Java virtual machine in milliseconds. This attribute displays the approximate time when the Java virtual machine started.
# TYPE base:jvm_uptime_seconds gauge
base:jvm_uptime_seconds 1.43104E-4

However there is no way to know the actual metric name from the Prometheus output itself as the metrics/base endpoint only mentions jvm_uptime_seconds and never jvm.uptime.

Could we improve somehow the Prometheus export format so that it is possible to drill down the metric from their scope without having to mentally convert the metric name from MicroProfile to the Prometheus one according to the spec (section 3.2.1. Translation rules for metric names)?

(2.0) Unit and description not taken into account for metrics from producers

@Gauge(unit = "USD", name = "coffee_price", absolute = true)
public long getPrice() {
    return 4;
}

@Produces
@Metric(name = "coffee_price_produces", unit = "USD", absolute = true)
protected Gauge<Long> getPrice2() {
    return () -> 4L;
}

These declarations should be equivalent, but the latter doesn't take the unit into account at runtime.

curl -H"Accept: application/json" -X OPTIONS localhost:8080/metrics/application/coffee_price_produces
{
    "coffee_price_produces":{
        "unit":"none",
        "type":"gauge",
        "displayName":"coffee_price_produces",
        "tags":""
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.