pn-retail-metrics

Writes formatted metric logs by wrapping console.log (stdout).

Usage no npm install needed!

<script type="module">
  import pnRetailMetrics from 'https://cdn.skypack.dev/pn-retail-metrics';
</script>

README

A nodejs metric writer for AWS Lambda

  • Writes logs to stdout using console.log
  • Built using typescript and includes types

Basic example

import { APIGatewayEvent } from 'aws-lambda';
import { metric } from 'pn-retail-metrics';
import { ok } from '../aws/response';

export const healthCheck = async (event: APIGatewayEvent) => {
  metric.log({
    itemId: 'string',
    sourceId: 'string',
    ssId: 'string',
    action: 'Updated items info',
    functionName: 'string',
    countryCode: 'string'
  });
};
  // Output
  {
    "timestamp": '2020-06-17T10:45:03.944Z',
    "level": "METRIC",
    "itemId": "string",
    "sourceId": "string"
    "ssId": "string",
    "action": "Updated items info",
    "functionName": "string",
    "countryCode": "string"
  }