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

kafkajs-metrics

v1.0.0

Published

Metrics package for KafkaJS

Downloads

900

Readme

KafkaJSMetrics

A lightweight KafkaJS library that provides simple access to key metrics within your code. KafkaJSMetrics enables custom breakpoint alerts and logging of key metrics, allowing for client health to be monitored within applications.

Table of Contents

Introduction

Apache Kafka is a distributed event streaming platform that is designed to handle high performance data pipelines in real-time. KafkaJS is a lightweight, user-friendly Apache Kafka client library that runs on Node.js, providing a simple and reliable way to produce and consume messages from Kafka clusters. Event emitters called instrumentation events are built into KafkaJS and provide information about the performance and behavior of a user's Kafka producers and consumers. These events are designed to help developers monitor and troubleshoot their Kafka applications. However, incorporating instrumentation events into code can be tedious and repetitive.

KafkaJSMetrics is a continuously-growing open source product that is designed to simplify and shorten the metric exposing processes. By committing to 100% Javascript alongside KafkaJS, the library leverages already built-in instrumentation events without relying on other third-party applications or requiring any additional installations. The library gives developers simple access to key metrics required to monitor the health of a Kafka instance.

Features

Below are some of the key features from KafkaJSMetrics. For a full explanation of library functionality, visit our docs.

Key features:

  • Access to key consumer/producer/admin metrics, including

    • offset lag
    • messages consumed
    • total number of consumer/producer/admin currently connected
    • heartbeat
    • partition assignment
    • see docs for complete metrics
  • Custom Breakpoint Alerts and On/Off metrics logging options, including

    • heartbeat monitor
    • request queue size monitor
    • request pending duration monitor
    • offset lag monitor
    • see docs for complete Breakpoint Alert and metrics logging options

For information about the web browser visualizer display feature that pairs with the kafkaJSMetrics library, visit our main visualizer branch


Getting Started

KafkaJSMetrics works with your KafkaJS client. For information on setting up your KafkaJS client, visit KafkaJS.

  • Installation and Usage walk through setting up the KafkaJSMetrics library for use within your KafkaJS Client code

Installation


Install the kafkajs-metrics package from npm

npm install kafkajs-metrics

Usage

KafkaJSMetrics works with your existing KafkaJS client. More information about KafkaJS at kafka.js.org.

  1. Require KafkaJSMetrics in your KafkaJS Client file to access metricize function
  1. Pass your KafkaJS Client instance into the metricize function (sample KafkaJS Client provided)

    • All consumer, producer, and admin instances created from this client will now have metrics and metrics-associated functionality
  1. Run your KafkaJS Client file
node client.js

Turn on logging methods

Visit the docs for a full list of available logging methods

Example:

Prints to console:

Turn on breakpoint alerts

Visit the docs for a full list of available breakpoint alert methods

Example:

Prints to console:


Community

As KafkaJSMetrics continues to grow, we welcome and encourage feedback! We are also always trying to improve our code so we actively welcome all contributions! If you would like to be a part of this product, please follow the steps below.

  1. Fork this repo of KafkaJSMetrics and then clone it to your machine

  2. Check out into the branch that you want to make contributions in

    1. Contributions to the library:

      git checkout library
  3. Create a feature branch

git checkout -b [feature/AmazingFeature]
  1. Add all your changes with the add command
git add [all your changes]
  1. Commit all your changes
git commit -m '<your comment>'
  1. Make sure the library branch is up to date

    1. Check back out to the library branch
    git checkout library
    1. Pull down the latest version
    git pull origin library
    1. Check back out to your feature branch
    git checkout [feature/AmazingFeature]
  2. Merge your branch with library

git merge library
  1. Resolve any merge conflicts
  2. Run unit tests and make sure all tests pass
npm test
  1. Push up your branch with the command
git push origin [feature/AmazingFeature]
  1. Finally, open a pull request for us to review!

Contributors


Other

Important links:

KafkaJSMetrics is licensed under the Mozilla Public License version 2.0 and are available for free. We have no affiliation with and are not endorsed by either The Apache Software Foundation or the developers of KafkaJS.