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 🙏

© 2026 – Pkg Stats / Ryan Hefner

openfalcon-perfcounter

v0.0.2

Published

Connect Metrics and Open-Falcon for Node.js

Readme

说明

Open-Falcon 是小米运维部开源的一款互联网企业级监控系统解决方案,分为Agent、Transfe、Graph、Sender、Judge等模块。Agent会定时搜集机器的相关信息并上报;同时可以接收用户自定义数据

Metrics 提供了强大的统计功能,分为guage、counter、meter、histogram、timer 5种基础数据结构。其Node实现为Node Metrics

本模块 基于Node实现,主要功能为:

  1. 提供简易调用接口
  2. 统计分析相关数据
  3. 转换数据为Agent可接受格式
  4. 定时发送数据到Agen

使用方式

安装

npm install openfalcon-perfcounter

调用

var PerfCounter = require('openfalcon-perfcounter').getInstance();
PerfCounter.count(eventName, count);            // 统计次数,可形成频率
PerfCounter.duration(eventName, duration);      // 统计时间,可形成分布

就是这么简单,相关数据在搭建好的Falcon平台上就可以看到了。

API

1.引入 var OP = require('openfalcon-perfcounter');

2.设置 OP.setOption(option); 初始设置:

{
  agentUri: 'http://127.0.0.1:1988/v1/push',
  step: 60,         // 每隔60秒向agent发送一次数据
  endpoint: os.hostname() || 'localhost',
  cluster: {
    connInterval: 1
  }
};

若不调用,则使用初始设置。

3.获取实例

var PerfCounter = OP.getInstance();             // 用于普通模式
var PerfCounter = OP.getClusterInstance();      // 用于cluster模式

若使用cluster模式,需调用getClusterInstance()。因为多个进程就同一event向Agent发送数据,Agent不会自动加和;若调用getClusterInstance(),PerfCounter会在每个worker进程向master进程发送数据,由master进程加和后发送给Agent。

4.设置Tag PerfCounter.addTags(eventName, {k1: v1, k2: v2})

Tag 会发送到Agent模块。

5.计数

PerfCounter.count(eventName, count);            // 统计次数,可形成频率
PerfCounter.duration(eventName, duration);      // 统计时间,可形成分布

perfCounter会自动分析出count()的 CPS-1-min、CPS-5-min、CPS-15-min,即1分钟、5分钟、15分钟内的调用频率(次/秒)

PerfCounter会自动分析出duration()的 75-percentile、95-percentile、99-percentile、999-percentile,即75%、95%、99%、99.9% 采样的最大时间。

6.详细控制

同时提供 incCounter、markMeter、updateHistogram、updateTimer 四种方法进行更精确的控制。其实count()与duration()就是利用meter及timer实现的。具体查看代码吧。