@serverless/sdk
Advanced tools
Comparing version 0.5.16 to 0.5.17
@@ -5,2 +5,14 @@ # Changelog | ||
### [0.5.17](https://github.com/serverless/console/compare/@serverless/sdk@0.5.16...@serverless/sdk@0.5.17) (2023-05-10) | ||
### Bug Fixes | ||
- Fix detection of not observed response body ([f7eb441](https://github.com/serverless/console/commit/f7eb4419869bff2f0fa4b69d94cd175919813f1a)) | ||
### Maintenance Improvements | ||
- Support black boxing internal spans ([4ae3a31](https://github.com/serverless/console/commit/4ae3a31333e1e599e1a5e91ab8d3cc8a6e5fe068)) | ||
- Do not create HTTP trace spans in black box context ([12ef23b](https://github.com/serverless/console/commit/12ef23b87ed6aa34785e1d942b3177240f72f794)) | ||
- Remove no longer needed debug logs ([978deb8](https://github.com/serverless/console/commit/978deb849f915a2e27a08411b38d9b17b51163c8)) | ||
### [0.5.16](https://github.com/serverless/console/compare/@serverless/sdk@0.5.15...@serverless/sdk@0.5.16) (2023-05-04) | ||
@@ -7,0 +19,0 @@ |
@@ -130,5 +130,5 @@ 'use strict'; | ||
Object.defineProperties( | ||
serverlessSdk, | ||
lazy({ _customTags: d('cew', () => new Tags(), { flat: true }) }) | ||
); | ||
Object.defineProperties(serverlessSdk, { | ||
_isInTraceSpanBlackBox: d.gs(() => TraceSpan.isInBlackBox), | ||
...lazy({ _customTags: d('cew', () => new Tags(), { flat: true }) }), | ||
}); |
@@ -147,11 +147,2 @@ 'use strict'; | ||
const startTime = process.hrtime.bigint(); | ||
if (serverlessSdk._isDebugMode) { | ||
// Generate stack trace only if intend to write this log | ||
// (stack trace generation can be expensive, esecially with source map generation on) | ||
serverlessSdk._debugLog( | ||
'HTTP request', | ||
shouldIgnoreFollowingRequest, | ||
!shouldIgnoreFollowingRequest && new Error().stack | ||
); | ||
} | ||
let [url, options] = args; | ||
@@ -191,3 +182,4 @@ | ||
options._slsIgnore || | ||
(originalCb && typeof originalCb !== 'function') | ||
(originalCb && typeof originalCb !== 'function') || | ||
serverlessSdk._isInTraceSpanBlackBox | ||
) { | ||
@@ -214,3 +206,3 @@ shouldIgnoreFollowingRequest = false; | ||
onCloseByRoot: () => { | ||
if (responseReadableState && responseReadableState.flowing === false) { | ||
if (responseReadableState && !responseReadableState.flowing) { | ||
// Response data was not observed | ||
@@ -286,6 +278,4 @@ traceSpan.close({ endTime: requestEndTime }); | ||
if (!isInstalled) return; | ||
serverlessSdk._debugLog('ignore HTTP request', shouldIgnoreFollowingRequest); | ||
shouldIgnoreFollowingRequest = true; | ||
process.nextTick(() => { | ||
serverlessSdk._debugLog('reset ignore HTTP request', shouldIgnoreFollowingRequest); | ||
shouldIgnoreFollowingRequest = false; | ||
@@ -292,0 +282,0 @@ }); |
@@ -34,2 +34,7 @@ 'use strict'; | ||
} | ||
static get isInBlackBox() { | ||
const currentSpan = TraceSpan.resolveCurrentSpan(); | ||
if (!currentSpan) return false; | ||
return Boolean(currentSpan._isBlackBox || currentSpan._isBlackBoxed); | ||
} | ||
@@ -65,2 +70,3 @@ constructor(name, options = {}) { | ||
if (options.output != null) this.output = options.output; | ||
this._isBlackBox = Boolean(options.isBlackBox); | ||
if (!TraceSpan.rootSpan) { | ||
@@ -83,4 +89,4 @@ TraceSpan.rootSpan = this; | ||
if (this.parentSpan) this.parentSpan.subSpans.add(this); | ||
emitter.emit('trace-span-open', this); | ||
if (this.parentSpan) this.parentSpan._subSpans.add(this); | ||
if (!this._isBlackBoxed) emitter.emit('trace-span-open', this); | ||
if (immediateDescendants && immediateDescendants.length) { | ||
@@ -148,3 +154,3 @@ // eslint-disable-next-line no-new | ||
} | ||
emitter.emit('trace-span-close', this); | ||
if (!this._isBlackBoxed) emitter.emit('trace-span-close', this); | ||
return this; | ||
@@ -154,3 +160,3 @@ } | ||
this.closeContext(); | ||
if (this.parentSpan) this.parentSpan.subSpans.delete(this); | ||
if (this.parentSpan) this.parentSpan._subSpans.delete(this); | ||
this.parentSpan = null; | ||
@@ -187,2 +193,9 @@ } | ||
} | ||
get subSpans() { | ||
return this._isBlackBox ? new Set() : this._subSpans; | ||
} | ||
get _isBlackBoxed() { | ||
if (!this.parentSpan) return false; | ||
return this.parentSpan._isBlackBox || this.parentSpan._isBlackBoxed; | ||
} | ||
get spans() { | ||
@@ -219,3 +232,3 @@ return new StringifiableSet([ | ||
id: d(() => generateId()), | ||
subSpans: d(() => new Set()), | ||
_subSpans: d(() => new Set()), | ||
tags: d(() => new Tags()), | ||
@@ -222,0 +235,0 @@ customTags: d(() => new Tags()), |
{ | ||
"name": "@serverless/sdk", | ||
"repository": "serverless/console", | ||
"version": "0.5.16", | ||
"version": "0.5.17", | ||
"author": "Serverless, Inc.", | ||
@@ -6,0 +6,0 @@ "dependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85776
1644