Socket
Socket
Sign inDemoInstall

lambda-log-wrapper

Package Overview
Dependencies
1
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lambda-log-wrapper

This is wrapper around node lambda which calls and logs


Version published
Maintainers
1
Install size
58.1 MB
Created

Readme

Source

Lambda Logger

  • 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

Last updated on 02 Feb 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc