zoukankan      html  css  js  c++  java
  • Fundebug后端Node.js插件更新至0.2.0,支持监控Express慢请求

    摘要: 性能问题也是BUG,也需要监控。

    Fundebug后端Node.js异常监控服务

    Fundebug是专业的应用异常监控平台,我们Node.js插件fundebug-nodejs可以提供全方位的异常监控,支持ExpressKoa以及Hapi框架。

    从用户的角度理解,性能问题某种程度上也是BUG,它可能是数据库的索引问题,可能是代码算法问题,也可能是业务逻辑的设计有问题。为了帮助大家快速定位性能BUG,fundebug-nodejs插件更新至0.2.0,支持监控Express慢请求。

    不过,Fundebug暂时无意于提供全面的性能监控服务,我们将继续专注于BUG监控。

    监控Express慢请求

    监控Express慢请求,需要配置阈值httpTimeout,并且添加ExpressTimeoutHandler中间件。

    fundebug.httpTimeout = 1000;
    app.use(fundebug.ExpressTimeoutHandler());
    

    注意,Fundebug的慢请求监控中间件ExpressTimeoutHandler必须放在其他中间件之前。

    这样,所有花费时间超过阈值1000ms的请求都会上报到Fundebug。

    fundebug-express-demo

    关于Express如何接入Fundebug异常监控服务,不妨查看我们的Demo项目fundebug-express-demo

    const express = require("express");
    const app = express();
    const port = 5000;
    const Promise = require("bluebird");
    
    const fundebug = require("fundebug-nodejs");
    fundebug.apikey = "APIKEY";
    fundebug.httpTimeout = 1000;
    
    app.use(fundebug.ExpressTimeoutHandler());
    
    app.get("/error", () => {
        throw new Error("test");
    });
    
    app.get("/timeout", async (req, res) => {
        await Promise.delay(1500);
        res.sendStatus(200);
    });
    
    app.use(function(err, req, res, next) {
        res.status(500);
        next(err);
    });
    
    app.use(fundebug.ExpressErrorHandler);
    
    app.listen(port, () => console.log(`Example app listening on port ${port}!`));
    

    其中,ExpressTimeoutHandler必须放在其他中间件之前,而ExpressErrorHandler必须放在其他中间件之后。

    Fundebug所捕获的超时请求如下:

    参考

    关于Fundebug

    Fundebug专注于JavaScript、微信小程序、微信小游戏、支付宝小程序、React Native、Node.js和Java线上应用实时BUG监控。 自从2016年双十一正式上线,Fundebug累计处理了10亿+错误事件,付费客户有阳光保险、核桃编程、荔枝FM、掌门1对1、微脉、青团社等众多知名企业。欢迎大家免费试用

    版权声明

    转载时请注明作者Fundebug以及本文地址:
    https://blog.fundebug.com/2019/07/30/fundebug-nodejs-0-2-0/

  • 相关阅读:
    NSOperationQueue
    iOS开发网络数据之AFNetworking使用
    NSURLConnection
    SQLite3 嵌入式数据库
    iOS中常用的四种数据持久化方法简介
    <转> core Animation动画-2
    core Animation动画
    ios数据库操作SQLite
    SQLite3-各个函数
    SQLite3-数据类型
  • 原文地址:https://www.cnblogs.com/fundebug/p/fundebug-nodejs-0-2-0.html
Copyright © 2011-2022 走看看