diff --git a/examples/java/time/src/main/java/ftl/time/Time.java b/examples/java/time/src/main/java/ftl/time/Time.java index b3951c0f4..d27668c8c 100644 --- a/examples/java/time/src/main/java/ftl/time/Time.java +++ b/examples/java/time/src/main/java/ftl/time/Time.java @@ -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()); } } diff --git a/jvm-runtime/ftl-runtime/common/deployment/pom.xml b/jvm-runtime/ftl-runtime/common/deployment/pom.xml index 0ba449822..72d4d26f4 100644 --- a/jvm-runtime/ftl-runtime/common/deployment/pom.xml +++ b/jvm-runtime/ftl-runtime/common/deployment/pom.xml @@ -23,6 +23,10 @@ io.quarkus quarkus-rest-jackson-deployment + + io.quarkus + quarkus-opentelemetry-deployment + io.quarkus quarkus-agroal-spi diff --git a/jvm-runtime/ftl-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/BannerConfigSource.java b/jvm-runtime/ftl-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/StaticConfigSource.java similarity index 53% rename from jvm-runtime/ftl-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/BannerConfigSource.java rename to jvm-runtime/ftl-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/StaticConfigSource.java index 0ce5fff4e..220491e33 100644 --- a/jvm-runtime/ftl-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/BannerConfigSource.java +++ b/jvm-runtime/ftl-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/StaticConfigSource.java @@ -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 getPropertyNames() { @@ -15,14 +16,19 @@ public Set 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"; } } diff --git a/jvm-runtime/ftl-runtime/common/deployment/src/main/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource b/jvm-runtime/ftl-runtime/common/deployment/src/main/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource index d8995dc83..3560bbbc3 100644 --- a/jvm-runtime/ftl-runtime/common/deployment/src/main/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource +++ b/jvm-runtime/ftl-runtime/common/deployment/src/main/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource @@ -1 +1 @@ -xyz.block.ftl.deployment.BannerConfigSource \ No newline at end of file +xyz.block.ftl.deployment.StaticConfigSource \ No newline at end of file diff --git a/jvm-runtime/ftl-runtime/common/runtime/pom.xml b/jvm-runtime/ftl-runtime/common/runtime/pom.xml index d8b58c794..1f0ac4cce 100644 --- a/jvm-runtime/ftl-runtime/common/runtime/pom.xml +++ b/jvm-runtime/ftl-runtime/common/runtime/pom.xml @@ -24,6 +24,14 @@ io.quarkus quarkus-rest-jackson + + io.quarkus + quarkus-opentelemetry + + + io.opentelemetry.instrumentation + opentelemetry-jdbc + com.fasterxml.jackson.module jackson-module-kotlin