Telemetry subsystem design improvements (umbrella)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- java
Línea de trabajo
Comienza con Design Issue 2 y lee src/main/java/dev/openfga/sdk/telemetry/Metrics.java; después, sigue la construcción de la configuración a través de OpenFgaApi.java y HttpRequestAttempt.java. Revisa OAuth2Client.java y la API de TelemetryConfiguration en relación con los seis Design Issues enumerados. Se considera terminado cuando los maintainers estén de acuerdo con la arquitectura coordinada y cada cambio seleccionado tenga definidos sus resultados de compatibilidad, testabilidad y telemetry-spec.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Note: This analysis was performed by AI with human assistance. The criticisms and proposed solutions below may warrant further discussion before acting on them.
Context
PR #290 fixes the immediate issue from #209 (sharing a single Telemetry instance per SDK client). During a comprehensive audit of the telemetry subsystem, several additional design limitations were identified. This umbrella issue tracks the larger improvements that require coordinated refactoring.
Related standalone bug fixes
These can be addressed independently in small PRs:
- #291 — All telemetry attributes exported as strings instead of correct types
- #292 —
Metricsconstructor mutates theConfigurationobject passed to it - #293 — No telemetry recorded for failed requests
Design Issues
1. ConfigurationOverride telemetry settings are silently ignored
Files: OpenFgaApi.java, HttpRequestAttempt.java
Every OpenFgaApi method accepts a ConfigurationOverride. When used, it creates a new Configuration via this.configuration.override(configurationOverride). However, the shared this.telemetry was constructed from the original configuration. So if an override changes telemetry settings, those changes are silently ignored.
Options:
- A)
Telemetry/Metricsmethods accept aConfigurationparameter at recording time (not just at construction) - B)
HttpRequestAttemptcreates a request-scopedTelemetrywhen an override is detected - C) Document that
ConfigurationOverridedoes not affect telemetry (if acceptable)
2. Users cannot provide their own OpenTelemetry instance
File: src/main/java/dev/openfga/sdk/telemetry/Metrics.java:26
Metrics hardcodes GlobalOpenTelemetry.get().getMeterProvider().get("openfga-sdk"). Users have no way to pass their own OpenTelemetry or MeterProvider instance.
Problems:
- Forces global state — Users must call
buildAndRegisterGlobal(). Non-global instances (common in multi-tenant setups, testing) silently produce no metrics. - Violates OTel best practices — The OTel Java library instrumentation guide says libraries should accept an
OpenTelemetryinstance rather than using the global singleton. - Untestable — No way to inject an in-memory meter for unit/integration tests.
Recommended fix: Allow ClientConfiguration to accept an optional OpenTelemetry instance, falling back to GlobalOpenTelemetry.get() if none is provided (backward-compatible):
ClientConfiguration config = new ClientConfiguration()
.apiUrl("https://...")
.openTelemetry(myOtelInstance); // optional
3. OAuth2Client creates a separate Telemetry instance
File: src/main/java/dev/openfga/sdk/api/auth/OAuth2Client.java:44
OAuth2Client creates its own Configuration copy and its own Telemetry. While PR #290 fixed the per-request issue, the credentialsRequest counter (line 61) still records against OAuth2Client's own separate Metrics instance. Credential request counts may not aggregate correctly with the parent client's metrics if the OTel implementation is sensitive to meter identity.
4. Telemetry class is unnecessary indirection
Telemetry is a thin wrapper that only lazily creates a Metrics instance. If it's not going to provide additional facilities (traces, logs, spans), it could be collapsed into Metrics directly, simplifying the API.
5. Missing fga-client.request.count metric from spec
The cross-SDK telemetry spec includes fga-client.request.count as a counter (disabled by default). The Java SDK doesn't implement it. The Python SDK added it in PR #135. While disabled by default, it should exist for spec parity and for users who want to enable it.
6. Poor DX — TelemetryConfiguration API is hard to use
The current configuration API requires:
Map<Metric, Map<Attribute, Optional<Object>>>
Problems:
- Unreadable type signature — Intimidating and hard to remember; 20+ lines of boilerplate for simple customization.
Optional<Object>serves no purpose — Every usage passesOptional.empty(). The data structure is effectively aSet<Attribute>disguised as aMap<Attribute, Optional<Object>>.- No builder/fluent API — No way to express
.disableAttribute(Attributes.URL_FULL). - All-or-nothing customization — To disable a single attribute on a single metric, users must copy the default map, mutate it, and reconstruct the full metrics map.
Recommended improvement: Add a builder pattern:
TelemetryConfiguration.builder()
.metric(Histograms.REQUEST_DURATION, attrs -> attrs
.defaults()
.without(Attributes.URL_FULL))
.metric(Counters.CREDENTIALS_REQUEST) // all defaults
.build();
Or at minimum, provide helper methods like withoutAttribute(Metric, Attribute) and withoutMetric(Metric).
Suggested Approach
These design issues are interrelated and would benefit from coordinated refactoring. A suggested ordering:
- Design Issue 2 (accept
OpenTelemetryinstance) — foundational, unblocks testability - Design Issue 4 (simplify
Telemetry→Metrics) — reduces surface area for other changes - Design Issue 3 (OAuth2Client telemetry sharing) — depends on design decisions from above
- Design Issue 1 (ConfigurationOverride telemetry) — requires clarity on config architecture
- Design Issue 5 (add
fga-client.request.count) — straightforward once plumbing is settled - Design Issue 6 (builder API for TelemetryConfiguration) — can be done at any point
- Lenguaje dominante
- Java
- Estrellas
- 55
- Forks
- 26
- Merge medio
- 1 d 22 h
- PR fusionados (30 d)
- 5
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de openfga/java-sdk
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Make client-credentials token refresh buffer and jitter configurablePosiblemente ocupada @dpkass la tomó hace 26 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
openfga/java-sdk#370 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
openfga/java-sdk#361 · 1 reacción ·
Los mantenedores suelen responder en 1 día
Todos los issues de openfga/java-sdk
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
-
Make branch and label autocomplete matching locale-independentPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
jenkinsci/gitlab-plugin#1950 ·
-
It's not necessary to copy the memory block in the readWrite() of org.h2.store.fs.mem.FileMemDataAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
h2database/h2database#4435 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
micronaut-projects/micronaut-core#13717 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ADORSYS-GIS/token-status-link#145 ·
Los mantenedores suelen responder en 3 días