Skip to content
Open
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
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,62 @@ You can run your application in dev mode that enables live coding using:

> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.

## OpenTelemetry and Metrics

This application is instrumented with OpenTelemetry and exposes metrics in Prometheus format.

### Metrics Endpoint

Once the application is running, metrics are available at:
```
http://localhost:8080/q/metrics
```

This endpoint provides:
- **HTTP metrics**: Request count, duration, and status codes
- **JVM metrics**: Memory usage, thread count, garbage collection statistics
- **Application metrics**: Custom LRA coordinator metrics

### Example Usage

To view metrics in your browser or with curl:
```shell script
curl http://localhost:8080/q/metrics
```

### Integration with Prometheus

To scrape metrics with Prometheus, add the following job to your `prometheus.yml`:
```yaml
scrape_configs:
- job_name: 'lra-coordinator'
metrics_path: '/q/metrics'
static_configs:
- targets: ['localhost:8080']
```

### OpenTelemetry Configuration

The application is configured with:
- Service name: `lra-coordinator`
- Traces enabled: Yes
- Metrics enabled: Yes

Additional OpenTelemetry configuration can be modified in `src/main/resources/application.properties`.

### Grafana Dev Service (Optional)

For a fully integrated observability stack in dev mode (Grafana, Loki, Tempo, Prometheus), you can add the following dependency to your `pom.xml`:
```xml
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-observability-devservices-lgtm</artifactId>
<scope>provided</scope>
</dependency>
```

This will automatically start a Grafana LGTM container when running in dev mode, giving you access to a pre-configured Grafana dashboard to visualize metrics, logs, and traces.

## Packaging and running the application

The application can be packaged using:
Expand Down
18 changes: 18 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-docker</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-opentelemetry</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,14 @@ quarkus.index-dependency.microprofile-lra-api.artifact-id=microprofile-lra-api

quarkus.index-dependency.lra-service-base.group-id=org.jboss.narayana.lra
quarkus.index-dependency.lra-service-base.artifact-id=lra-service-base

# OpenTelemetry
quarkus.otel.service.name=lra-coordinator
quarkus.otel.traces.enabled=true
quarkus.otel.metrics.enabled=true
quarkus.otel.logs.enabled=true

# Metrics endpoint
quarkus.micrometer.export.prometheus.enabled=true
quarkus.micrometer.binder.http-server.enabled=true
quarkus.micrometer.binder.jvm.enabled=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.jboss.narayana.rts;

import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;

@QuarkusTest
class OpenTelemetryEndpointTest {

@Test
void metricsEndpointReturnsPrometheusData() {
given()
.when().get("/q/metrics")
.then()
.statusCode(200)
.contentType(containsString("openmetrics-text"))
.body(containsString("jvm_memory"));
}

@Test
void metricsEndpointContainsHttpServerMetrics() {
given()
.when().get("/q/metrics")
.then()
.statusCode(200)
.body(containsString("http_server"));
}
}
3 changes: 3 additions & 0 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Disable OTLP exporter in tests (no collector available)
quarkus.otel.exporter.otlp.traces.endpoint=http://localhost:4317
quarkus.otel.sdk.disabled=true