Add an error to the current segment or subsegment as metadata.
Error to serialize as metadata
Add response data to the current segment or subsegment as metadata.
Data to serialize as metadata
Name of the method that is being traced
Add service name to the current segment or subsegment as annotation.
Add ColdStart annotation to the current segment or subsegment.
If Tracer has been initialized outside the Lambda handler then the same instance
of Tracer will be reused throughout the lifecycle of that same Lambda execution environment
and this method will annotate ColdStart: false
after the first invocation.
Patch all AWS SDK v2 clients and create traces when your application makes calls to AWS services.
If you want to patch a specific client use captureAWSClient and if you are using AWS SDK v3 use captureAWSv3Client instead.
AWS SDK v2 import
AWS - Instrumented AWS SDK
Patch a specific AWS SDK v2 client and create traces when your application makes calls to that AWS service.
If you want to patch all clients use captureAWS and if you are using AWS SDK v3 use captureAWSv3Client instead.
AWS SDK v2 client
service - Instrumented AWS SDK v2 client
Patch an AWS SDK v3 client and create traces when your application makes calls to that AWS service.
If you are using AWS SDK v2 use captureAWSClient instead.
AWS SDK v3 client
service - Instrumented AWS SDK v3 client
A decorator automating capture of metadata and annotations on segments or subsegments for a Lambda Handler.
Using this decorator on your handler function will automatically:
ColdStart
annotationNote: Currently TypeScript only supports decorators on classes and methods. If you are using the function syntax, you should use the middleware instead.
A decorator automating capture of metadata and annotations on segments or subsegments for an arbitrary function.
Using this decorator on your function will automatically:
Note: Currently TypeScript only supports decorators on classes and methods. If you are using the function syntax, you should use the middleware instead.
Get the active segment or subsegment in the current scope.
Usually you won't need to call this method unless you are creating custom subsegments or using manual mode.
segment - The active segment or subsegment in the current scope.
Get the current value of the tracingEnabled
property.
You can use this method during manual instrumentation to determine if tracer is currently enabled.
tracingEnabled - true
if tracing is enabled, false
otherwise.
Adds annotation to existing segment or subsegment.
Annotation key
Value for annotation
Adds metadata to existing segment or subsegment.
Metadata key
Value for metadata
Namespace that metadata will lie under, if none is passed it will use the serviceName
Sets the passed subsegment as the current active subsegment.
If you are using a middleware or a decorator this is done automatically for you.
Subsegment to set as the current segment
Generated using TypeDoc
Intro
Tracer is an opinionated thin wrapper for AWS X-Ray SDK for Node.js.
Tracing data can be visualized through AWS X-Ray Console.
Key features
Usage
For more usage examples, see our documentation.
Functions usage with middleware
If you use function-based Lambda handlers you can use the captureLambdaHandler() middy middleware to automatically:
ServiceName
andColdStart
annotationsObject oriented usage with decorators
If instead you use TypeScript Classes to wrap your Lambda handler you can use the @tracer.captureLambdaHandler() decorator to automatically:
ServiceName
andColdStart
annotationsFunctions usage with manual instrumentation
If you prefer to manually instrument your Lambda handler you can use the methods in the tracer class directly.