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

zw-service-monitor

v3.0.11

Published

日志监控上报

Downloads

12

Readme

zw-service-monitor

政务方向,服务异常监控

监控接入

1、 安装依赖

npm i zw-service-monitor --save

2、接入

2.1 方式1:原生小程序

直接在 app.js 中引入(zw-service-monitor会重写 request)

import 'zw-service-monitor';

2.2 方式2:可以通过使用 sendFailLog、sendSuccessLog 进行接入

import {sendSuccessLog, sendFailLog} = from 'zw-service-monitor/dist/index.js';

2.2.1 sendSuccessLog方法参数说明

|参数||类型|说明| |--|--|--|--| |params||Object|业务发送接口请求的参数| ||url|String|业务接口地址| ||data|Number|业务请求的参数| |oldDate||Number|业务请求的时间戳|

2.2.2 sendFailLog方法参数说明

|参数||类型|说明| |--|--|--|--| |params||Object|业务发送接口请求的参数| ||url|String|业务接口地址| ||data|Number|业务请求的参数| |oldDate||Number|业务请求的时间戳| |err||Object|业务请求失败的报错信息|

3、使用demo

// 引入
import {sendSuccessLog, sendFailLog} = from 'zw-service-monitor/dist/index.js';

function request() {
    const url = 'https://sfc.baidu.com/shopping/nianhuo/bimai?timestamp=10001';
    const data = {
        tabname: '美食酒水'
    };
    const oldDate = +new Date();
   
   
    // 发起请求
    swan.request({
        url,
        data,
        method: 'POST',
        success: res => {
            // 请求错误
            if (res && res.statusCode !== 200) {
                res.errCode = res.statusCode;
   
   
                // 发送错误日志
                sendFailLog({
                    url,
                    data
                }, oldDate, res);
            } else {
                // 业务接口状态
                if (+res.data.errno === 0) {
                    // 发送成功日志
                    sendSuccessLog({
                        url,
                        data
                    }, oldDate)
                      
                } else {
                    // 发送错误日志
                    sendFailLog({
                        url,
                        data
                    }, oldDate, res);
                }
            } 
        },
        fail: err => {
            // 发送错误日志
            sendFailLog({
                url,
                data
            }, oldDate, err);
        }
    });
}

4、 观察工具中以下接口请求是否正常

接口地址:https://minipro.baidu.com/ma/zw/monitor/logreport

请求成功:图片

确认该接口的 form data 的 status 是 success 还是 fail,success 代表业务接口正常,fail 代表业务接口异常

图片