Releases: terodox/aws-xray-lambda-promise-subsegment
Update dependencies
Fix some small issues
The build was failing and therefore the last version failed.
This is a fix for that failure.
AWS SDK v3 and Drop Node 10 support
This change come with 2 breaking changes:
- Dropped support for Node version 10
- Updated to version 3 of aws-xray-sdk-core
Added:
- Now exporting type definitions for aws-xray-sdk-core items that are applicable to this package.
fix type definition
fix type definition causing 'error TS2314: Generic type 'Promise requires 1 type argument(s).
Thanks again to @peteroreil for the contribution!
Add a simple function for basic use cases
This minor version introduces a new function to handle very basic use cases.
addSegment
has a very basic contract:
function addSegment<T>(segmentName: string, promise: Promise): Promise<T>;
It's the simplest form possible for adding a new segment to a trace.
Allow nested traces
🚨BREAKING CHANGES🚨
This release brings the ability to run nested traces along with a reworking of the method contract.
A key change here is the move from promiseFactory being a promise - to promiseFactory now being a function! Check out the signature below for more information.
// Old contract
export declare function addPromiseSegment<T>(subSegmentName: string, promiseToWrap: Promise<T>, additionalMetaData?: Metadata, annotations?: Annotations): Promise<T>;
// New Contract
export declare function addPromiseSegment<T>({
annotations,
metaData,
parentSegment,
promiseFactory,
segmentName
}: {
annotations?: Annotations,
metaData?: Metadata,
parentSegment?: object,
promiseFactory: (subsegment) => Promise<T>,
segmentName: string
}): Promise<T>;
This give more flexibility with adding annotations without metadata and vice-versa. The additional benefit is the passing out of the subsegment in the promiseFactory
. This will allow you to pass that new subsegment as the parentSegment
for another promise subsegment creating a hierarchy of calls in X-Ray.
NOTE: The most important change here is moving from passing in a promise, to passing in a promiseFactory that will return a promise.