JDBC spans report the whole host list as the host for multi-host connection URLs
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 70/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- java
调研方向
Issue 提到了 ConnectionMetaData.parse,并展示了包含多个主机的 PostgreSQL 和 H2 URL,但没有指出源文件或测试文件。先定位 URL 解析代码以及现有的 MySQL 和 MariaDB 多主机测试,然后检查 PostgreSQL 和 H2 的主机与端口是如何解析的。完成标准是:为 issue 中的示例报告第一个主机及其端口,并且测试覆盖两种 URL 格式。
由索引模型根据 Issue 内容生成。
描述
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(expectedmyhost1) - port:
5432, the default (expected666)
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
- Connect to PostgreSQL with a multi-host URL, for example
jdbc:postgresql://host1:5432,host2:5432/db?targetServerType=primary. - Run a query while a transaction is active.
- Inspect the JDBC span:
destination.addressishost1: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)
- 主要语言
- Java
- 星标
- 592
- 派生
- 340
- 平均合并
- 2 天 17 小时
- 30 天内合并 PR
- 17
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
elastic/apm-agent-java 的其他 Issue
-
Spring MVC View instrumentation incorrectly matches static render overloads (EasyPOI)可能重新可做 @VelpulaGangavardhan 于 21 天前认领,目前没有进行中的 PR。 未关闭agent-java community triage
难度 2/5 1-3 小时 新手友好度 72/100
elastic/apm-agent-java#4594 · 2 条评论 ·
维护者通常 1 天内回复
-
agent-java
难度 2/5 1-2 天 新手友好度 62/100
elastic/apm-agent-java#2844 · 2 条评论 ·
维护者通常 1 天内回复
-
Improve docs and add error log related to illegal activation of transaction可能已有人在做 @AzazelSensei 于 58 天前认领。 未关闭docs good first issue
难度 2/5 1-3 小时 新手友好度 68/100
elastic/apm-agent-java#850 · 4 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
Log4j 2.7 log correlation calls ThreadContext.removeAll, which was introduced in 2.8可能已有人在做 @Anshuman-Prakash 于 18 天前认领。 未关闭agent-java community triage
难度 3/5 1-2 天 新手友好度 55/100
elastic/apm-agent-java#4593 ·
维护者通常 1 天内回复
-
agent-java community triage
elastic/apm-agent-java#4573 · 4 条评论 ·
维护者通常 1 天内回复
查看 elastic/apm-agent-java 的全部 Issue
相似的 Issue
-
Good First Issue
难度 1/5 1 小时以内 新手友好度 68/100
hiero-ledger/hiero-sdk-java#3044 ·
维护者通常 1 天内回复
-
A second build without clean fails in resources-optimizer-maven-plugin because minified files are minified again可能已有人在做 @papegaaij 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
hermes-queue
难度 1/5 1 小时以内 新手友好度 85/100
chrisalunlloyd2-sudo/mindpalace#337 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 79/100
flutter/flutter-intellij#9221 ·
维护者通常 1 天内回复