Socket
Book a DemoInstallSign in
Socket

@dazn/lambda-powertools-middleware-sample-logging

Package Overview
Dependencies
Maintainers
7
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dazn/lambda-powertools-middleware-sample-logging

Middy middleware to sample debug logs for a configurable % of invocations

1.29.0
latest
npmnpm
Version published
Maintainers
7
Created
Source

lambda-powertools-middleware-sample-logging

A Middy middleware that will enable debug logging for a configurable % of invocations. Defaults is 1%.

Main features:

  • integrates with the @dazn/lambda-powertools-logger package to enable debug logging

  • integrates with the @dazn/lambda-powertools-correlation-ids package to allow sampling decision to flow through correlation IDs - i.e. enable debug logging at the edge, and the entire call chain will respect that decision

  • enables debug logging for some % (defaults to 1%) of invocations

  • records an error log message with the invocation event as attribute when an invocation errors

Getting Started

Install from NPM: npm install @dazn/lambda-powertools-middleware-sample-logging

Alternatively, if you use the template @dazn/lambda-powertools-pattern-basic then this would be configured for you.

API

Accepts a configuration object of the following shape:

{
  sampleRate: double [between 0 and 1]
}
const middy = require('middy')
const sampleLogging = require('@dazn/lambda-powertools-middleware-sample-logging')

const handler = async (event, context) => {
  return 42
}

module.exports = middy(handler)
  .use(sampleLogging({ sampleRate: 0.01 }))
}

This middleware is often used alongside the @dazn/lambda-powertools-middleware-correlation-ids middleware to implement sample logging. It's recommended that you use the @dazn/lambda-powertools-pattern-basic which configures both to enable debug logging at 1% of invocations.

FAQs

Package last updated on 04 May 2021

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.