@aws-lambda-powertools/tracer
Version:
The tracer package for the Powertools for AWS Lambda (TypeScript) library
34 lines • 1.37 kB
TypeScript
import type { MiddlewareLikeObj } from '@aws-lambda-powertools/commons/types';
import type { Tracer } from '../Tracer.js';
import type { CaptureLambdaHandlerOptions } from '../types/Tracer.js';
/**
* A middy middleware automating capture of metadata and annotations on segments or subsegments for a Lambda Handler.
*
* Using this middleware on your handler function will automatically:
* * handle the subsegment lifecycle
* * add the `ColdStart` annotation
* * add the function response as metadata
* * add the function error as metadata (if any)
*
* @example
* ```typescript
* import { Tracer } from '@aws-lambda-powertools/tracer';
* import { captureLambdaHandler } from '@aws-lambda-powertools/tracer/middleware';
* import middy from '@middy/core';
*
* const tracer = new Tracer({ serviceName: 'serverlessAirline' });
*
* const lambdaHandler = async (_event: any, _context: any) => {
* ...
* };
*
* export const handler = middy(lambdaHandler).use(captureLambdaHandler(tracer));
* ```
*
* @param target - The Tracer instance to use for tracing
* @param options - (_optional_) Options for the middleware
* @returns middleware - The middy middleware object
*/
declare const captureLambdaHandler: (target: Tracer, options?: CaptureLambdaHandlerOptions) => MiddlewareLikeObj;
export { captureLambdaHandler };
//# sourceMappingURL=middy.d.ts.map