New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aws-lambda-powertools/tracer

Package Overview
Dependencies
Maintainers
3
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-lambda-powertools/tracer

The tracer package for the Powertools for AWS Lambda (TypeScript) library

  • 2.13.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
120K
decreased by-21.04%
Maintainers
3
Weekly downloads
 
Created

What is @aws-lambda-powertools/tracer?

@aws-lambda-powertools/tracer is an npm package designed to simplify the implementation of distributed tracing in AWS Lambda functions. It helps in capturing and propagating trace data, making it easier to monitor and debug serverless applications.

What are @aws-lambda-powertools/tracer's main functionalities?

Initialize Tracer

This code initializes the Tracer object, which is the starting point for using the tracing functionalities provided by the package.

const { Tracer } = require('@aws-lambda-powertools/tracer');
const tracer = new Tracer();

Capture Lambda Handler

This code demonstrates how to wrap a Lambda handler with the tracer to automatically capture trace data for the entire function execution.

const { Tracer } = require('@aws-lambda-powertools/tracer');
const tracer = new Tracer();

exports.handler = tracer.captureLambdaHandler(async (event, context) => {
  // Your Lambda function code here
  return { statusCode: 200, body: 'Hello World' };
});

Capture Method

This code shows how to use the @tracer.captureMethod() decorator to capture trace data for individual methods within a class.

const { Tracer } = require('@aws-lambda-powertools/tracer');
const tracer = new Tracer();

class MyService {
  @tracer.captureMethod()
  myMethod() {
    // Your method code here
  }
}

Add Annotation

This code demonstrates how to add custom annotations to the trace, which can be useful for adding additional context to the trace data.

const { Tracer } = require('@aws-lambda-powertools/tracer');
const tracer = new Tracer();

exports.handler = tracer.captureLambdaHandler(async (event, context) => {
  tracer.annotate('key', 'value');
  // Your Lambda function code here
  return { statusCode: 200, body: 'Hello World' };
});

Add Metadata

This code shows how to add custom metadata to the trace, which can be useful for adding structured data to the trace.

const { Tracer } = require('@aws-lambda-powertools/tracer');
const tracer = new Tracer();

exports.handler = tracer.captureLambdaHandler(async (event, context) => {
  tracer.addMetadata('key', { foo: 'bar' });
  // Your Lambda function code here
  return { statusCode: 200, body: 'Hello World' };
});

Other packages similar to @aws-lambda-powertools/tracer

Keywords

FAQs

Package last updated on 28 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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