fix(astro): Fix astro trace propagation issues #14501
Open
+97
−46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Noticed this while working on #14481.
This PR fixes a bug in our opentelemetry code that lead to invalid empty span IDs being generated in certain cases.
Instead, we now generate valid (but random) span IDs in this case.
Additionally, I also noticed that the way we try-catched the astro server request code lead to the http.server span not being attached to servers correctly - we had a try-catch block outside of the
startSpan
call, where we sent caught errors to sentry. but any error caught this way would not have an active span (because by the time thecatch
part triggers,startSpan
is over), and thus the http.server span would not be attached to the error. By moving this try-catch inside of thestartSpan
call, we can correctly assign the span to errors. I also tried to add some tests to this - there is still a problem in there which the tests show, which I'll look at afterwards (and/or they may get fixed by #14481)UPDATE: Turns out part of this, the generation of an
''
span ID, has other implications - otel ignores this as it is invalid, so changing this breaks the pure otel E2E apps. I'll tackle this separately, this PR only handles better try-catching of error traces now.