( _api: HttpApi.HttpApi<Id, Groups>, )
| 148 | ) {} |
| 149 | |
| 150 | export const observabilityMiddleware = <Id extends string, Groups extends HttpApiGroup.Any>( |
| 151 | _api: HttpApi.HttpApi<Id, Groups>, |
| 152 | ): Layer.Layer<ObservabilityMiddleware> => |
| 153 | Layer.succeed(ObservabilityMiddleware, (httpApp) => |
| 154 | Effect.catchCause(httpApp, (cause) => |
| 155 | Effect.gen(function* () { |
| 156 | const defect = Cause.findDefect(cause); |
| 157 | if (Result.isFailure(defect)) { |
| 158 | return yield* Effect.failCause(cause); |
| 159 | } |
| 160 | const c = yield* resolveCapture; |
| 161 | const traceId = yield* c.captureException(cause); |
| 162 | return HttpServerResponse.jsonUnsafe(new InternalError({ traceId }), { |
| 163 | status: 500, |
| 164 | }); |
| 165 | }), |
| 166 | ), |
| 167 | ); |
no outgoing calls