Add computed value as log annotations (in a generator)
Hello everyone. I am starting to add some observability to my effect app. I want to add some advanced logging by enhancing the log outputs with a requestID or the requested path. Now the problem is I can only add log anotations like this
But what if I want to add log annotations from within a service layer? Or a generator? Something like this:
Effect.gen(function* (_) { const headerService = yield* HeaderService; const path = headerService.get("x-requested-path"); // TODO: Annotate all downstream logs with the path // This will not work yield* Effect.annotateLogs("requestId", requestId);});
Effect.gen(function* (_) { const headerService = yield* HeaderService; const path = headerService.get("x-requested-path"); // TODO: Annotate all downstream logs with the path // This will not work yield* Effect.annotateLogs("requestId", requestId);});