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

concurix-transactionlog

v1.0.1

Published

Log transactions (by string id) and collect stats on measurements over time.

Downloads

113

Readme

concurix-transactionlog

Logs transactions (by string id) and collects stats over time about them. This tool is part of the concurix node.js instrumentation.

var TransactionLog = require("concurix-transactionlog")
var tlog = new TransactionLog({
  raw_subset: true,
  subset_stats: true,
  transactions_per_ms: true
})

tlog.update("/index.html", 13)
tlog.update("/index.html", 22)
tlog.update("/user/foo?blah=zap", 101)

var subset = tlog.reapSubset()
console.log(JSON.stringify(subset, null, 2))

/*
{
  "start": 1403045590568,
  "end": 1403045590569,
  "transactions": {
    "/index.html": {
      "stats": {
        "n": 2,
        "min": 13,
        "max": 22,
        "sum": 35,
        "mean": 17.5,
        "variance": 20.25,
        "standard_deviation": 4.5
      },
      "subset": [
        13,
        22
      ],
      "subset_stats": {
        "n": 2,
        "min": 13,
        "max": 22,
        "sum": 35,
        "mean": 17.5,
        "variance": 20.25,
        "standard_deviation": 4.5
      },
      "transactions_per_ms": {
        "n": 1,
        "min": 2,
        "max": 2,
        "sum": 2,
        "mean": 2,
        "variance": 0,
        "standard_deviation": 0
      }
    },
    "/user/foo?blah=zap": {
      "stats": {
        "n": 1,
        "min": 101,
        "max": 101,
        "sum": 101,
        "mean": 101,
        "variance": 0,
        "standard_deviation": 0
      },
      "subset": [
        101
      ],
      "subset_stats": {
        "n": 1,
        "min": 101,
        "max": 101,
        "sum": 101,
        "mean": 101,
        "variance": 0,
        "standard_deviation": 0
      },
      "transactions_per_ms": {
        "n": 1,
        "min": 1,
        "max": 1,
        "sum": 1,
        "mean": 1,
        "variance": 0,
        "standard_deviation": 0
      }
    }
  }
}
*/

setTimeout(function () {
  tlog.update("/index.html", 50)
  var subset = tlog.reapSubset()
  console.log(JSON.stringify(subset, null, 2))
}, 1000)

/*
{
  "start": 1403045590568,
  "end": 1403045591581,
  "transactions": {
    "/index.html": {
      "stats": {
        "n": 3,
        "min": 13,
        "max": 50,
        "sum": 85,
        "mean": 28.333333333333336,
        "variance": 248.2222222222222,
        "standard_deviation": 15.755069730795297
      },
      "subset": [
        50
      ],
      "subset_stats": {
        "n": 1,
        "min": 50,
        "max": 50,
        "sum": 50,
        "mean": 50,
        "variance": 0,
        "standard_deviation": 0
      },
      "transactions_per_ms": {
        "n": 2,
        "min": 0.0009871668311944718,
        "max": 2,
        "sum": 2.0009871668311945,
        "mean": 1.0004935834155972,
        "variance": 0.9990130767933937,
        "standard_deviation": 0.9995064165844028
      }
    }
  }
}
*/

API

var transactionLog = require("concurix-transactionlog")(config)

Create a new transaction log

config:

  • raw_subset [false]: show the raw values for each member of this subset
  • subset_stats: [true]: show stats for just this subset
  • transactions_per_ms: [true]: show transactions per millisecond stats

transactionLog.update(transactionId, measurement)

Log an instance of this transaction. transactionId should be a string and measurement should be a number.

transactionLog.reapSubset()

Extract the current subset of the transaction log and clear the subset buffer.

When reaped, statistics for each transaction id that was active in this subset is returned, with optional fields depending on the config provided.

  • stats: statistics for this tansaction id for all history
  • subset: raw values for this subset
  • subset_stats: statistics for just this subset
  • transactions_per_ms: Instances of this transaction id per millisecond, sampled at each reapSubset() call for all history.

Long-term stats are kept intact between reapSubset calls.

transactionLog.clearAll()

Completely empty the transaction log of all transactions and long-term stats.

LICENSE

Concurix Terms Of Service