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

kagent

v0.1.9

Published

<p align=center> <h1>KAgent</h1> <a href="https://github.com/kaola-fed/kagent"> <img src="https://img.shields.io/npm/v/kagent.svg?style=for-the-badge"/> </a> <a href="https://travis-ci.org/kaola-fed/kagent"> <img src="https

Downloads

3

Readme

特性

  • 内置应用度量标准 Metrics,支持应用打点;
  • 内置 Node.js 进程级信息收集任务,支持外部扩展;
  • 内置 Filesystem Reporter 上报监控信息,支持自定义;

API 介绍

start(options, callback)

const KAgent = require('kagent');
KAgent.start({
    name: 'appName',
    reporter: ['filesystem'],
    tasks: [],
    rundir: path.join(__dirname, 'fixtures/run'),
    flushInterval: 1000,
    files: {
        'built-in': path.join(__dirname, 'fixtures/kagent/built-in.log'),
        application: path.join(__dirname, 'fixtures/kagent/application.log'),
        error: path.join(__dirname, 'fixtures/common-error.log')
    }
}, (err, results) => {

});

new Metrix({ files })

const { Metrix } = require('kagent');
const metrix = new Metrix({
    files: {
        'built-in': path.join(__dirname, 'fixtures/kagent/built-in.log'),
        application: path.join(__dirname, 'fixtures/kagent/application.log'),
        error: path.join(__dirname, 'fixtures/common-error.log')
    }
});

getCounter()

const counter = metrix.getCounter();
counter.inc();
counter.dec();

getGuage()

const guage = metrix.getGuage();
guage.setValue();

getHistogram()

const histogram = metrix.getHistogram();
histogram.update(1);

getMeter()

const meter = metrix.getMeter();
meter.mark();

getTimer()

const timer = metrix.getTimer();
// some async thing
// await xxx();
timer.end();

addMetric(scope, metric, tag?)

metrix.addMetric(['connection'], counter);
metrix.addMetric(['cpu'], guage);
metrix.addMetric(['histogram'], histogram);
metrix.addMetric(['meter'], meter);
metrix.addMetric(['access'], timer);

概念抽象

Logger

应用运行的过程中的 Metrics 记录,会运行在 worker 进程。

Collector

Metrics 的收集者,负责定期的执行 Task 任务,并合并所有 Task 的输出,调用 Reporter 上报。

Task

Task 是 Collector 得以生成 Metrics 信息的载体,每个 Task 都允许设定执行时间,不设定执行时间,或是和默认的执行周期一致的,则会推入到 collect 阶段前执行。

有以下内置的 Task:

Process Task

收集所有运行中的 Node.js 进程运行信息,包括 CPU 占用率、内存占用、启动参数等等。

Metrix Parser Task

分析应用/框架的打点记录,用于生成 QPS/RT 等关键指标,也可用于业务数据的打点。

Clean Log Task

定期清除 KAgent 的运行日志,以防撑爆硬盘.

Agent

服务端的代理人,包括:

  1. 执行服务端命令;
  2. 上报 Metrics 信息。

Reporter

由 Collector 驱动,进行 Metrics 上报,内置落盘文件的 Reporter。

Filesystem Reporter

落盘 JSON 文件,一般可由系统 agent 采集,汇总到自家的监控系统。

LICENSE

MIT