-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Observability extension - PromQL client, devservices, etc
- Loading branch information
Showing
124 changed files
with
5,379 additions
and
15 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
core/runtime/src/main/java/io/quarkus/runtime/util/EnumerationUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package io.quarkus.runtime.util; | ||
|
||
import java.util.Enumeration; | ||
import java.util.Iterator; | ||
import java.util.NoSuchElementException; | ||
import java.util.Objects; | ||
import java.util.Spliterator; | ||
import java.util.function.Consumer; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* Transform to "old school" Enumeration from Iterator/Spliterator/Stream | ||
*/ | ||
public class EnumerationUtil { | ||
public static <T> Enumeration<T> from(Iterator<T> iterator) { | ||
Objects.requireNonNull(iterator); | ||
|
||
return new Enumeration<T>() { | ||
@Override | ||
public boolean hasMoreElements() { | ||
return iterator.hasNext(); | ||
} | ||
|
||
@Override | ||
public T nextElement() { | ||
return iterator.next(); | ||
} | ||
}; | ||
} | ||
|
||
public static <T> Enumeration<T> from(Spliterator<T> spliterator) { | ||
Objects.requireNonNull(spliterator); | ||
|
||
class Adapter implements Enumeration<T>, Consumer<T> { | ||
boolean valueReady; | ||
T nextElement; | ||
|
||
public void accept(T t) { | ||
this.valueReady = true; | ||
this.nextElement = t; | ||
} | ||
|
||
public boolean hasMoreElements() { | ||
if (!this.valueReady) { | ||
spliterator.tryAdvance(this); | ||
} | ||
|
||
return this.valueReady; | ||
} | ||
|
||
public T nextElement() { | ||
if (!this.valueReady && !this.hasMoreElements()) { | ||
throw new NoSuchElementException(); | ||
} else { | ||
this.valueReady = false; | ||
T t = this.nextElement; | ||
this.nextElement = null; | ||
return t; | ||
} | ||
} | ||
} | ||
|
||
return new Adapter(); | ||
} | ||
|
||
public static <T> Enumeration<T> from(Stream<T> stream) { | ||
return from(stream.spliterator()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>quarkus-observability-parent</artifactId> | ||
<groupId>io.quarkus</groupId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>quarkus-observability-common</artifactId> | ||
<name>Quarkus - Observability - Common</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-core</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.smallrye.config</groupId> | ||
<artifactId>smallrye-config-core</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
10 changes: 10 additions & 0 deletions
10
...bservability/common/src/main/java/io/quarkus/observability/common/ContainerConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.quarkus.observability.common; | ||
|
||
public final class ContainerConstants { | ||
|
||
public static final String GRAFANA = "grafana/grafana:10.1.0"; | ||
public static final String JAEGER = "quay.io/jaegertracing/all-in-one:1.48.0"; | ||
public static final String OTEL = "otel/opentelemetry-collector-contrib:0.83.0"; | ||
public static final String VICTORIA_METRICS = "victoriametrics/victoria-metrics:v1.93.0"; | ||
public static final String VM_AGENT = "victoriametrics/vmagent:v1.93.0"; | ||
} |
51 changes: 51 additions & 0 deletions
51
.../common/src/main/java/io/quarkus/observability/common/config/AbstractContainerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package io.quarkus.observability.common.config; | ||
|
||
import java.util.Locale; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
public abstract class AbstractContainerConfig implements ContainerConfig { | ||
|
||
private final String imageName; | ||
private final boolean shared; | ||
|
||
public AbstractContainerConfig(String imageName) { | ||
this(imageName, true); | ||
} | ||
|
||
public AbstractContainerConfig(String imageName, boolean shared) { | ||
this.imageName = imageName; | ||
this.shared = shared; | ||
} | ||
|
||
@Override | ||
public boolean enabled() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String imageName() { | ||
return imageName; | ||
} | ||
|
||
@Override | ||
public boolean shared() { | ||
return shared; | ||
} | ||
|
||
@Override | ||
public Optional<Set<String>> networkAliases() { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public String label() { | ||
String sn = getClass().getSimpleName().toLowerCase(Locale.ROOT); | ||
return "quarkus-dev-resource-" + sn; | ||
} | ||
|
||
@Override | ||
public String serviceName() { | ||
return "quarkus"; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...bservability/common/src/main/java/io/quarkus/observability/common/config/ConfigUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.quarkus.observability.common.config; | ||
|
||
public class ConfigUtils { | ||
|
||
public static boolean isEnabled(ContainerConfig config) { | ||
if (config != null && config.enabled()) { | ||
DevTarget target = config.getClass().getAnnotation(DevTarget.class); | ||
if (target != null) { | ||
ClassLoader cl = Thread.currentThread().getContextClassLoader(); | ||
try { | ||
cl.loadClass(target.value()); | ||
return true; | ||
} catch (ClassNotFoundException ignore) { | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public static String vmEndpoint(VictoriaMetricsConfig vmc) { | ||
String host = vmc.networkAliases().map(s -> s.iterator().next()).orElse("victoria-metrics"); | ||
int port = vmc.port(); | ||
return String.format("%s:%s", host, port); | ||
} | ||
|
||
} |
Oops, something went wrong.