3131import io .opentelemetry .sdk .metrics .SdkMeterProvider ;
3232import io .opentelemetry .sdk .metrics .export .PeriodicMetricReader ;
3333import io .opentelemetry .sdk .resources .Resource ;
34- import io .opentelemetry .semconv .ResourceAttributes ;
34+ import io .opentelemetry .semconv .ServiceAttributes ;
3535import java .time .Duration ;
3636import java .util .HashMap ;
3737import 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