| 179 | } |
| 180 | |
| 181 | export function traceRestResponse(info: { |
| 182 | method: string; |
| 183 | path: string; |
| 184 | requestId: string; |
| 185 | status: number; |
| 186 | durationMs: number; |
| 187 | code: number; |
| 188 | msg: string; |
| 189 | envelopeRequestId?: string; |
| 190 | data?: unknown; |
| 191 | }): void { |
| 192 | if (!isTraceEnabled()) return; |
| 193 | const failed = info.code !== 0; |
| 194 | push({ |
| 195 | source: 'rest', |
| 196 | kind: failed ? 'rest:error' : 'rest:response', |
| 197 | label: `← ${info.method} ${info.path} ${info.status} code=${info.code}${failed ? ` "${info.msg}"` : ''} ${Math.round(info.durationMs)}ms`, |
| 198 | method: info.method, |
| 199 | path: info.path, |
| 200 | requestId: info.requestId, |
| 201 | status: info.status, |
| 202 | code: info.code, |
| 203 | durationMs: info.durationMs, |
| 204 | detail: { |
| 205 | envelope: { code: info.code, msg: info.msg, request_id: info.envelopeRequestId }, |
| 206 | data: detailOf(info.data), |
| 207 | }, |
| 208 | }); |
| 209 | } |
| 210 | |
| 211 | export function traceRestFailure(info: { |
| 212 | method: string; |