Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: observability support for JVM #3051

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion examples/java/time/src/main/java/ftl/time/Time.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@

import java.time.OffsetDateTime;

import io.opentelemetry.api.metrics.LongCounter;
import io.opentelemetry.api.metrics.Meter;
import xyz.block.ftl.Export;
import xyz.block.ftl.Verb;

public class Time {
final LongCounter counter;

public Time(Meter meter) {
counter = meter.counterBuilder("time.invocations")
.setDescription("The number of time invocations")
.setUnit("invocations")
.build();
}

@Verb
@Export
public static TimeResponse time() {
public TimeResponse time() {
counter.add(1);
return new TimeResponse(OffsetDateTime.now());
}
}
4 changes: 4 additions & 0 deletions jvm-runtime/ftl-runtime/common/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-jackson-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-opentelemetry-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-agroal-spi</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

import org.eclipse.microprofile.config.spi.ConfigSource;

public class BannerConfigSource implements ConfigSource {
public class StaticConfigSource implements ConfigSource {

public static final String QUARKUS_BANNER_ENABLED = "quarkus.banner.enabled";
final static String OTEL_METRICS_ENABLED = "quarkus.otel.metrics.enabled";

@Override
public Set<String> getPropertyNames() {
Expand All @@ -15,14 +16,19 @@ public Set<String> getPropertyNames() {

@Override
public String getValue(String propertyName) {
if (propertyName.equals(QUARKUS_BANNER_ENABLED)) {
return "false";
switch (propertyName) {
case (QUARKUS_BANNER_ENABLED) -> {
return "false";
}
case OTEL_METRICS_ENABLED -> {
return "true";
}
}
return null;
}

@Override
public String getName() {
return "Quarkus Banner";
return "Quarkus Static Config Source";
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
xyz.block.ftl.deployment.BannerConfigSource
xyz.block.ftl.deployment.StaticConfigSource
8 changes: 8 additions & 0 deletions jvm-runtime/ftl-runtime/common/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-opentelemetry</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
Expand Down