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

lambda-log-timer

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lambda-log-timer

This timer adds pre- and post- hooks to a lamdba function for logging the duration of a call

  • 0.0.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Lambda Timer

  • Adds pre and post hooks to a lamdba function so that we can generate duration data, and simplify the output of a single lambda call into a single log entry with a unified format

  • This npm package logs data about calls to lambda functions including:

    • Duration
    • Request/ Response objects
  • Log the duration of a call from <caller-name> to <invoked-name> to a Log group with a naming convention of /metric/lambda/correlation/<caller-name>/<invoked-name>

When using serverless

  • Serverless automatically appends the stage variable to lambda functions when deploying to aws
  • It is suggested you add the stage variable as an environment variable for your lamdba functions. This allows you to dynamically piece together the correct funciton name for the stage being tested
var funcitonName = 'helloworld' + '-' + process.env.STAGE;

Usage

// Initialize lambda logger
var Lambda = require('lambda-logger');

exports.handler = (event, context, callback) => {
    // Pass the context object to lambda wrapper
    var lambda = new Lambda(context);

    // Invoke function
    var request = {
        FunctionName: 'Helloworld',
        ProcessId: pid,
        TranactionId: tid
    };
    lambda.invoke(request)
    .then((response) => {
        // Do work ...

        // Chaining calls
        var request = {
            FunctionName: 'Goodbyeworld',
            ProcessId: pid,
            TranactionId: tid
        };
        return lambda.invoke(request);
    })
    .then(() => {
        // Do final steps
    })
    .catch((err) => {
        // Error within promsise chain
    });
}

TODO:

  • Update the Security template give functions permission to:
    • Create log group
    • put cloudwatch metrics
  • Update the application template
    • Add new npm package
  • test promise chaining
  • implement callback version

Keywords

FAQs

Package last updated on 02 Feb 2017

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