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

lytics

v0.1.4

Published

Analyses server performance

Downloads

5

Readme

Lytics

Lytics provides really simple analytics for Express applications built on top of Node.js. It works by plugging in one middleware function into your application just like Morgan. The middleware injected by this package has minimal overhead on your application's performance. For every request that the app receives Lytics will measure the duration and collect the request data including url, method, timestamp, ip.

Requiring Lytics in your app will spin up a logging server on port 5151 listening for the request data objects. As the responses to the requests are finished sending, Lytics will send the request metadata collected above to the logging server via web-sockets. The logging server expects a Mongodb instance running locally on port 27017, where it writes the data received.

One more thing, opening up localhost:5151 on your browser will provide you with a live stream of all requests being served by your app server along with request metadata.

Data logged by Lytics

For every request handled by your app server, Lytics will record the following data about the request:

  • Duration (ms)
  • Timestamp
  • URL
  • HTTP Method
  • IP
  • Query parameters (wip)
  • Body length (wip)

Use Case

The idea is to be able to run aggregation on the logged data to gain insights into how the app server is performing. It will help you

  • find out endpoints that are the current bottlenecks in your app's performance
  • monitor the health of critical endpoints of your app

Setup

  1. Run npm install --save lytics to install.

  2. Require lytics using this command to use it with your Express app

    // Require lytics using this command
    var lytics = require('lytics');
  3. Use middleware returned by lytics by the instance of the Express app

    var express = require('express');
    var app = express();
       
    // Use middleware returned by lytics
    app.use(lytics());

Requirements

  1. An instance of MongoDB should be running locally on port 27017.

  2. Port 5151 should be available for running the logging server.

Realtime monitoring

Point your browser to localhost:5151 while running Lytics to monitor your app in realtime. The client connects to the logging server via web-sockets and receives the above data as it is being received by the logging server. To view the data, open the console on the browser and enjoy the realtime feed of request data.

request data