Skip to content

Report configured Elasticsearch REST addresses as server.address - #19901

Merged
trask merged 2 commits into
trask-elasticsearch-library-separationfrom
trask-elasticsearch-rest-targets
Sep 9, 2026
Merged

trask merged 2 commits into
trask-elasticsearch-library-separationfrom
trask-elasticsearch-rest-targets

Conversation

@trask

@trask trask commented Aug 28, 2026 •

Copy link
Copy Markdown
Member

Capture configured Elasticsearch REST nodes at client construction and use that immutable target for stable database server attributes and span names, so sniffing and setNodes changes do not alter telemetry identity.

This PR is part of #19899 and applies the configured database target rules proposed in open-telemetry/semantic-conventions#4058 to the Elasticsearch REST client.

Configured target

A single configured host reports server.address=es.example, plus server.port=9200 when the port is not the scheme default. Host lists preserve duplicates, use deterministic lexical ordering, and report at most the first five endpoints. When every endpoint uses its scheme default, ports and server.port are omitted. If any endpoint in a multi-host target uses a non-default port, every endpoint keeps its effective port in server.address, including default-port members, and server.port is omitted.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-09-10 16:27 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds configured Elasticsearch REST targets and actual network-peer telemetry while preserving legacy span naming and server attributes.

Changes:

  • Captures immutable configured targets for Elasticsearch 5.x–7.x clients.
  • Propagates actual socket peers from Apache HttpAsyncClient.
  • Updates stable span names, attributes, documentation, and tests.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated no comments.

Show a summary per file
File Description
.../ElasticsearchServerTargetTest.java Tests target normalization and sanitization.
.../ElasticsearchDbAttributesGetterTest.java Tests peer attribute extraction.
.../ElasticsearchSpanNameExtractor.java Uses stable database span naming.
.../ElasticsearchServerTarget.java Models sanitized configured targets.
.../ElasticsearchRestRequest.java Carries target and peer state.
.../ElasticsearchDbAttributesGetter.java Exposes server and network-peer attributes.
.../ElasticsearchClientAttributeExtractor.java Preserves configured stable targets.
.../ElasticsearchServerTargets.java Stores targets in a virtual field.
elasticsearch-rest-7.0/library/.../ElasticsearchRest7Test.java Tests library target behavior.
.../RestClientWrapper.java Adds builder wrapping and target capture.
.../ElasticsearchRest7Telemetry.java Exposes the builder overload.
elasticsearch-rest-7.0/library/README.md Documents builder-based wrapping.
elasticsearch-rest-7.0/javaagent/.../ElasticsearchRest7Test.java Tests 7.x agent attributes and targets.
elasticsearch-rest-7.0/javaagent/.../RestClientInstrumentation.java Propagates target and peer state.
elasticsearch-rest-7.0/javaagent/.../RestClientConstructorInstrumentation.java Captures initial 7.x nodes.
.../ElasticsearchRest7InstrumentationModule.java Registers constructor instrumentation.
elasticsearch-rest-6.4/javaagent/.../ElasticsearchRest6Test.java Tests 6.x agent behavior.
elasticsearch-rest-6.4/javaagent/.../RestClientInstrumentation.java Propagates 6.x target and peer state.
elasticsearch-rest-6.4/javaagent/.../RestClientConstructorInstrumentation.java Captures initial 6.x nodes.
.../ElasticsearchRest6InstrumentationModule.java Registers constructor instrumentation.
elasticsearch-rest-5.0/javaagent/.../ElasticsearchRest5Test.java Tests 5.x agent behavior.
elasticsearch-rest-5.0/javaagent/.../RestClientInstrumentation.java Propagates 5.x target and peer state.
elasticsearch-rest-5.0/javaagent/.../RestClientConstructorInstrumentation.java Captures initial 5.x hosts.
.../ElasticsearchRest5InstrumentationModule.java Registers constructor instrumentation.
.../ElasticsearchClientTest.java Verifies API-client target and peer telemetry.
.../ApacheHttpAsyncClientInstrumentation.java Captures the connected socket peer.
.../SearchPeerStateTest.java Tests peer-state propagation and replacement.
.../SearchPeerState.java Implements nested peer capture state.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated no new comments.

@trask trask changed the title Capture Elasticsearch REST targets and network peers Capture the Elasticsearch REST logical server and network peer addresses Aug 29, 2026
@trask
trask force-pushed the trask-elasticsearch-rest-targets branch from fa8f77f to 51011a0 Compare August 30, 2026 15:15
@trask
trask requested a balanced review from Copilot August 31, 2026 03:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.

@trask
trask requested a balanced review from Copilot August 31, 2026 04:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated no new comments.

@trask
trask requested a balanced review from Copilot August 31, 2026 10:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated no new comments.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/v4_1/ApacheHttpAsyncClientInstrumentation.java:248

  • [General] This open-state guard drops the peer for transport failures that close or begin closing an established connection before failed() runs. Apache's HttpInetConnection address accessors do not require isOpen(), and the following null/port checks already omit connections without a resolved endpoint. Removing this guard lets failed Elasticsearch spans retain the last resolved socket peer as intended.
      if (!inetConnection.isOpen()) {
        return;
      }

@trask
trask requested a balanced review from Copilot August 31, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated no new comments.

@trask
trask changed the base branch from main to trask-database-endpoint-utility September 2, 2026 23:13
An error occurred while trying to automatically change base from trask-database-endpoint-utility to main September 3, 2026 17:32
@trask
trask force-pushed the trask-elasticsearch-rest-targets branch from eb65c17 to 041941b Compare September 3, 2026 20:29
@trask
trask changed the base branch from trask-database-endpoint-utility to main September 3, 2026 22:50
@trask trask changed the title Capture the Elasticsearch REST logical server and network peer addresses Report configured Elasticsearch REST addresses as server.address Sep 4, 2026
@trask
trask force-pushed the trask-elasticsearch-rest-targets branch from ce9e4e7 to a94bc5b Compare September 5, 2026 19:15
@trask
trask changed the base branch from main to trask-elasticsearch-library-separation September 5, 2026 20:29
@trask
trask marked this pull request as ready for review September 5, 2026 21:53
@trask
trask requested a review from a team as a code owner September 5, 2026 21:54
@trask
trask force-pushed the trask-elasticsearch-rest-targets branch 2 times, most recently from e10978b to 2619d2a Compare September 7, 2026 22:13
trask and others added 2 commits September 9, 2026 11:40
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@trask
trask force-pushed the trask-elasticsearch-rest-targets branch from 2619d2a to 3b1f512 Compare September 9, 2026 18:40
@trask
trask merged commit c9fd0eb into main Sep 9, 2026
100 checks passed
@trask
trask deleted the trask-elasticsearch-rest-targets branch September 9, 2026 22:12
laurit pushed a commit to laurit/opentelemetry-java-instrumentation that referenced this pull request Sep 21, 2026
…n-telemetry#19901)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants