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

leanengine-apm

v0.5.0

Published

LeanEngine application performance monitoring

Downloads

5

Readme

LeanEngine APM

这个包将会取代 leanengine-sniper 来为 云引擎 上的 Node.js 应用提供应用级别的性能统计分析。

先安装这个包:

npm install --save leanengine-apm

然后访问 apm.leanapp.cn,通过 LeanCloud 登录,为你的应用获取一个 Token,然后在你的 server.js 中添加(确保添加到加载 leanengine 之前):

var apm = require('leanengine-apm');
apm.init('c4f7ddfebc2d107fa6b7097506ea4c3742e76044'); // 你的 Token

如果遇到问题请到我们的 技术支持论坛 反馈,更新历史见 Releases 页面。

路由统计

然后在 app.js 中添加下面这行代码即可开启路由统计:

app.use(require('leanengine-apm').express());

任务统计

你还可以使用 wrapTask 来统计特定的函数,例如你有一个 sendMail 的函数:

var sendMail = function(template, address) {
  // ...
};

那么你可以用 wrapTask 包装一下这个函数:

var apm = require('leanengine-apm');
var sendMail = apm.wrapTask('sendMail', function(template, address) {
  // ...
});

wrapTask 用于包装返回 Promise 的函数,此外还有一个 wrapCallbackTask 用于包装回调风格的函数。你还可以使用 runTask 来为统计添加更多筛选标签:

var sendMail = function(template, address) {
  return apm.runTask('sendMail', {template: template}, function() {
    // ...
  });
};

建议取值数量有限的字段作为标签才有筛选和分组的意义,请勿使用每次执行值都不同的字段作为标签。