Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taobao-mini-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinhaitao
taobao-mini-template
Commits
a38f24a6
Commit
a38f24a6
authored
Sep 02, 2021
by
qinhaitao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'c_server_ts_perf-talk' into 'c_server_ts_perf'
钉钉告警优化 See merge request
!37
parents
4447fbac
87407989
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
16 deletions
+24
-16
mini.project.json
mini.project.json
+4
-1
package.json
v2.0/package.json
+1
-0
constants.ts
v2.0/src/constants.ts
+0
-5
preUpdate.ts
v2.0/src/decorator/common/preUpdate.ts
+1
-1
requestCountLimit.ts
v2.0/src/decorator/common/requestCountLimit.ts
+1
-1
requestRateLimit.ts
v2.0/src/decorator/common/requestRateLimit.ts
+1
-1
dingTalk.ts
v2.0/src/utils/common/dingTalk.ts
+15
-6
doHandler.ts
v2.0/src/utils/common/doHandler.ts
+1
-1
No files found.
mini.project.json
View file @
a38f24a6
{
{
"cloud"
:
{
"cloud"
:
{
"type"
:
"CLOUDAPP"
"type"
:
"CLOUDAPP"
}
},
"exclude"
:
[
"server/**"
]
}
}
v2.0/package.json
View file @
a38f24a6
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
"version"
:
"1.0.0"
,
"version"
:
"1.0.0"
,
"description"
:
"11"
,
"description"
:
"11"
,
"main"
:
"index.js"
,
"main"
:
"index.js"
,
"title"
:
"测试活动"
,
"author"
:
"duiba"
,
"author"
:
"duiba"
,
"license"
:
"ISC"
,
"license"
:
"ISC"
,
"sdkVersion"
:
"*"
,
"sdkVersion"
:
"*"
,
...
...
v2.0/src/constants.ts
View file @
a38f24a6
...
@@ -119,8 +119,3 @@ export const sellerId = '1234'
...
@@ -119,8 +119,3 @@ export const sellerId = '1234'
// C端的APP NAME
// C端的APP NAME
export
const
C_APP_NAME
:
string
=
`promotioncenter-
${
appId
}
`
export
const
C_APP_NAME
:
string
=
`promotioncenter-
${
appId
}
`
// 钉钉告警 活动名称
export
const
activityName
=
''
// 开发者手机号
export
const
phone
=
''
v2.0/src/decorator/common/preUpdate.ts
View file @
a38f24a6
...
@@ -42,7 +42,7 @@ export default function preUpdate(checks: IFunction[]) {
...
@@ -42,7 +42,7 @@ export default function preUpdate(checks: IFunction[]) {
console
.
log
(
error
,
'preUpdateUser-error'
)
console
.
log
(
error
,
'preUpdateUser-error'
)
recordErrorLog
(
context
,
baseInfos
,
error
.
toString
(),
error
.
stack
)
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
resultsModel
.
error
(
CODE_TYPES
.
SYSTEM_ERROR
)
}
}
return
method
.
apply
(
target
,
[
context
,
{
...
baseInfos
},
services
,
preCheckData
])
return
method
.
apply
(
target
,
[
context
,
{
...
baseInfos
},
services
,
preCheckData
])
...
...
v2.0/src/decorator/common/requestCountLimit.ts
View file @
a38f24a6
...
@@ -58,7 +58,7 @@ export default function requestCountLimit(limitCount: number, limitTime: number)
...
@@ -58,7 +58,7 @@ export default function requestCountLimit(limitCount: number, limitTime: number)
console
.
log
(
'error'
,
error
)
console
.
log
(
'error'
,
error
)
recordErrorLog
(
context
,
baseInfos
,
error
.
toString
(),
error
.
stack
)
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
resultsModel
.
error
(
CODE_TYPES
.
SYSTEM_ERROR
)
}
}
...
...
v2.0/src/decorator/common/requestRateLimit.ts
View file @
a38f24a6
...
@@ -47,7 +47,7 @@ export default function requestRateLimit(rate = 500) {
...
@@ -47,7 +47,7 @@ export default function requestRateLimit(rate = 500) {
console
.
log
(
'error'
,
error
)
console
.
log
(
'error'
,
error
)
recordErrorLog
(
context
,
baseInfos
,
error
.
toString
(),
error
.
stack
)
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
resultsModel
.
error
(
CODE_TYPES
.
SYSTEM_ERROR
)
}
}
...
...
v2.0/src/utils/common/dingTalk.ts
View file @
a38f24a6
import
{
phone
,
activityName
}
from
'../../constants'
const
configPackage
=
require
(
'../../../package.json'
)
/**
/**
* 告警信息
* 告警信息
* @param message
* @param message
*/
*/
export
const
cloundAlarm
=
async
(
context
:
IContext
<
IParams
>
,
message
:
string
)
=>
{
export
const
cloundAlarm
=
async
(
context
:
IContext
<
IParams
>
,
message
:
string
,
stack
:
string
)
=>
{
// https://oapi.dingtalk.com/robot/send?access_token=f6d0d8ecdab3ad77dc51b5173f630f1c0e0fcbe90e994d0a642fb0b516dfd24c
console
.
warn
(
configPackage
)
const
{
title
,
author
}
=
configPackage
const
envTxt
=
{
'test'
:
'测试环境'
,
'pre'
:
'预发环境'
,
'online'
:
'线上环境'
}
// https://oapi.dingtalk.com/robot/send?access_token= f6d0d8ecdab3ad77dc51b5173f630f1c0e0fcbe90e994d0a642fb0b516dfd24c
// 测试 d452c99b12d3fe67472c681e76b13ed5b2355c3e2c3b856a1c3a9897a103986b
const
text
=
{
const
text
=
{
"msgtype"
:
"markdown"
,
"msgtype"
:
"markdown"
,
"markdown"
:
{
"markdown"
:
{
"title"
:
"云告警"
,
"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
(
const
result
=
await
context
.
cloud
.
httpApi
.
invoke
(
{
{
...
...
v2.0/src/utils/common/doHandler.ts
View file @
a38f24a6
...
@@ -14,7 +14,7 @@ export async function doHandler(target: Object, method: IFunction, args: any[])
...
@@ -14,7 +14,7 @@ export async function doHandler(target: Object, method: IFunction, args: any[])
console
.
log
(
'error'
,
error
)
console
.
log
(
'error'
,
error
)
recordErrorLog
(
args
[
0
],
args
[
1
],
error
.
toString
(),
error
.
stack
)
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
)
ret
=
resultsModel
.
error
(
CODE_TYPES
.
SYSTEM_ERROR
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment