-
Notifications
You must be signed in to change notification settings - Fork 821
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
chore: allow parent span to be null #569
chore: allow parent span to be null #569
Conversation
Codecov Report
@@ Coverage Diff @@
## master #569 +/- ##
==========================================
- Coverage 92.49% 92.22% -0.27%
==========================================
Files 157 149 -8
Lines 7951 7411 -540
Branches 682 638 -44
==========================================
- Hits 7354 6835 -519
+ Misses 597 576 -21
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
const entries = this._getEntries(); | ||
|
||
const rootSpan = this._startSpan( | ||
AttributeNames.DOCUMENT_LOAD, | ||
PTN.FETCH_START, | ||
entries, | ||
{ parent: serverContext } | ||
{ parent: parseTraceParent(metaElement?.content ?? '') } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like optional chaining was finally added in TS3.7... Cool!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only works for node apparently. It breaks the browser test.
I'm not sure if it isn't too late, but for me it looks like generally replacing undefined with null, which might produce more problems with typing in future. Why can't we have undefined instead of null in general and then handle correctly the optional |
Just to give you even better context why it should remain |
The returns are opposite but I get the idea. I think I like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@mayurkale22 how do you feel about the null/undefined issue? Regarding @obecny's links:
I still think null and undefined have different semantic meaning regardless of whether or not they are a good idea as a language-level concept. That said, I don't really feel strongly about it and am happy to just use edit: another way to look at it: |
@dyladan I know these are for maintainers :) but basically I think we might end up with having |
And still wonder how will the mixed types propagate between different systems when trying to serialise spans with null values. Will all systems handle that correctly as |
The need for this If its really a problem, we will need to edit the scopes managers to use |
@vmarchaud even if that's the case, it is of limited value. You treat it the same way every time. Whether the span is undefined or null, you still don't have a parent to put on your span so you still create a new span with no parent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@mayurkale22 think this is ready for merge |
* chore(plugin-mongodb-core): add missing codecov script * fix(mongodb-plugin): check currentSpan against undefined * chore(scope-managers): return undefined if no scope is found (following #569)
* docs(instrumentation-graphql): improve README.md * docs: updated README according to PR review * fix(graphql): fixed graphql example it didn't work since @opentelemetry/api package was missing and update @opentelemetry/instrumentation-express and @opentelemetry/instrumentation-graphql Co-authored-by: Bartlomiej Obecny <[email protected]>
Which problem is this PR solving?
Short description of the changes
parent: tracer.getCurrentSpan() || undefined