envelop
envelop copied to clipboard
Adds the root sentry span to a resolver's context
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)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [x] 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
- [x] Tests
Checklist:
- [x] I have followed the CONTRIBUTING doc and the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented on my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published in downstream modules
π¦ Changeset detected
Latest commit: 01624ef17666bdcc90e6c86c3118acf4cc7dfedf
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
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?
@orta can you add a changeset?
Looks like just need to run prettier @orta
on the markdown that gets thrown away? That should be in the exceptions
@n1ru4l @saihaj Can we get this merged? ππ»
CI is failing :/
CI is failing :/
Rerun it? All but one appear fineπ
And Orta is right with Prettier; .changeset shouldn't be linted
@jeengbe Unit tests are failing :)
@jeengbe Unit tests are failing :)
Run it once more, it worked locally on the second attempt π
@ardatan @orta See https://github.com/orta/envelop/pull/1
In response to https://github.com/getsentry/sentry-javascript/discussions/7083#discussioncomment-4918660, 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.