Skip to content

refactor(instrumentation): Separate API wrapping from tracing - #2575

Open
Luca Forstner (lforst) wants to merge 2 commits into
mainfrom
lforst/dum-e/vancouver-8d9dc35a5b
Open

Luca Forstner (lforst) wants to merge 2 commits into
mainfrom
lforst/dum-e/vancouver-8d9dc35a5b

Conversation

@lforst

Copy link
Copy Markdown
Member
  • API wrapping previously carried tracing lifecycle machinery. intercept and invoke now only wrap function calls, so they can be reused without creating spans or initializing Braintrust.
  • Rename the internal definition API to defineInterceptor. Interceptors receive the original function, receiver, and arguments:
    const hooks = defineInterceptor("client", {
      request: channel<[string], Promise<string>>({ channelName: "request" }),
    });
    
    // Wrap calls without enabling tracing.
    hooks.request.intercept((target, receiver, args) => {
      console.log("Request:", args[0]);
      return Reflect.apply(target, receiver, args);
    });
  • Move span creation, context propagation, and completion into separate tracing functions. Provider integrations explicitly register these through interceptors; manual and generated wrappers only invoke hooks.
  • Remove the old tracing hook protocol. Applications with previously transformed bundles need to rebuild after upgrading.

@lforst Luca Forstner (lforst) changed the title refactor(instrumentation)!: Separate API wrapping from tracing refactor(instrumentation): Separate API wrapping from tracing Oct 2, 2026

This branch has not been deployed

No deployments
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