File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,12 @@ const EXCLUDE_PATH_PATTERNS = [
23
23
/ \/ r e a d y $ / i,
24
24
/ \/ l i v e $ / i,
25
25
] ;
26
+ const EXCLUDE_USER_AGENT_PATTERNS = [
27
+ / h e a l t h [ - _ ] ? c h e c k / i,
28
+ / m i c r o s o f t - a z u r e - a p p l i c a t i o n - l b / i,
29
+ / g o o g l e h c / i,
30
+ / k u b e - p r o b e / i,
31
+ ] ;
26
32
const MASK_QUERY_PARAM_PATTERNS = [
27
33
/ a u t h / i,
28
34
/ a p i - ? k e y / i,
@@ -113,6 +119,12 @@ export default class RequestLogger {
113
119
return matchPatterns ( urlPath , patterns ) ;
114
120
}
115
121
122
+ private shouldExcludeUserAgent ( userAgent ?: string ) {
123
+ return userAgent
124
+ ? matchPatterns ( userAgent , EXCLUDE_USER_AGENT_PATTERNS )
125
+ : false ;
126
+ }
127
+
116
128
private shouldMaskQueryParam ( name : string ) {
117
129
const patterns = [
118
130
...this . config . maskQueryParams ,
@@ -155,9 +167,13 @@ export default class RequestLogger {
155
167
156
168
const url = new URL ( request . url ) ;
157
169
const path = request . path ?? url . pathname ;
170
+ const userAgent = request . headers . find (
171
+ ( [ k ] ) => k . toLowerCase ( ) === "user-agent" ,
172
+ ) ?. [ 1 ] ;
158
173
159
174
if (
160
175
this . shouldExcludePath ( path ) ||
176
+ this . shouldExcludeUserAgent ( userAgent ) ||
161
177
( this . config . excludeCallback ?.( request , response ) ?? false )
162
178
) {
163
179
return ;
You can’t perform that action at this time.
0 commit comments