feat(sentry): add distributed tracing between Studio and ToolHive API#1916
Merged
feat(sentry): add distributed tracing between Studio and ToolHive API#1916
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Enables end-to-end distributed tracing by propagating trace context from the Studio (Electron main + renderer) to the locally spawned ToolHive API server.
Changes:
- Configure Sentry in both renderer and main processes to propagate
traceparent/Sentry tracing headers to localhost/127.0.0.1 requests. - Forward Sentry DSN/environment/sample-rate to the spawned
thv serveprocess via CLI flags whenVITE_SENTRY_THV_DSNis set. - Add
VITE_SENTRY_THV_DSNto env typings and.env.example.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| renderer/src/lib/sentry.ts | Enables trace header propagation for local API calls initiated by the renderer. |
| main/src/sentry.ts | Enables trace header propagation for local API calls initiated by the main process. |
| main/src/toolhive-manager.ts | Adds conditional forwarding of Sentry configuration to the spawned ToolHive server process. |
| main/src/vite-env.d.ts | Adds env typing for VITE_SENTRY_THV_DSN. |
| .env.example | Documents the new env var for ToolHive server Sentry DSN. |
Add propagateTraceparent and tracePropagationTargets to both main and renderer Sentry.init() so sentry-trace, baggage, and W3C traceparent headers are automatically injected into fetch requests to localhost / 127.0.0.1.
When VITE_SENTRY_THV_DSN is set, pass --sentry-dsn, --sentry-environment, and --sentry-traces-sample-rate to the spawned thv serve process so the Go backend reports spans to the same trace.
… in E2E Check isTelemetryEnabled from the DB before passing --sentry-* flags to thv serve, and skip entirely when TOOLHIVE_E2E is set — matching the guard used by the Studio Sentry init. Add unit tests for all three branches (DSN + telemetry enabled, no DSN, telemetry disabled).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Enables end-to-end distributed tracing so that API requests initiated in Studio appear correlated with their server-side spans in Sentry.
Changes
we need to wait this PR to be included in a release