Skip to content

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

Open
orta wants to merge 5 commits into
graphql-hive:mainfrom
orta:ctx
Open

Adds the root sentry span to a resolver's context#1609
orta wants to merge 5 commits into
graphql-hive:mainfrom
orta:ctx

Conversation

@orta

@orta orta commented Jan 7, 2023

Copy link
Copy Markdown
Contributor

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

changeset-bot Bot commented Jan 7, 2023

Copy link
Copy Markdown

🦋 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

orta commented Jan 7, 2023

Copy link
Copy Markdown
Contributor Author
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

saihaj commented Jan 13, 2023

Copy link
Copy Markdown
Member

@orta can you add a changeset?

@saihaj

saihaj commented Jan 21, 2023

Copy link
Copy Markdown
Member

Looks like just need to run prettier @orta

@orta

orta commented Jan 21, 2023

Copy link
Copy Markdown
Contributor Author

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

@jeengbe

jeengbe commented Feb 8, 2023

Copy link
Copy Markdown
Contributor

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

@ardatan

ardatan commented Feb 8, 2023

Copy link
Copy Markdown
Member

CI is failing :/

@jeengbe

jeengbe commented Feb 8, 2023

Copy link
Copy Markdown
Contributor

CI is failing :/

Rerun it? All but one appear fine😄

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

@ardatan

ardatan commented Feb 8, 2023

Copy link
Copy Markdown
Member

@jeengbe Unit tests are failing :)

@jeengbe

jeengbe commented Feb 8, 2023

Copy link
Copy Markdown
Contributor

@jeengbe Unit tests are failing :)

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

@jeengbe

jeengbe commented Feb 8, 2023

Copy link
Copy Markdown
Contributor

@ardatan @orta See orta#1

Comment thread packages/plugins/sentry/src/index.ts Outdated
orta and others added 2 commits February 8, 2023 21:20
fix: use Sentry.flush()
Co-authored-by: Jesper Engberg <jeengbe@gmail.com>
@jeengbe

jeengbe commented Feb 9, 2023

Copy link
Copy Markdown
Contributor

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

Development

Successfully merging this pull request may close these issues.

7 participants