Skip to content

Commit c589608

Browse files
committed
fix build, update otel deps
1 parent 24883ee commit c589608

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

examples/opentelemetry/build.gradle

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ task downloadAgent {
2222
if (!agentFile.exists()) {
2323
println "Downloading OpenTelemetry Java agent..."
2424
def agentUrl = 'https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar'
25-
def agentUrl = 'https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar'
2625
try {
2726
new URL(agentUrl).withInputStream { i ->
2827
agentFile.withOutputStream { it << i }
@@ -76,8 +75,8 @@ repositories {
7675

7776
ext {
7877
fgaSdkVersion = "0.9.0"
79-
openTelemetryVersion = "1.32.0"
80-
openTelemetryAlphaVersion = "1.32.0-alpha"
78+
openTelemetryVersion = "1.53.0"
79+
openTelemetryAlphaVersion = "1.53.0-alpha"
8180
}
8281

8382
dependencies {
@@ -97,7 +96,7 @@ dependencies {
9796
implementation("io.opentelemetry:opentelemetry-exporter-prometheus:$openTelemetryAlphaVersion")
9897
implementation("io.opentelemetry:opentelemetry-exporter-otlp:$openTelemetryVersion")
9998
implementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:$openTelemetryVersion")
100-
implementation("io.opentelemetry.semconv:opentelemetry-semconv:1.21.0-alpha")
99+
implementation("io.opentelemetry.semconv:opentelemetry-semconv:1.34.0")
101100

102101
// Environment variables for this example
103102
implementation("io.github.cdimascio:dotenv-java:3.2.0")

examples/opentelemetry/src/main/java/dev/openfga/sdk/example/opentelemetry/OpenTelemetryExample.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
3232
import io.opentelemetry.sdk.metrics.export.PeriodicMetricReader;
3333
import io.opentelemetry.sdk.resources.Resource;
34-
import io.opentelemetry.semconv.ResourceAttributes;
34+
import io.opentelemetry.semconv.ServiceAttributes;
3535
import java.time.Duration;
3636
import java.util.HashMap;
3737
import java.util.List;
@@ -65,11 +65,11 @@ public class OpenTelemetryExample {
6565
private static final int OPERATION_LOOP_INTERVAL_SECONDS = 20;
6666
private static final int ERROR_RETRY_INTERVAL_SECONDS = 2;
6767
private static final int METRICS_EXPORT_INTERVAL_SECONDS = 10;
68-
68+
6969
// Command Line Arguments
7070
private static final String ARG_MODE_AGENT = "--mode=agent";
7171
private static final String ARG_MODE_MANUAL = "--mode=manual";
72-
72+
7373
// Environment Variable Names
7474
private static final String ENV_OTEL_EXPORTER_OTLP_ENDPOINT = "OTEL_EXPORTER_OTLP_ENDPOINT";
7575
private static final String ENV_OTEL_SERVICE_NAME = "OTEL_SERVICE_NAME";
@@ -81,15 +81,15 @@ public class OpenTelemetryExample {
8181
private static final String ENV_FGA_CLIENT_SECRET = "FGA_CLIENT_SECRET";
8282
private static final String ENV_FGA_API_AUDIENCE = "FGA_API_AUDIENCE";
8383
private static final String ENV_FGA_API_TOKEN_ISSUER = "FGA_API_TOKEN_ISSUER";
84-
84+
8585
// Default Values
8686
private static final String DEFAULT_OTLP_ENDPOINT = "http://localhost:4317";
8787
private static final String DEFAULT_SERVICE_NAME = "openfga-java-sdk-example";
8888
private static final String DEFAULT_SERVICE_VERSION = "1.0.0";
8989
private static final String DEFAULT_FGA_API_URL = "http://localhost:8080";
9090
private static final String DEFAULT_API_AUDIENCE = "https://api.fga.example";
9191
private static final String DEFAULT_API_TOKEN_ISSUER = "auth.fga.example";
92-
92+
9393
private static Dotenv dotenv;
9494
private static OpenFgaClient fgaClient;
9595

@@ -120,7 +120,8 @@ public static void main(String[] args) throws Exception {
120120
createOpenFgaClient();
121121

122122
System.out.println("\n🔄 Starting continuous operations loop...");
123-
System.out.println(" Operations will run every " + OPERATION_LOOP_INTERVAL_SECONDS + " seconds until stopped (Ctrl+C)");
123+
System.out.println(
124+
" Operations will run every " + OPERATION_LOOP_INTERVAL_SECONDS + " seconds until stopped (Ctrl+C)");
124125
System.out.println(" This matches the behavior of other OpenFGA SDK examples");
125126

126127
// Run operations continuously
@@ -183,8 +184,8 @@ private static void configureOpenTelemetryManually() {
183184

184185
// Create resource with service information
185186
Resource resource = Resource.getDefault().toBuilder()
186-
.put(ResourceAttributes.SERVICE_NAME, serviceName)
187-
.put(ResourceAttributes.SERVICE_VERSION, serviceVersion)
187+
.put(ServiceAttributes.SERVICE_NAME, serviceName)
188+
.put(ServiceAttributes.SERVICE_VERSION, serviceVersion)
188189
.build();
189190

190191
// Configure OTLP metric exporter
@@ -194,7 +195,8 @@ private static void configureOpenTelemetryManually() {
194195
// Create meter provider with OTLP exporter
195196
SdkMeterProvider meterProvider = SdkMeterProvider.builder()
196197
.registerMetricReader(PeriodicMetricReader.builder(metricExporter)
197-
.setInterval(Duration.ofSeconds(METRICS_EXPORT_INTERVAL_SECONDS)) // Export metrics every 10 seconds
198+
.setInterval(
199+
Duration.ofSeconds(METRICS_EXPORT_INTERVAL_SECONDS)) // Export metrics every 10 seconds
198200
.build())
199201
.setResource(resource)
200202
.build();
@@ -257,7 +259,8 @@ private static void createOpenFgaClient() throws Exception {
257259
String modelId = dotenv.get(ENV_FGA_MODEL_ID);
258260

259261
if (storeId == null || modelId == null) {
260-
throw new IllegalStateException(ENV_FGA_STORE_ID + " and " + ENV_FGA_MODEL_ID + " must be configured in .env file");
262+
throw new IllegalStateException(
263+
ENV_FGA_STORE_ID + " and " + ENV_FGA_MODEL_ID + " must be configured in .env file");
261264
}
262265

263266
System.out.println(" API URL: " + apiUrl);

0 commit comments

Comments
 (0)