Skip to content

feat: wrap fetchClient to add HTTP client attributes to remote servic…#425

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

feat: wrap fetchClient to add HTTP client attributes to remote servic…#425
vkozyura wants to merge 7 commits into
mainfrom
wrap-fetchclient

Conversation

@vkozyura
Copy link
Copy Markdown
Contributor

@vkozyura vkozyura commented May 21, 2026

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.

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.

1 participant