Skip to content

Commit

Permalink
feat: observability support for JVM (#3051)
Browse files Browse the repository at this point in the history
fixes: #3041
  • Loading branch information
stuartwdouglas authored Oct 10, 2024
1 parent 85c38ae commit db0ca7f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
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

0 comments on commit db0ca7f

Please sign in to comment.