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 dbc547e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 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
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
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 dbc547e

Please sign in to comment.