npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@telemetry-js/publisher-cloudwatch

v1.0.0

Published

Publish single or summary metrics to AWS CloudWatch

Downloads

3

Readme

publisher-cloudwatch

Publish single or summary metrics to AWS CloudWatch.
A telemetry plugin.

npm status node Test JavaScript Style Guide

Table of Contents

Usage

With Telemetry

const telemetry = require('@telemetry-js/telemetry')()
const cloudwatch = require('@telemetry-js/publisher-cloudwatch')

telemetry.task()
  .publish(cloudwatch)

// Or with options
telemetry.task()
  .publish(cloudwatch, { /* options */ })

If an HTTP request to CloudWatch fails, it is retried. If it fails 5 times, an error event will be emitted and in this case forwarded to telemetry:

telemetry.on('error', (err) => {
  console.error(err)
})

Standalone

Useful to publish one-time metrics.

const cloudwatch = require('@telemetry-js/publisher-cloudwatch')
const single = require('@telemetry-js/metric').single

const publisher = cloudwatch()
const metric = single('myapp.example.count', { unit: 'count', value: 10 })

publisher.publish(metric)

await publisher.flush()

The flush method will yield an error if the HTTP request failed (after retries).

To publish multiple metrics (in one HTTP request), repeat the .publish() call before .flush():

const metric1 = single('myapp.example.count', { unit: 'count', value: 10 })
const metric2 = single('myapp.foobar.bytes', { unit: 'bytes', value: 10 })

publisher.publish(metric1)
publisher.publish(metric2)

await publisher.flush()

Options

  • namespace: string, defaults to telemetry
  • retry: boolean, defaults to true
  • retryDelay: number, milliseconds, defaults to 1000
  • timeout: socket timeout, number, milliseconds, defaults to 60 seconds
  • credentials: AWS credentials in the form of { accessKeyId, secretAccessKey }. You normally don't need to set this, as credentials are fetched with awscred which supports EC2, ECS, Lambda, ..
  • region: AWS CloudWatch region. You normally don't need to set this, as it is fetched with awscred.

Install

With npm do:

npm install @telemetry-js/publisher-cloudwatch

Acknowledgements

This project is kindly sponsored by Reason Cybersecurity Ltd.

reason logo

License

MIT © Vincent Weevers