Effect CommunityEC
Effect Community3y ago
3 replies
Patrick Roza

Issue with Reproducing Strange Effect Behavior

solved im having a strange issue but I can't get a simple repro.
it comes down to this:
Effect
  .gen(function*($) {
    const eff = yield* $(
      Effect
        .logInfo("constructing")
        .pipe(
          Effect.zipRight(
            Effect.sync(() => () =>
              Effect
                .logInfo("processing request")
                .pipe(Effect.withSpan("within-request"))
            )
          ),
          Effect.withSpan("constructing")
        )
    )
    const rt = yield* $(Effect.runtime<never>())
    rt.pipe(Runtime.runFork)(eff().pipe(Effect.withSpan("request")))
  })
but instead of span within-request having span request as parent, it has span constructing as parent - while that was only a span at construction (but I repeat, the above does not reproduce the issue)
(its an express app, where at the start we construct all handler functions, and then call handler(req, res next) upon each request.

interestingly, span request doesn't have span constructing as parent.
and when I remove span constructing, span within-request suddenly correctly has span request as parent.

im using the standard otel setup from the sample in this case, so I can see the traces in my log output being wrong.
Was this page helpful?