🔊 Better logging
This commit is contained in:
parent
e231e4d6ae
commit
e105306a6f
@ -5,18 +5,18 @@ meta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get {
|
get {
|
||||||
url: http://localhost:4000/api/metrics/POD-2/WORKLOAD?bucket-unit=DAILY
|
url: http://localhost:4000/api/metrics/analytics-backend-deployment-8695d9f87f-v8n7r/WORKLOAD?bucket-unit=RAW
|
||||||
body: none
|
body: none
|
||||||
auth: basic
|
auth: basic
|
||||||
}
|
}
|
||||||
|
|
||||||
params:query {
|
params:query {
|
||||||
bucket-unit: DAILY
|
bucket-unit: RAW
|
||||||
}
|
}
|
||||||
|
|
||||||
auth:basic {
|
auth:basic {
|
||||||
username: kubooboo
|
username: test
|
||||||
password: password
|
password: test
|
||||||
}
|
}
|
||||||
|
|
||||||
settings {
|
settings {
|
||||||
|
|||||||
@ -26,7 +26,9 @@ body:json {
|
|||||||
"RELATIVE_CPU": "20",
|
"RELATIVE_CPU": "20",
|
||||||
"RELATIVE_MEMORY": "23",
|
"RELATIVE_MEMORY": "23",
|
||||||
"RELATIVE_DISK_USAGE": "56",
|
"RELATIVE_DISK_USAGE": "56",
|
||||||
"TOTAL_DISK_SPACE": "73483209348"
|
"TOTAL_DISK_SPACE": "73483209348",
|
||||||
|
"REQUESTS": "2",
|
||||||
|
"AVERAGE_REQUESTS": "465"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,13 +6,19 @@ import java.util.Optional;
|
|||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.ws.rs.*;
|
import jakarta.ws.rs.*;
|
||||||
|
|
||||||
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import dev.dinauer.metrics.service.client.auth.AuthenticationService;
|
import dev.dinauer.metrics.service.client.auth.AuthenticationService;
|
||||||
import dev.dinauer.metrics.service.model.Bucket;
|
import dev.dinauer.metrics.service.model.Bucket;
|
||||||
import dev.dinauer.metrics.service.model.BucketUnit;
|
import dev.dinauer.metrics.service.model.BucketUnit;
|
||||||
|
import dev.dinauer.metrics.service.utils.Timer;
|
||||||
|
|
||||||
@Path("/{resource}/{metric}")
|
@Path("/{resource}/{metric}")
|
||||||
public class Resource
|
public class Resource
|
||||||
{
|
{
|
||||||
|
@Inject
|
||||||
|
Logger LOG;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
AuthenticationService authenticationService;
|
AuthenticationService authenticationService;
|
||||||
|
|
||||||
@ -24,7 +30,9 @@ public class Resource
|
|||||||
{
|
{
|
||||||
if (authenticationService.canWrite())
|
if (authenticationService.canWrite())
|
||||||
{
|
{
|
||||||
|
Timer timer = Timer.start();
|
||||||
service.index(resource, metric, insert.owner(), insert.values());
|
service.index(resource, metric, insert.owner(), insert.values());
|
||||||
|
LOG.infof("Indexing in %s seconds.", timer.stop());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -37,7 +45,10 @@ public class Resource
|
|||||||
{
|
{
|
||||||
if (authenticationService.canRead())
|
if (authenticationService.canRead())
|
||||||
{
|
{
|
||||||
return service.get(resource, metric, bucketUnit.orElse(BucketUnit.RAW));
|
Timer timer = Timer.start();
|
||||||
|
List<Bucket> buckets = service.get(resource, metric, bucketUnit.orElse(BucketUnit.RAW));
|
||||||
|
LOG.infof("Retrieving %s buckets in %s seconds.", buckets.size(), timer.stop());
|
||||||
|
return buckets;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
21
src/main/java/dev/dinauer/metrics/service/utils/Timer.java
Normal file
21
src/main/java/dev/dinauer/metrics/service/utils/Timer.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package dev.dinauer.metrics.service.utils;
|
||||||
|
|
||||||
|
public class Timer
|
||||||
|
{
|
||||||
|
long start;
|
||||||
|
|
||||||
|
public Timer()
|
||||||
|
{
|
||||||
|
this.start = System.nanoTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Timer start()
|
||||||
|
{
|
||||||
|
return new Timer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double stop()
|
||||||
|
{
|
||||||
|
return (System.nanoTime() - start) / 1_000_000_000.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user