Commit a38f24a6 authored by qinhaitao's avatar qinhaitao

Merge branch 'c_server_ts_perf-talk' into 'c_server_ts_perf'

钉钉告警优化

See merge request !37
parents 4447fbac 87407989
{
"cloud": {
"type": "CLOUDAPP"
}
},
"exclude": [
"server/**"
]
}
......@@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "11",
"main": "index.js",
"title": "测试活动",
"author": "duiba",
"license": "ISC",
"sdkVersion": "*",
......
......@@ -119,8 +119,3 @@ export const sellerId = '1234'
// C端的APP NAME
export const C_APP_NAME: string = `promotioncenter-${appId}`
// 钉钉告警 活动名称
export const activityName = ''
// 开发者手机号
export const phone = ''
......@@ -42,7 +42,7 @@ export default function preUpdate(checks: IFunction[]) {
console.log(error, 'preUpdateUser-error')
recordErrorLog(context, baseInfos, error.toString(), error.stack)
// 云告警
cloundAlarm(context, error.toString())
cloundAlarm(context, error.toString(), error.stack)
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR)
}
return method.apply(target, [context, { ...baseInfos }, services, preCheckData])
......
......@@ -58,7 +58,7 @@ export default function requestCountLimit(limitCount: number, limitTime: number)
console.log('error', error)
recordErrorLog(context, baseInfos, error.toString(), error.stack)
// 云告警
cloundAlarm(context, error.toString())
cloundAlarm(context, error.toString(), error.stack)
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR)
}
......
......@@ -47,7 +47,7 @@ export default function requestRateLimit(rate = 500) {
console.log('error', error)
recordErrorLog(context, baseInfos, error.toString(), error.stack)
// 云告警
cloundAlarm(context, error.toString())
cloundAlarm(context, error.toString(), error.stack)
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR)
}
......
import { phone, activityName } from '../../constants'
const configPackage = require('../../../package.json')
/**
* 告警信息
* @param message
*/
export const cloundAlarm = async (context: IContext<IParams>, message: string) => {
// https://oapi.dingtalk.com/robot/send?access_token=f6d0d8ecdab3ad77dc51b5173f630f1c0e0fcbe90e994d0a642fb0b516dfd24c
export const cloundAlarm = async (context: IContext<IParams>, message: string, stack: string) => {
console.warn(configPackage)
const { title, author } = configPackage
const envTxt = {
'test': '测试环境',
'pre': '预发环境',
'online': '线上环境'
}
// https://oapi.dingtalk.com/robot/send?access_token= f6d0d8ecdab3ad77dc51b5173f630f1c0e0fcbe90e994d0a642fb0b516dfd24c
// 测试 d452c99b12d3fe67472c681e76b13ed5b2355c3e2c3b856a1c3a9897a103986b
const text = {
"msgtype": "markdown",
"markdown": {
"title":"云告警",
"text": `### 活动名称:${activityName} \n ### 告警内容 \n ####${message}\n @${phone}`
"text": `### 活动名称:${title} \n > #### 环境: ${envTxt[context.env]}\n > #### 告警内容: ${message}\n > #### 详细信息: \n > ${stack}\n\n @${author}`
},
"at": { "isAtAll": false, "atMobiles": [phone], "atUserIds": [] }
"at": { "isAtAll": false, "atMobiles": [], "atUserIds": [] }
}
const result = await context.cloud.httpApi.invoke(
{
......@@ -27,4 +36,4 @@ export const cloundAlarm = async (context: IContext<IParams>, message: string) =
'body': text
});
return result
}
}
\ No newline at end of file
......@@ -14,7 +14,7 @@ export async function doHandler(target: Object, method: IFunction, args: any[])
console.log('error', error)
recordErrorLog(args[0], args[1], error.toString(), error.stack)
// 云告警
cloundAlarm(args[0], error.toString())
cloundAlarm(args[0], error.toString(), error.stack)
ret = resultsModel.error(CODE_TYPES.SYSTEM_ERROR)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment