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

Aberta
#14,765 2 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
48/100
Tipo de issue
Funcionalidade
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
java
Domínio
observability

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.
Linguagem predominante
Java
Estrelas
2.1k
Forks
1.2k
Merge médio
2d 14h
PRs com merge (30d)
192

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de googleapis/google-cloud-java

Todas as issues de googleapis/google-cloud-java

Issues semelhantes

Mais issues de Java

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.