( _api: HttpApi.HttpApi<Id, Groups>, )
| 159 | ) {} |
| 160 | |
| 161 | export const observabilityMiddleware = <Id extends string, Groups extends HttpApiGroup.Any>( |
| 162 | _api: HttpApi.HttpApi<Id, Groups>, |
| 163 | ): Layer.Layer<ObservabilityMiddleware> => |
| 164 | Layer.succeed(ObservabilityMiddleware, (httpApp) => |
| 165 | Effect.catchCause(httpApp, (cause) => |
| 166 | Effect.gen(function* () { |
| 167 | const defect = Cause.findDefect(cause); |
| 168 | if (Result.isFailure(defect)) { |
| 169 | return yield* Effect.failCause(cause); |
| 170 | } |
| 171 | const c = yield* resolveCapture; |
| 172 | const traceId = yield* c.captureException(cause); |
| 173 | return HttpServerResponse.jsonUnsafe(new InternalError({ traceId }), { |
| 174 | status: 500, |
| 175 | }); |
| 176 | }), |
| 177 | ), |
| 178 | ); |
no outgoing calls