Skip to content

✨ Inspectable attributes#1098

Merged
cowboyd merged 1 commit intov4-1-alphafrom
inspectable-attributes
Feb 4, 2026
Merged

✨ Inspectable attributes#1098
cowboyd merged 1 commit intov4-1-alphafrom
inspectable-attributes

Conversation

@cowboyd
Copy link
Member

@cowboyd cowboyd commented Feb 4, 2026

Motivation

Effection currently lack a standardized way to attach metadata for debugging and visualization purposes. We need a way to attach metadata to a scope so that it can be consumed by downstream tooling such as OTEL or the Effection Inspector.

Approach

This change introduces two new APIs:

  • useAttributes() - An operation that adds serializable metadata (name/value pairs) to the current scope. This is api is meant to be used to annotate Effection scopes from user-land code. Accessible from the main module export.
  • getAttributes() - A function to retrieve a scope attributes. This api is not really designed to be called from user-land, but will be called from tooling that needs to read attributes from a scope. This api is only available via the effection/exmperimental module.

Each scope maintains its own attributes. They are not inherited from parent scopes. This makes sense when we think that these attributes are there to present information that is unique to the current scope.p

Multiple calls to useAttributes within the same scope merge attributes rather than replacing them, allowing progressive enhancement of scope metadata.

Example Usage

function useServer(port: number): Operation<Server> {
  return resource(function*(provide) {
    yield* useAttributes({ name: "Server", port });
    let server = createServer();
    server.listen();
    try {
      yield* provide(server);
    } finally {
      server.close();
    }
  });
}

Note: this api is called useLabels() in the current @effectionx/inspector branch.

@cowboyd cowboyd requested review from jbolda and taras February 4, 2026 03:53
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 4, 2026

Open in StackBlitz

npm i https://pkg.pr.new/thefrontside/effection@1098

commit: 6ff6140

@cowboyd cowboyd merged commit cf1dd55 into v4-1-alpha Feb 4, 2026
5 checks passed
@cowboyd cowboyd deleted the inspectable-attributes branch February 4, 2026 22:40
cowboyd added a commit that referenced this pull request Feb 4, 2026
cowboyd added a commit that referenced this pull request Feb 4, 2026
cowboyd added a commit that referenced this pull request Feb 4, 2026
cowboyd added a commit that referenced this pull request Feb 5, 2026
cowboyd added a commit that referenced this pull request Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant