Skip to content

Commit

Permalink
example extended for Micrometer integration
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Nesen <maxim.nesen@oracle.com>
  • Loading branch information
senivam committed Oct 11, 2023
1 parent 35d6897 commit d09ce33
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 52 deletions.
4 changes: 0 additions & 4 deletions examples/micrometer/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ The mapping of the URI path space is presented in the following table:
URI path | Resource class | HTTP methods
------------------------------------------ | ------------------------- | --------------
**_/micro/measure/timed_** | JerseyResource | GET
**_/micro/measure/counted_** | JerseyResource | GET
**_/micro/metrics_** | JerseyResource | GET

Sample Response
Expand All @@ -28,8 +27,6 @@ Sample Response
```html
--- (micro/measure/timed)
Requests to this method are measured. Use /metrics to see more
--- (micro/measure/counted)
Requests to this method are counted. Use /metrics to see more
---- (micro/metrics)
Listing available meters: http.shared.metrics;
----)
Expand All @@ -47,7 +44,6 @@ Run the example using [Grizzly](https://javaee.github.io/grizzly/) container as
- <http://localhost:8080/micro/metrics>
- after few request to the main page go to the url
- - <http://localhost:8080/micro/measure/timed>
- - <http://localhost:8080/micro/measure/counted>
- and see the responses from available resource pages
- then go to the
- - <http://localhost:8080/micro/metrics>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public void run() {
server.start();

System.out.println(String.format("Application started.\nTry out %s%s\n"
+ "After several requests go to %s%s\nAnd after that go to the %s%s\n"
+ "And after that go to the %s%s\n"
+ "Stop the application using CTRL+C",
BASE_URI, ROOT_PATH + "/timed", BASE_URI, ROOT_PATH + "/counted", BASE_URI, "metrics"));
BASE_URI, ROOT_PATH + "/timed", BASE_URI, "metrics"));
Thread.currentThread().join();
} catch (IOException | InterruptedException ex) {
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

package org.glassfish.jersey.examples.micrometer;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.Timer;

Expand Down Expand Up @@ -61,14 +60,6 @@ public String getMeters() {
result.append(String.format("Requests to 'measure/timed' counts: %d, total time (millis): %f \n\r",
annotatedTimer.count(), annotatedTimer.totalTime(TimeUnit.MILLISECONDS)));

//unfortunately the @counted annotation is not supported for the Jersey Integration.
//so, it always shows 0.0 as count() result.
final Counter counter = store.getRegistry().counter(MeasuredCountedResource.COUNTER_NAME,
"method", "GET", "status", "200", "exception", "None",
"outcome", "SUCCESS", "uri", "/micro/measure/counted");

result.append(String.format("Requests to 'measure/counted' counts: %f \n\r",
counter.count()));
} catch (Exception ex) {
result.append("Exception occurred, see log for details...");
result.append(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class MetricsResourceConfig extends ResourceConfig {
public MetricsResourceConfig() {
register(store.getMetricsApplicationEventListener());
register(MeasuredTimedResource.class);
register(MeasuredCountedResource.class);
register(new MetricsResource(store));
}

Expand Down

0 comments on commit d09ce33

Please sign in to comment.