Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Draft PR: Effect Integration for Sentry Node SDK #17432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Divyanshu7001 wants to merge 2 commits into getsentry:develop
base: develop
Choose a base branch
Loading
from Divyanshu7001:feat/effect-integration

Conversation

@Divyanshu7001
Copy link

@Divyanshu7001 Divyanshu7001 commented Aug 19, 2025

1. Goal

This PR adds support for tracing Effect computations in the Sentry Node SDK. The goal is to automatically create Sentry spans for Effect operations and capture errors that occur within Effect computations as Sentry exceptions, providing better observability for users of the Effect library.

2. Pathway Taken

  • Added a new integration (effectIntegration) and instrumentation (instrumentEffect) under @sentry/node.
  • Followed the robust test/mocking patterns from other integrations to ensure isolated, reliable tests.
  • Updated the SDK’s auto-integration and preload logic to include Effect.
  • Added the effect package as a dependency and provided type definitions for Effect’s tracer API.
  • Wrote comprehensive unit tests for the integration, covering all tracer hooks and error scenarios.

3. How the integration has happened and where it is included now

  • The integration is implemented in packages/node/src/integrations/tracing/effect/.
  • It is exported from the main SDK entrypoint and included in the auto-performance integrations list.
  • The SDK will now automatically register the Effect tracer if the Effect library is present in the user’s project.

4. How users should integrate Effect into their own project

Basic usage:

const Sentry = require('@sentry/node');
Sentry.init({
 dsn: 'YOUR_DSN',
 integrations: [
 Sentry.effectIntegration(),
 // ...other integrations
 ],
 // ...other options
});
  • Just add Sentry.effectIntegration() to your integrations array.
  • The SDK will automatically patch Effect’s tracer and start capturing spans and errors.
  • No manual instrumentation is required for most use cases.

5. Where am i stuck / need help

  • Some test cases are still flaky or failing due to mocking or module loading order (see attached images).
Screenshot 2025年08月19日 054036 Screenshot 2025年08月19日 054110 Screenshot 2025年08月19日 054126 Screenshot 2025年08月19日 054055

6. What is my thinking about these errors?

I think these errors are due to me not being able to setup the test environment properly as in most errors..the problem is just Span processes being undefined.
I would appreciate some pointers of where i am going wrong and how should i setup the test environment properly to test.

seer-by-sentry[bot] reacted with hooray emoji
@Divyanshu7001 Divyanshu7001 requested a review from a team as a code owner August 19, 2025 00:17
Copy link

marbemac commented Sep 8, 2025

Just a quick note - @Divyanshu7001 the auto formatting on your machine resulted in lots of unrelated files being changed that make it more difficult to digest this PR.

Copy link
Author

Just a quick note - @Divyanshu7001 the auto formatting on your machine resulted in lots of unrelated files being changed that make it more difficult to digest this PR.

I was afraid of the same thing & thats why used github codespaces with no local settings
but yes..i did run yarn fix to do all the linting fixes on the package level , which has caused this issue.😅
@marbemac would you prefer another PR without the linting fixes?
i can do that if that will suit things better.

all open for it.

Copy link
Member

s1gr1d commented Sep 16, 2025

Thanks for creating this PR!
Can you please run fix:prettier from the root package.json? And also update the PR (merging or rebasing).

And to make sure we don't forget to review the PR you can assign e.g. me as a reviewer when you are ready.

Copy link

@marbemac marbemac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Divyanshu7001, after actually looking at it, I don't understand how this is supposed to work. Most of the interfaces and methods used are not present in effect.

I created a custom effect tracer for Sentry over here, if you are interested -> https://github.com/marbemac/cloudflare-sentry-effect-tracing/blob/main/worker/effect-sentry-tracer.ts.

Comment on lines +21 to +22
onSpanStart?: (span: EffectSpan) => void;
onSpanEnd?: (span: EffectSpan, exit: EffectExit) => void;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where can you find this in effect?

export interface EffectTracer {
onSpanStart?: (span: EffectSpan) => void;
onSpanEnd?: (span: EffectSpan, exit: EffectExit) => void;
span<A>(name: string, f: () => A): A;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The span method on custom tracers takes 6 args, not 2.

onSpanStart?: (span: EffectSpan) => void;
onSpanEnd?: (span: EffectSpan, exit: EffectExit) => void;
span<A>(name: string, f: () => A): A;
withSpan<A>(span: EffectSpan, f: () => A): A;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where can you find this in the effect tracer interface?

Comment on lines +114 to +122
if (typeof Effect.Tracer.set === 'function') {
Effect.Tracer.set(sentryTracer);
} else if (typeof Effect.Tracer.register === 'function') {
Effect.Tracer.register(sentryTracer);
} else if (typeof Effect.Tracer.use === 'function') {
Effect.Tracer.use(sentryTracer);
} else {
return;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did you find these methods on the effect tracer? I do not think they exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@marbemac marbemac marbemac requested changes

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /