-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: Initial tracing setup (peer deps + utils) #13899
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
base: main
Are you sure you want to change the base?
feat: Initial tracing setup (peer deps + utils) #13899
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
cc0eef5
to
7f08f16
Compare
🦋 Changeset detectedLatest commit: 4b64316 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
7f08f16
to
1472161
Compare
6ce43ea
to
293392b
Compare
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.
This looks good to me. As discussed on Slack, it might be nice if users had the ability to modify the root span (e.g. via a requestHook
).
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.
Nice! Thanks a lot for adding this!
Just had a minor concern about performance of dynamically importing @opentelemetry/api
multiple times but I think overall, the implementation is great!
span.recordException({ | ||
name: 'HttpError', | ||
message: error.body.message | ||
}); |
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.
does a HttpError
also have a stack
? If so, would be cool to also record the stack trace.
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.
Furthermore, I'm not 100% sure if this applies here but in our SDK, when we capture HttpError
s, we ignore 4xx errors because usually you don't want to record exceptions for bad requests, 404s, etc. Might be worth a thought if they are valuable or too noisy but happy to leave the call up to you!
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.
Yeah, lemme think about this one -- not sure if we should just exclude all 400s or give users the ability to filter status codes. My initial feeling is just exclude 400s and see if anyone ever asks for the ability to see them
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.
We should probably share the logic contained in #13848
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.
Don't think I agree -- this is just about setting the status of the span, not whether we capture the span at all. I adjusted the logic to only set an error status on >=500; otherwise it's captured as a normal span
c8c11f9
to
eca0d11
Compare
eca0d11
to
0c3aad6
Compare
…13900) * feat: Add tracing to `load`, server actions, and `handle`/`resolve` * feat: add universal IDs to client nodes * approve otp dep build * add links for docs * since tags * clarify * explain util * import the rest of the types through jsdoc import statements * generate types --------- Co-authored-by: Chew Tee Ming <chew.tee.ming@nindatech.com>
Thanks! This looks good. I think all we need is a changeset and some documentation on how to get started. The instructions could be similar to the setup in the demo of #13900 (comment) or we might want to try and get something like #13776 merged next cc: @manuel3108 @AdrianGonz97 would we want to add some kind of OpenTelemetry or Sentry add-on to the Svelte CLI in the future to make the setup more seamless? |
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.
nice! mostly looks good but I think we can avoid passing tracer
around etc
/** | ||
* Whether to enable server-side [OpenTelemetry](https://opentelemetry.io/) tracing for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#Server-hooks-handle), [`load` functions](https://svelte.dev/docs/kit/load), and [form actions](https://svelte.dev/docs/kit/form-actions). | ||
* @default undefined | ||
* @since 2.26.0 // TODO: update this before publishing |
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.
TODO
|
||
/** | ||
* Access to spans for tracing. If tracing is not enabled or the function is being run in the browser, these spans will do nothing.\ | ||
* @since 2.26.0 // TODO: update this before publishing |
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.
TODO
Co-authored-by: Rich Harris <richard.a.harris@gmail.com>
Co-authored-by: Rich Harris <richard.a.harris@gmail.com>
|
||
/** | ||
* Access to spans for tracing. If tracing is not enabled, these spans will do nothing. | ||
* @since 2.26.0 // TODO: update this before publishing |
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.
Also TODO
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.
beautiful 😍
nervous about that test failure, not sure why that's happening suddenly |
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.
rescinding my earlier approval because i was reminded that this should probably have some docs
Adds spans to
load
(on the server), server actions, andhandle
/resolve
. It also adds atracing
object withenabled
,root
, andcurrent
to theRequestEvent
,ServerLoadEvent
, andLoadEvent
types. This means you can get access to a span to annotate it pretty much anywhere -- including usinggetRequestEvent
(this could be quite nice for library integrations!).We're punting on clientside tracing for now, as we do not feel the o11y community has sufficiently converged on approaches (see https://github.com/open-telemetry/community/blob/main/projects/browser-phase-1.md). When OTEL provides a stable and truly browser-native tracing platform, we'll be all over it.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits