Repository navigation
Capture the Cassandra 4.4 logical server in server.address - #19877
Conversation
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Updates Cassandra 4.4 instrumentation to report stable server.address / server.port from configured (and captured programmatic) contact points, aligning with semantic-conventions#4041, while preserving legacy behavior and handling SNI/broadcast RPC cases.
Changes:
- Capture and snapshot configured/programmatic contact points at session-wrap time and propagate into request/span attribute extraction.
- Add
CassandraServerTargetlogic + tests for parsing/deduping/sorting contact points and session configuration fallbacks. - Extend server attribute extraction logic for stable semconv, including special handling for SNI endpoints.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.
Show a summary per file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Pull request dashboard statusMerged · refreshed 2026-09-10 17:07 UTC Status above doesn't look right?
|
467bdaa to
5ec792a
Compare
db0984d to
7f1f03b
Compare
7f1f03b to
e66ddec
Compare
e66ddec to
dd7a20b
Compare
dd7a20b to
291625c
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Failing check: build / common / build: error: warnings found and -Werror specified Cause: The Javadoc name addContactPoints resembled the contactPoints parameter, so Error Prone reported InvalidParam. Fix: Describe the builder methods without identifier-style code text that Error Prone interprets as a parameter reference. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot comment:
`ofAddresses` does not guard against invalid entries (e.g., null elements) and does not wrap its loop/build in the same `try/catch` used by the session-based overloads. However, `CassandraServerTargetTest.unsafeExplicitContactPointAddressesHaveNoTarget` passes a null `InetSocketAddress` and expects `null` rather than an exception. To match the omission rules ('unsafe or malformed values omit the stable target'), handle null/invalid addresses by recording an invalid endpoint or catching `RuntimeException` and returning `null`.
Analysis: The explicit-address overload let invalid entries throw before the target builder could omit the target. Catching RuntimeException around endpoint collection and target construction applies the same omission behavior as the session overloads.
Upsides: Unsafe or malformed explicit addresses now omit server.address instead of escaping into session construction.
Downsides: The overload does not expose the specific malformed endpoint that caused omission.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot comment:
Parsing string contact points via `lastIndexOf(':')` makes unbracketed IPv6 literals **without** an explicit port ambiguous and can be misinterpreted as `host + port` (e.g., `\"::1\"` becomes host `\"::\"` port `1`, and `\"2001:db8::1\"` becomes host `\"2001:db8::\"` port `1`). This conflicts with `CassandraServerTargetTest.invalidContactPoints()` which expects those values to drop the target, and it can also yield incorrect stable targets in production. Consider changing the string-format contract to require bracketed IPv6 (`[addr]:port`) for any IPv6 host in configured contact points, or add stricter validation to reject cases that look like bare IPv6 literals rather than `host:port` entries. (Mandatory to make behavior deterministic and aligned with the test expectations/omission rules.)
Analysis: The last colon cannot distinguish an IPv6 address segment from a port. Requiring brackets whenever the parsed host contains a colon makes the configured contact point format unambiguous and keeps bare IPv6 literals from producing a false stable target.
Upsides: IPv6 contact points now produce a stable target only from the deterministic `[address]:port` form, and tests cover apparent-port edge cases.
Downsides: Previously accepted unbracketed IPv6 contact points with a port now omit the stable target.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
a7c2370 to
8759138
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Target ordering, malformed bracket handling, and the public overload contract need correction.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (2)
instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraServerTarget.java:96
- [General] The mixed configured/programmatic path still preserves the configured prefix and sorts only the programmatic suffix. Since the Cassandra driver treats the merged contact points as an unordered set, equivalent builder/config combinations can produce different target strings. Enable sorting on the final
DbServerTargetBuilderinstead of preserving this split order.
DbServerTargetBuilder target = DbServerTarget.builder(DEFAULT_PORT);
instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraServerTarget.java:177
- [General] This strips brackets without checking that they enclosed IPv6, so malformed values such as
[node.example.com]:9042or[127.0.0.1]:9042are accepted as ordinary hosts instead of dropping the target. Validate that a bracketed host is IPv6 before passing it to the target builder.
if (host.startsWith("[")) {
if (!host.endsWith("]")) {
target.addEndpoint((String) null, -1);
return null;
}
- Files reviewed: 14/14 changed files
- Comments generated: 2
- Review effort level: Balanced
There was a problem hiding this comment.
I guess this is to figure out whether 2 addresses are really the same, does it matter?
There was a problem hiding this comment.
yeah, this was probably too much, simplified it, and require passing in the seeds into the library instrumentation similar to mongo (#19839)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Bracketed non-IPv6 hosts are incorrectly accepted instead of triggering target omission.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 16/16 changed files
- Comments generated: 1
- Review effort level: Balanced
Copilot comment: [General] This strips brackets before `DbServerTargetBuilder` can validate their use, so a malformed value such as `[node.example.com]:9042` is accepted and emitted as `node.example.com` instead of dropping the complete target. Brackets are valid only for IPv6 literals; reject a bracketed host without a colon before removing the brackets so malformed configurations follow the PR's omission rule. Analysis: CassandraServerTarget removes brackets before passing the host to DbServerTargetBuilder. The builder therefore cannot tell that a DNS hostname was bracketed. Rejecting a bracketed host without a colon preserves valid IPv6 literals and drops malformed bracketed hostnames. Upsides: Malformed bracketed hostnames now omit the complete server target, and the parameterized parser test covers this case. Downsides: No material downside identified Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The target capture, omission rules, semantic-convention behavior, and compatibility paths are consistently implemented and tested.
Review details
- Files reviewed: 16/16 changed files
- Comments generated: 0 new
- Review effort level: Balanced
…metry#19877) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This PR is part of #19899 and applies the configured database target rules in open-telemetry/semantic-conventions#4058 to Cassandra 4.4. Stable spans report configured contact points in
server.addressrather than the selected coordinator; legacy coordinator and proxy telemetry are preserved, with operation peer information handled separately by #19883.Library users supply the complete original contact-point list, including both builder and driver-configuration sources:
The existing
wrap(session)still traces operations but omits stableserver.addressandserver.port. This follows the MongoDB library pattern in #19839 rather than trying to reconstruct original configuration from resolved driver metadata.The javaagent continues to combine captured builder contact points with
basic.contact-pointsautomatically. Targets are captured once when wrapping the session, so later topology and coordinator changes do not affect them.Multi-endpoint handling
server.address, and a non-default port is recorded inserver.port.9042port.server.addressandserver.portis omitted.Omission rules
Unsafe or malformed values, implicit targets, and custom or SNI discovery endpoints omit the stable target instead of falling back to the coordinator.
Builds on #19872.