Skip to content
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

feat: Make it possible to get the active span in the GraphQL resolver #2323

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

Karibash
Copy link
Contributor

Description

Please include a summary of the change and which issue is fixed. Please also include relevant
motivation and context. List any dependencies that are required for this change.

Fixes #2322

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Added test to run getActiveSpan within a GraphQL resolver.

Test Environment:

  • OS: MacOS 14.6.1
  • NodeJS: 22.11.0

Checklist:

  • I have followed the
    CONTRIBUTING doc and the
    style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link

changeset-bot bot commented Nov 12, 2024

🦋 Changeset detected

Latest commit: 68c2246

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@envelop/sentry Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -131,56 +132,93 @@ export const useSentry = <PluginContext extends Record<string, any> = {}>(
...addedTags,
};

let rootSpan: Span | undefined;
const createExecuteFn = async (
Copy link
Collaborator

Choose a reason for hiding this comment

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

The name of this function is a bit misleading.

What do you think of executeWithSpan ?

Suggested change
const createExecuteFn = async (
const executeWithSpan = async (

Copy link
Collaborator

@EmrysMyrddin EmrysMyrddin left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for you contribution!

I've made a minor comment, apart from this, it should be good to merge!

@@ -0,0 +1,5 @@
---
'@envelop/sentry': minor
Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn't noticed, but this PR contains a breaking change, so the version bump should be major

Suggested change
'@envelop/sentry': minor
'@envelop/sentry': major

The breaking change is that now, this plugin wraps the execution phase. So the plugin is now order dependent in the plugin list. Which means it can break existing configuration.

Can you add an advice to put the plugin at the end of the plugin list ? This way, it ensures that the execute function doesn't get overwritten by another plugin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed it to a major update and added a note that it is a breaking change.
9fb31e0

@EmrysMyrddin
Copy link
Collaborator

Some modifications have been made to this plugin on the main branch, so I merged the changes into your branch.

Can you confirm it's still doing what you needed ?

@Karibash
Copy link
Contributor Author

Karibash commented Dec 2, 2024

@EmrysMyrddin
Thanks for the branch update.It is simpler and better than my implementation.
The test I added also passes without any problems, so I think it is fine.

@EmrysMyrddin
Copy link
Collaborator

Great ! Let's merge this then :-)

In fact, it's pretty much exactly what remained of your code once all changes related to deleted code on main have been removed :-P So yeah, it's basically the whole plugin that was a bit messy, because of the way legacy Sentry API used to work :-)

@EmrysMyrddin
Copy link
Collaborator

@Karibash Can you rebase this PR ? I don't have the rights to force push your branch :/

@Karibash Karibash force-pushed the feature/active-span branch from def90b5 to bfae518 Compare December 11, 2024 00:54
@Karibash Karibash force-pushed the feature/active-span branch from bfae518 to 6ea2fe2 Compare December 11, 2024 00:57
@Karibash
Copy link
Contributor Author

@EmrysMyrddin I have rebased and consolidated the commits into one. Please check it!

@EmrysMyrddin
Copy link
Collaborator

I was hoping that it would fix the CI... I will check why it's not working

@EmrysMyrddin EmrysMyrddin merged commit 2993773 into n1ru4l:main Dec 12, 2024
13 checks passed
@Karibash Karibash deleted the feature/active-span branch December 13, 2024 00:46
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.

Make it possible to get the active span in the GraphQL resolver
2 participants