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

Adds the root sentry span to a resolver's context #1609

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

orta
Copy link
Contributor

@orta orta commented Jan 7, 2023

Description

Hello folks, I was going through Sentry tracing, and I needed access to set my parent span on a transaction. Now, this is reasonably easy to do via:

const opScope = Sentry.getCurrentHub().getScope()?.getSpan()

But relying on a bunch of globals feels a little bit off for me, when context is really what this sort of thing is for (IMO.) So, this PR adds span into the operation context. I've scoped it into a sentry object - in case there more things added further down the line.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update (maybe?)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Tests

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

@changeset-bot
Copy link

changeset-bot bot commented Jan 7, 2023

🦋 Changeset detected

Latest commit: 01624ef

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 Patch

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

@orta
Copy link
Contributor Author

orta commented Jan 7, 2023

FAIL packages/plugins/sentry/__tests__/sentry.spec.ts
  ● sentry › report unexpected error

    expect(received).toHaveLength(expected)

    Expected length: 1
    Received length: 0
    Received array:  []

It seems surprising that my code would change the error handling? Is it known to be flaky?

@saihaj
Copy link
Collaborator

saihaj commented Jan 13, 2023

@orta can you add a changeset?

@saihaj
Copy link
Collaborator

saihaj commented Jan 21, 2023

Looks like just need to run prettier @orta

@orta
Copy link
Contributor Author

orta commented Jan 21, 2023

on the markdown that gets thrown away? That should be in the exceptions

@jeengbe
Copy link
Contributor

jeengbe commented Feb 8, 2023

@n1ru4l @saihaj Can we get this merged? 🙏🏻

@ardatan
Copy link
Collaborator

ardatan commented Feb 8, 2023

CI is failing :/

@jeengbe
Copy link
Contributor

jeengbe commented Feb 8, 2023

CI is failing :/

Rerun it? All but one appear fine😄

And Orta is right with Prettier; .changeset shouldn't be linted

@ardatan
Copy link
Collaborator

ardatan commented Feb 8, 2023

@jeengbe Unit tests are failing :)

@jeengbe
Copy link
Contributor

jeengbe commented Feb 8, 2023

@jeengbe Unit tests are failing :)

Run it once more, it worked locally on the second attempt 🙂

@jeengbe
Copy link
Contributor

jeengbe commented Feb 8, 2023

@ardatan @orta See orta#1

orta and others added 2 commits February 8, 2023 21:20
@jeengbe
Copy link
Contributor

jeengbe commented Feb 9, 2023

In response to getsentry/sentry-javascript#7083 (reply in thread), this might actually be the wrong solution to this problem. Instead, a PR that integrates this domain thing would probably be the better solution as that would truly ensure all child spans are set correctly.

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.

7 participants