Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

### Fixed

- Cloud SDK outbound requests are traced again (patch getter-only `@sap-cloud-sdk/http-client` exports via `Object.defineProperty`)

## Version 2.0.1 - 2026-07-03

### Fixed
Expand Down
33 changes: 16 additions & 17 deletions lib/tracing/cloud_sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ function _cloudSdkSpanName(destination, requestConfig) {
return `${method}${path ? ' ' + path : ''}`
}

// REVISIT: unverified!
// Instruments @sap-cloud-sdk/http-client's exports (the outbound path CAP uses by
// default when the cloud sdk is installed) to emit a CLIENT span per remote call.
// Note: cloud sdk v4 exposes executeHttpRequest(WithOrigin) as getter-only properties,
// so a plain assignment silently fails -> we must use Object.defineProperty with a value.
module.exports = () => {
try {
require.resolve('@sap-cloud-sdk/http-client')
Expand All @@ -25,26 +28,22 @@ module.exports = () => {

const cloudSDK = require('@sap-cloud-sdk/http-client')
const { executeHttpRequest: _execute, executeHttpRequestWithOrigin: _executeWithOrigin } = cloudSDK
cloudSDK.executeHttpRequest = wrap(_execute, {
const _executeHttpRequest = wrap(_execute, {
wrapper: function executeHttpRequest(destination, requestConfig) {
return trace(
_cloudSdkSpanName(destination, requestConfig),
_execute,
this,
arguments,
{ kind: SpanKind.CLIENT, outbound: destination.name }
)
return trace(_cloudSdkSpanName(destination, requestConfig), _execute, this, arguments, {
kind: SpanKind.CLIENT,
outbound: destination.name
})
}
})
cloudSDK.executeHttpRequestWithOrigin = wrap(_executeWithOrigin, {
Object.defineProperty(cloudSDK, 'executeHttpRequest', { value: _executeHttpRequest, writable: true, configurable: true })
const _executeHttpRequestWithOrigin = wrap(_executeWithOrigin, {
wrapper: function executeHttpRequestWithOrigin(destination, requestConfig) {
return trace(
_cloudSdkSpanName(destination, requestConfig),
_executeWithOrigin,
this,
arguments,
{ kind: SpanKind.CLIENT, outbound: destination.name }
)
return trace(_cloudSdkSpanName(destination, requestConfig), _executeWithOrigin, this, arguments, {
kind: SpanKind.CLIENT,
outbound: destination.name
})
}
})
Object.defineProperty(cloudSDK, 'executeHttpRequestWithOrigin', { value: _executeHttpRequestWithOrigin, writable: true, configurable: true })
}
Loading