Skip to content

feat: add HTTP client attributes to remote service#425

Open
vkozyura wants to merge 10 commits into
mainfrom
wrap-fetchclient
Open

feat: add HTTP client attributes to remote service#425
vkozyura wants to merge 10 commits into
mainfrom
wrap-fetchclient

Conversation

@vkozyura

@vkozyura vkozyura commented May 21, 2026

Copy link
Copy Markdown
Contributor

Adds HTTP semantic convention attributes to remote service spans by wrapping fetchClient.executeHttpRequest.

Alternative considered: Using @opentelemetry/instrumentation-undici response hooks to propagate attributes from HTTP child spans. This approach was rejected as it requires an additional dependency and creates duplicate spans.

@vkozyura vkozyura requested a review from sjvans May 21, 2026 08:48
@vkozyura vkozyura marked this pull request as draft May 21, 2026 08:48
hyperspace-insights[bot]

This comment was marked as resolved.

@vkozyura vkozyura marked this pull request as ready for review May 21, 2026 09:41
hyperspace-insights[bot]

This comment was marked as resolved.

@vkozyura vkozyura marked this pull request as draft May 21, 2026 09:46
@vkozyura vkozyura marked this pull request as ready for review May 21, 2026 12:12
@hyperspace-insights

Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


feat: Add HTTP Semantic Convention Attributes to Remote Service Spans

New Feature

✨ Enriches remote service spans with HTTP semantic convention attributes by wrapping fetchClient.executeHttpRequest. This improves observability for outbound HTTP calls made through CDS remote services, populating standard OpenTelemetry attributes such as request method, response status code, full URL, server address, and port.

Changes

  • lib/tracing/remote.js (new): Implements the remote tracing wrapper. Hooks into fetchClient.executeHttpRequest after CDS services are served, sets HTTP semantic convention attributes (http.request.method, url.full, server.address, server.port) before the call, and captures http.response.status_code from both successful responses and error responses. Includes a double-wrapping guard and graceful fallback if the fetchClient module cannot be loaded.

  • lib/tracing/index.js: Registers the new remote tracing module by calling require('./remote')() alongside the existing cds and cloud_sdk tracing setups.

  • test/tracing-attributes.test.js: Adds a remote test suite that spins up a local HTTP server and verifies that after making a GET request through a CDS remote service, all expected HTTP attributes are recorded on the active span. The test is skipped for CDS v8 due to Cloud SDK module resolution issues in the test environment.

  • test/bookshop/package.json: Adds @sap/cds-dk as a devDependency (version ^9) to support the new remote service tests.


  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.20.51

  • Event Trigger: pull_request.ready_for_review
  • File Content Strategy: Full file content
  • Output Template: Default Template
  • Correlation ID: 1164e10d-0329-4a43-a7ce-fce8c0fa87e8
  • Summary Prompt: Default Prompt
  • LLM: anthropic--claude-4.6-sonnet

hyperspace-insights[bot]

This comment was marked as resolved.

@sjvans sjvans 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.

@vkozyura

Copy link
Copy Markdown
Contributor Author

should use instrumentation-http's hooks

@sjvans: The @opentelemetry/instrumentation-http hooks doesn't work with CDS. CDS uses fetch() and not the http module. That's why I initially decided to use the client wrapper. But actually @opentelemetry/instrumentation-undici solves the problem. The http attributes are now there by just including instrumentation into dependencies.

@vkozyura vkozyura changed the title feat: wrap fetchClient to add HTTP client attributes to remote servic… feat: add HTTP client attributes to remote servic… Jun 24, 2026
@vkozyura vkozyura changed the title feat: add HTTP client attributes to remote servic… feat: add HTTP client attributes to remote service Jun 24, 2026
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.

2 participants