Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@serverless/sdk

Package Overview
Dependencies
Maintainers
6
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serverless/sdk - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

1

.ts-types/index.d.ts

@@ -29,2 +29,3 @@ import ExpressAppInstrument from './instrumentation/express-app';

): undefined;
setTag(name: string, value: boolean | number | string | Date | Array<unknown> | null): undefined;
}

@@ -31,0 +32,0 @@

@@ -5,2 +5,9 @@ # Changelog

### [0.3.1](https://github.com/serverless/console/compare/@serverless/sdk@0.3.0...@serverless/sdk@0.3.1) (2023-01-13)
### Features
- `serverlessSdk.setTag` ([c546bcd](https://github.com/serverless/console/commit/c546bcd85bc8ee6d77926ad655c2696eea270ef1))
- Automatically resolve `.traceSpans.root` ([99eb5e2](https://github.com/serverless/console/commit/99eb5e2f20cd60c3e99c75d7e33e70845ef7f9b2))
## [0.3.0](https://github.com/serverless/console/compare/@serverless/sdk@0.2.4...@serverless/sdk@0.3.0) (2023-01-12)

@@ -7,0 +14,0 @@

@@ -5,2 +5,14 @@ # Serverless SDK

### `.name`
Name of the used SDK package. By default `@serverless/sdk`, but if environment extension is used, it's overriden (to e.g. `@serverless/aws-lambda-sdk`)
### `.version`
Package version
### `.orgId`
Authenticated Serverless Console organization id
### `.traceSpans`

@@ -10,7 +22,7 @@

### `serverlessSdk.instrumentation`
### `.instrumentation`
Most of the instrumentation is setup automatically, still there are scenarios when it's difficult to ensure that (e.g. when target modules are imported as ESM, or come from bundles). In such case instrumentation need to be set manually. In context of `@serverless/sdk` following instrumentation extensions are provided:
- `.expressApp.install(express)` - Instrument Express. See [instrumentatiom/express-app](instrumentation/express-app.md)
- `.instrumentation.expressApp.install(express)` - Instrument Express. See [instrumentatiom/express-app](instrumentation/express-app.md)

@@ -34,1 +46,8 @@ ### `.captureError(error[, options])`

- `fingerprint` _(string)_ - Console UI groups common warnings by the _fingerprint_, which by default is derived from its message. This can be overriden by passing custom `fingeprint` value
### `.setTag(name, value)`
Set custom (user defined) tag on root span
- `name` _(string)_ - Tag name, can contain alphanumeric (both lower and upper case), `-`, `_` and `.` characters
- `value` (any) - Tag value. Can be _string_, _boolean_, _number_, _Date_ or _Array_ containing any values of prior listed types

@@ -26,3 +26,7 @@ 'use strict';

serverlessSdk.version = pkgJson.version;
serverlessSdk.traceSpans = {};
serverlessSdk.traceSpans = {
get root() {
return TraceSpan.rootSpan;
},
};
serverlessSdk.instrumentation = {};

@@ -41,2 +45,8 @@ Object.defineProperties(

};
serverlessSdk.setTag = (name, value) => {
if (!serverlessSdk.traceSpans.root) {
throw new Error('Cannot set tag with no root trace span being initialized');
}
serverlessSdk.traceSpans.root.customTags.set(name, value);
};

@@ -43,0 +53,0 @@ // Private

27

lib/trace-span.js

@@ -20,2 +20,4 @@ 'use strict';

const objHasOwnProperty = Object.prototype.hasOwnProperty;
class StringifiableSet extends Set {

@@ -29,7 +31,5 @@ toJSON() {

let rootSpan;
class TraceSpan {
static resolveCurrentSpan() {
return asyncLocalStorage.getStore() || rootSpan || null;
return asyncLocalStorage.getStore() || TraceSpan.rootSpan || null;
}

@@ -66,7 +66,7 @@

if (options.output != null) this.output = options.output;
if (!rootSpan) {
rootSpan = this;
if (!TraceSpan.rootSpan) {
TraceSpan.rootSpan = this;
this.parentSpan = null;
} else {
if (rootSpan.endTime) {
if (TraceSpan.rootSpan.endTime) {
throw Object.assign(new Error('Cannot intialize span: Trace is closed'), {

@@ -77,3 +77,5 @@ code: 'UNREACHABLE_TRACE',

this.parentSpan = TraceSpan.resolveCurrentSpan();
while (this.parentSpan.endTime) this.parentSpan = this.parentSpan.parentSpan || rootSpan;
while (this.parentSpan.endTime) {
this.parentSpan = this.parentSpan.parentSpan || TraceSpan.rootSpan;
}
}

@@ -95,3 +97,3 @@

if (asyncLocalStorage.getStore() !== this) return;
if (this === rootSpan) {
if (this === TraceSpan.rootSpan) {
asyncLocalStorage.enterWith(this);

@@ -102,3 +104,3 @@ return;

if (!span.endTime) return span;
return span.parentSpan ? self(span.parentSpan) : rootSpan;
return span.parentSpan ? self(span.parentSpan) : TraceSpan.rootSpan;
})(this.parentSpan);

@@ -130,3 +132,3 @@ asyncLocalStorage.enterWith(openParentSpan);

this.endTime = targetEndTime || defaultEndTime;
if (this === rootSpan) {
if (this === TraceSpan.rootSpan) {
const leftoverSpans = [];

@@ -167,2 +169,3 @@ for (const subSpan of this.spans) {

tags: this.tags,
customTags: objHasOwnProperty.call(this, 'customTags') ? this.customTags : undefined,
};

@@ -181,2 +184,5 @@ }

tags: toProtobufTags(this.tags),
customTags: objHasOwnProperty.call(this, 'customTags')
? JSON.stringify(this.customTags)
: undefined,
};

@@ -217,2 +223,3 @@ }

tags: d(() => new Tags()),
customTags: d(() => new Tags()),
})

@@ -219,0 +226,0 @@ );

{
"name": "@serverless/sdk",
"repository": "serverless/console",
"version": "0.3.0",
"version": "0.3.1",
"author": "Serverless, Inc.",

@@ -6,0 +6,0 @@ "dependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc