Skip to content

Commit

Permalink
feat: obervability support for JVM
Browse files Browse the repository at this point in the history
fixes: #3041
  • Loading branch information
stuartwdouglas committed Oct 9, 2024
1 parent f4fab8c commit c9807a9
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 30 deletions.
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package xyz.block.ftl.deployment;

import java.util.Set;

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

public class StaticConfigSource implements ConfigSource {

public static final String QUARKUS_BANNER_ENABLED = "quarkus.banner.enabled";
final static String OTEL_ENDPOINT = "quarkus.otel.exporter.otlp.endpoint";
final static String OTEL_METRICS_ENABLED = "quarkus.otel.metrics.enabled";

@Override
public Set<String> getPropertyNames() {
return Set.of(QUARKUS_BANNER_ENABLED);
}

@Override
public String getValue(String propertyName) {
switch (propertyName) {
case (QUARKUS_BANNER_ENABLED) -> {
return "false";
}
case OTEL_ENDPOINT -> {
if (System.getenv("QUARKUS_OTEL_EXPORTER_OTLP_ENDPOINT") != null) {
return System.getenv("QUARKUS_OTEL_EXPORTER_OTLP_ENDPOINT");
}
return null;
}
case OTEL_METRICS_ENABLED -> {
return "true";
}
}
return null;
}

@Override
public String getName() {
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package xyz.block.ftl.runtime;

import io.opentelemetry.api.metrics.DoubleGauge;
import jakarta.inject.Singleton;

import io.grpc.stub.StreamObserver;
import io.opentelemetry.api.metrics.LongCounter;
import io.opentelemetry.api.metrics.Meter;
import io.quarkus.grpc.GrpcService;
import xyz.block.ftl.v1.*;

Expand All @@ -11,14 +14,21 @@
public class VerbHandler extends VerbServiceGrpc.VerbServiceImplBase {

final VerbRegistry registry;
final LongCounter counter;

public VerbHandler(VerbRegistry registry) {
public VerbHandler(VerbRegistry registry, Meter meter) {
this.registry = registry;
counter = meter.counterBuilder("ftl-jvm-runtime/verb_invocations")
.setDescription("The number of verb invocations")
.setUnit("invocations")
.build();
}

@Override
public void call(CallRequest request, StreamObserver<CallResponse> responseObserver) {
try {
counter.add(1);

var response = registry.invoke(request);
responseObserver.onNext(response);
responseObserver.onCompleted();
Expand Down

0 comments on commit c9807a9

Please sign in to comment.