mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-21 21:41:30 +00:00
[AB-184] adding various metrics to the system, organizing imports, changing some transactional behaviour
adding okhttp metrics, split bot service into multiple services (guild, message), unified some places that services are used in order to interact with the api, and not directly the objects (this is to make it easier for metric to be accurate)
This commit is contained in:
15
abstracto-application/core/metrics-interface/pom.xml
Normal file
15
abstracto-application/core/metrics-interface/pom.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>core</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>metrics-interface</artifactId>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,21 @@
|
||||
package dev.sheldan.abstracto.core.metrics.service;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@SuperBuilder
|
||||
@EqualsAndHashCode
|
||||
public class CounterMetric implements Metric {
|
||||
private String name;
|
||||
@Builder.Default
|
||||
private List<MetricTag> tagList = new ArrayList<>();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.sheldan.abstracto.core.metrics.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface Metric {
|
||||
String getName();
|
||||
void setName(String name);
|
||||
List<MetricTag> getTagList();
|
||||
void setTagList(List<MetricTag> tagList);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.abstracto.core.metrics.service;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.ToDoubleFunction;
|
||||
|
||||
public interface MetricService {
|
||||
void registerCounter(CounterMetric counterMetric, String help);
|
||||
void registerGauge(CounterMetric counterMetric, Supplier<Number> f, String help);
|
||||
void registerGauge(CounterMetric counterMetric, Supplier<Number> f, String help, String baseUnit);
|
||||
<T> void registerGauge(CounterMetric counterMetric, T obj, ToDoubleFunction<T> f, String help);
|
||||
<T> void registerGauge(CounterMetric counterMetric, T obj, ToDoubleFunction<T> f, String help, String baseUnit);
|
||||
void incrementCounter(CounterMetric name);
|
||||
void incrementCounter(CounterMetric name, Long amount);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package dev.sheldan.abstracto.core.metrics.service;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class MetricTag {
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
public static MetricTag getTag(String key, String value) {
|
||||
return MetricTag.builder().key(key).value(value).build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user