[java-bigquerystorage] Accept an OpenTelemetry instance per stream writer instead of the cached GlobalOpenTelemetry

Ouverte
#14,765 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
48/100
Type d'issue
Fonctionnalité
Clarté
Clairement spécifiée
Activité
Active
Stack technique
java
Domaine
observability

Piste de recherche

Start with StreamWriter.Builder and the TelemetryMetrics and Singletons files linked in the issue; trace how each writer obtains its MeterProvider. Check the builders for JsonStreamWriter and SchemaAwareStreamWriter too, since the request asks for the same option there. Done means each builder can accept its own OpenTelemetry instance while an unset option retains the current global behavior.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Is your feature request related to a problem? Please describe.

The Storage Write client's OpenTelemetry metrics (StreamWriter.Builder.setEnableOpenTelemetry(true)) can only be sent to the process-wide GlobalOpenTelemetry.
TelemetryMetrics takes its MeterProvider from Singletons.getOpenTelemetry(), which caches GlobalOpenTelemetry.get() in a static field on first use and has no setter:

https://github.com/googleapis/google-cloud-java/blob/165f02ec20bc3db5eb8ca0b6ba09af6f6590be71/java-bigquerystorage/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/Singletons.java#L30-L36

https://github.com/googleapis/google-cloud-java/blob/165f02ec20bc3db5eb8ca0b6ba09af6f6590be71/java-bigquerystorage/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/TelemetryMetrics.java#L136-L139

This makes the metrics hard to use from a framework that hosts many writers in one JVM.
We maintain an Apache Flink connector for BigQuery (flink-gcp/flink-connector-gcp) and want to forward each writer's metrics into Flink's own metric system, which then exports them to whatever reporter the deployment uses (Prometheus, Datadog, OTLP).
With only the global instance:

  • several jobs or subtasks share one TaskManager JVM, so their writers cannot report to separate meter providers;
  • a library cannot call GlobalOpenTelemetry.set(...) without taking that global over from the application;
  • when the client is shaded into a connector jar, io.opentelemetry is relocated, so the relocated global is not one the application or a Java agent can set at all.

Describe the solution you'd like

An optional per-writer OpenTelemetry (or MeterProvider) on the writer builders, for example StreamWriter.Builder.setOpenTelemetry(OpenTelemetry), with the same setter on JsonStreamWriter.Builder and SchemaAwareStreamWriter.Builder.
When it is unset, the current GlobalOpenTelemetry behaviour would stay as it is.

Other clients in this repository already offer this:

  • Spanner: SpannerOptions.Builder.setClientMetricsProvider(MetricsProvider) (#13741).
  • Bigtable: BigtableDataSettings.Builder.setMetricsProvider(MetricsProvider), which accepts a CustomOpenTelemetryMetricsProvider.

Describe alternatives you've considered

  • GlobalOpenTelemetry.set(...) once per JVM: it cannot separate the writers of different jobs, and it does not reach a relocated copy of the client.
  • Reading the meters reflectively, or replacing Singletons: neither is a supported surface.

Additional context

  • Libraries-Bom: 26.90.0
    • google-cloud-bigquerystorage 3.35.0
  • The same code is on main at 165f02ec20bc3db5eb8ca0b6ba09af6f6590be71.
Langage dominant
Java
Étoiles
2.1k
Forks
1.2k
Merge moyen
2 j 14 h
PR mergées (30 j)
192

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de googleapis/google-cloud-java

Toutes les issues de googleapis/google-cloud-java

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.