JDBC spans report the whole host list as the host for multi-host connection URLs

Aperta Adatta ai principianti
#4,616 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@RaphaelFakhri ci sta già lavorando.

Dal 3/11/2026.

  • #4617 di @RaphaelFakhri — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java
Ambito
observability

Direzione di ricerca

L’issue menziona ConnectionMetaData.parse e mostra URL PostgreSQL e H2 con più host, ma non indica file sorgente o di test. Inizia individuando il codice che analizza gli URL e i test esistenti per MySQL e MariaDB con più host, poi verifica come vengono analizzati gli host e le porte di PostgreSQL e H2. Il lavoro è completato quando per gli esempi dell’issue vengono indicati il primo host e la relativa porta, con test che coprono entrambi i formati di URL.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

agent-java community triage

The JDBC plugin parses the connection URL that DatabaseMetaData.getURL() returns to fill the destination and database fields of JDBC spans. When the URL lists more than one host, as in PostgreSQL failover/load balancing URLs or H2 cluster URLs, the parser treats the full comma-separated host list as a single host.

For example, jdbc:postgresql://myhost1:666,myhost2:777/database produces:

  • host: myhost1:666,myhost2:777 (expected myhost1)
  • port: 5432, the default (expected 666)

jdbc:h2:tcp://server1:9101,server2:9102/~/sample produces host server1:9101,server2:9102 and port -1.

The PostgreSQL driver returns the original connection URL from getURL(), so every span on such a connection reports this host and port in destination.address, destination.port and the service target. The MySQL and MariaDB parsers already use the first host of a multi-host URL.

Steps to reproduce

  1. Connect to PostgreSQL with a multi-host URL, for example jdbc:postgresql://host1:5432,host2:5432/db?targetServerType=primary.
  2. Run a query while a transaction is active.
  3. Inspect the JDBC span: destination.address is host1:5432,host2:5432.

The same result is visible in a unit test:

ConnectionMetaData metadata = ConnectionMetaData.parse("jdbc:postgresql://myhost1:666,myhost2:777/database").build();
metadata.getHost(); // "myhost1:666,myhost2:777"
metadata.getPort(); // 5432

Expected behavior

The agent uses the first host and its port, as it already does for MySQL and MariaDB multi-host URLs.

Environment

  • Agent version: current main (1.57.2-SNAPSHOT)
  • Drivers: PostgreSQL JDBC (multi-host URLs), H2 (cluster URLs)
Lingua principale
Java
Stelle
592
Fork
340
Merge medio
2g 17h
PR unite (30g)
17

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di elastic/apm-agent-java

Tutte le issue di elastic/apm-agent-java

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.