Java Code Examples for org.eclipse.microprofile.metrics.MetricUnits#MILLISECONDS
The following examples show how to use
org.eclipse.microprofile.metrics.MetricUnits#MILLISECONDS .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BookStoreEndpoint.java From ebook-Building-an-API-Backend-with-MicroProfile with Apache License 2.0 | 6 votes |
@APIResponses( value = { @APIResponse( responseCode = "404", description = "We could not find anything", content = @Content(mediaType = "text/plain")) , @APIResponse( responseCode = "200", description = "We have a list of books", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Properties.class)))}) @Operation(summary = "Outputs a list of books", description = "This method outputs a list of books") @Timed(name = "get-all-books", description = "Monitor the time getAll Method takes", unit = MetricUnits.MILLISECONDS, absolute = true) @GET public Response getAll() { return Response.ok(bookService.getAll()).build(); }
Example 2
Source File: TodoResource.java From quarkus-deep-dive with Apache License 2.0 | 6 votes |
@PATCH @Path("/{id}") @Transactional @Counted(name = "updateCount", monotonic = true, description = "How many update calls have been done.") @Timed(name = "updateTime", description = "How long does the update method takes.", unit = MetricUnits.MILLISECONDS) public Response update(@Valid Todo todo, @PathParam("id") Long id) { Todo entity = Todo.findById(id); if (entity == null) { throw new WebApplicationException("Item with id of " + id + " does not exist.", 404); } entity.id = id; entity.completed = todo.completed; entity.order = todo.order; entity.title = todo.title; entity.url = todo.url; return Response.ok(entity).build(); }
Example 3
Source File: BookStoreEndpoint.java From ebook-Building-an-API-Backend-with-MicroProfile with Apache License 2.0 | 5 votes |
@Metered(name = "create-books", unit = MetricUnits.MILLISECONDS, description = "Monitor the rate events occured", absolute = true) @POST public Response create(Book book) { bookService.create(book); return Response.ok().build(); }
Example 4
Source File: TodoResource.java From quarkus-deep-dive with Apache License 2.0 | 5 votes |
@GET @Counted(name = "getAllCount", monotonic = true, description = "How many getAll calls have been done.") @Timed(name = "getAllTime", description = "How long does the getAll method takes.", unit = MetricUnits.MILLISECONDS) public List<Todo> getAll() { return Todo.listAll(Sort.by("order")); }
Example 5
Source File: TodoResource.java From quarkus-deep-dive with Apache License 2.0 | 5 votes |
@POST @Transactional @Counted(name = "createCount", monotonic = true, description = "How many create calls have been done.") @Timed(name = "createTime", description = "How long does the create method takes.", unit = MetricUnits.MILLISECONDS) public Response create(@Valid Todo item) { item.persist(); return Response.status(Status.CREATED).entity(item).build(); }
Example 6
Source File: TodoResource.java From quarkus-deep-dive with Apache License 2.0 | 5 votes |
@DELETE @Transactional @Counted(name = "deleteCompletedCount", monotonic = true, description = "How many deleteCompleted calls have been done.") @Timed(name = "deleteCompletedTime", description = "How long does the deleteCompleted method takes.", unit = MetricUnits.MILLISECONDS) public Response deleteCompleted() { Todo.deleteCompleted(); return Response.noContent().build(); }
Example 7
Source File: TodoResource.java From quarkus-deep-dive with Apache License 2.0 | 5 votes |
@DELETE @Transactional @Path("/{id}") @Counted(name = "deleteOneCount", monotonic = true, description = "How many deleteOne calls have been done.") @Timed(name = "deleteOneTime", description = "How long does the deleteOne method takes.", unit = MetricUnits.MILLISECONDS) public Response deleteOne(@PathParam("id") Long id) { Todo entity = Todo.findById(id); if (entity == null) { throw new WebApplicationException("Todo with id of " + id + " does not exist.", Status.NOT_FOUND); } entity.delete(); return Response.noContent().build(); }
Example 8
Source File: PrimeNumberChecker.java From quarkus-quickstarts with Apache License 2.0 | 5 votes |
@GET @Path("/{number}") @Produces("text/plain") @Counted(name = "performedChecks", description = "How many primality checks have been performed.") @Timed(name = "checksTimer", description = "A measure how long it takes to perform the primality test.", unit = MetricUnits.MILLISECONDS) public String checkIfPrime(@PathParam long number) { if (number < 1) { return "Only natural numbers can be prime numbers."; } if (number == 1) { return "1 is not prime."; } if (number == 2) { return "2 is prime."; } if (number % 2 == 0) { return number + " is not prime, it is divisible by 2."; } for (int i = 3; i < Math.floor(Math.sqrt(number)) + 1; i = i + 2) { if (number % i == 0) { return number + " is not prime, is divisible by " + i + "."; } } if (number > highestPrimeNumberSoFar) { highestPrimeNumberSoFar = number; } return number + " is prime."; }
Example 9
Source File: ExporterUtil.java From smallrye-metrics with Apache License 2.0 | 5 votes |
public static Double convertNanosTo(Double value, String unit) { Double out; switch (unit) { case MetricUnits.NANOSECONDS: out = value; break; case MetricUnits.MICROSECONDS: out = value / NANOS_PER_MICROSECOND; break; case MetricUnits.MILLISECONDS: out = value / NANOS_PER_MILLI; break; case MetricUnits.SECONDS: out = value / NANOS_PER_SECOND; break; case MetricUnits.MINUTES: out = value / NANOS_PER_MINUTE; break; case MetricUnits.HOURS: out = value / NANOS_PER_HOUR; break; case MetricUnits.DAYS: out = value / NANOS_PER_DAY; break; default: out = value; } return out; }
Example 10
Source File: OpenMetricsUnitScalingTest.java From smallrye-metrics with Apache License 2.0 | 5 votes |
@Test public void testFindBaseUnit2() { String foo = MetricUnits.MILLISECONDS; String out = OpenMetricsUnit.getBaseUnitAsOpenMetricsString(Optional.ofNullable(foo)); assertEquals(MetricUnits.SECONDS, out); String promUnit = OpenMetricsUnit.getBaseUnitAsOpenMetricsString(Optional.ofNullable(out)); assertEquals("seconds", promUnit); }
Example 11
Source File: CustomerEndpoint.java From Hands-On-Cloud-Native-Applications-with-Java-and-Quarkus with MIT License | 4 votes |
@GET @Counted(description = "Customer list count", absolute = true) @Timed(name = "timerCheck", description = "How much time it takes to load the Customer list", unit = MetricUnits.MILLISECONDS) public List<Customer> getAll() { return customerRepository.findAll(); }
Example 12
Source File: HelloService.java From smallrye-metrics with Apache License 2.0 | 4 votes |
@Timed(unit = MetricUnits.MILLISECONDS, name = "howdy-time", absolute = true, displayName = "Howdy Time", description = "Time of howdy invocations") public String howdy() { return "Howdy from timed method"; }
Example 13
Source File: OpenMetricsUnit.java From smallrye-metrics with Apache License 2.0 | 4 votes |
/** * Determines the basic unit to be used by OpenMetrics exporter based on the input unit from parameter. * That is: * - for memory size units, returns "bytes" * - for time units, returns "seconds" * - for any other unit, returns the input unit itself */ public static String getBaseUnitAsOpenMetricsString(Optional<String> optUnit) { if (!optUnit.isPresent()) { return MetricUnits.NONE; } String unit = optUnit.get(); String out; switch (unit) { /* Represents bits. Not defined by SI, but by IEC 60027 */ case MetricUnits.BITS: /* 1000 {@link #BITS} */ case MetricUnits.KILOBITS: /* 1000 {@link #KIBIBITS} */ case MetricUnits.MEGABITS: /* 1000 {@link #MEGABITS} */ case MetricUnits.GIGABITS: /* 1024 {@link #BITS} */ case MetricUnits.KIBIBITS: /* 1024 {@link #KIBIBITS} */ case MetricUnits.MEBIBITS: /* 1024 {@link #MEBIBITS} */ case MetricUnits.GIBIBITS: /* 8 {@link #BITS} */ case MetricUnits.BYTES: /* 1000 {@link #BYTES} */ case MetricUnits.KILOBYTES: /* 1000 {@link #KILOBYTES} */ case MetricUnits.MEGABYTES: /* 1000 {@link #MEGABYTES} */ case MetricUnits.GIGABYTES: out = "bytes"; break; /* 1/1000 {@link #MICROSECONDS} */ case MetricUnits.NANOSECONDS: /* 1/1000 {@link #MILLISECONDS} */ case MetricUnits.MICROSECONDS: /* 1/1000 {@link #SECONDS} */ case MetricUnits.MILLISECONDS: /* Represents seconds */ case MetricUnits.SECONDS: /* 60 {@link #SECONDS} */ case MetricUnits.MINUTES: /* 60 {@link #MINUTES} */ case MetricUnits.HOURS: /* 24 {@link #HOURS} */ case MetricUnits.DAYS: out = "seconds"; break; default: out = unit; } return out; }
Example 14
Source File: HelloMetricsClient.java From thorntail with Apache License 2.0 | 4 votes |
@Timed(unit = MetricUnits.MILLISECONDS, name = TIMED_NAME, absolute = true) @GET @Path("/hello") String helloTimed();
Example 15
Source File: HelloService.java From thorntail with Apache License 2.0 | 4 votes |
@Timed(unit = MetricUnits.MILLISECONDS, name = "howdy-time", absolute = true, displayName = "Howdy Time", description = "Time of howdy invocations") public String howdy() { return "Howdy from timed method"; }