Skip to content

Effect.fn should automatically apply withLogSpan #5755

@alex-dixon

Description

@alex-dixon

What is the problem this feature would solve?

Effect.fn has been a tremendous improvement for dx. It removes boilerplate required to add span names to traces. Howvever it does not add span names to logs. Span names in logs can be useful information for developers and LLMs.

Before Effect.fn:

const MyService = {
  myFn: (arg: string) =>
    Effect.succeed(arg).pipe(
      Effect.withSpan("MyService.myFn"),
      Effect.withLogSpan("MyService.myFn")
    )
}

With Effect.fn today:

Effect.fn("MyService.myFn")(
  function* (arg) { return arg; },
  Effect.withLogSpan("MyService.myFn")   // ← not added automatically
)

What is the feature you are proposing to solve the problem?

Effect.fn should automatically add .withLogSpan the same way it adds .withSpan.

Proposed:

Effect.fn("MyService.myFn")(
  function* (arg) { return arg; },
) // annotates traces and logs with the name of the fn

What alternatives have you considered?

Wrapping Effect.fn to perform this automatically, using the wrapped version instead of Effect.fn in the codebase

Relying on tracing only (inevitably we still have logs, somewhat impractical for contexts like tests or scripts)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions