Skip to content

Comments

feat: Add startupTracingIntegration#1282

Merged
timfish merged 10 commits intomasterfrom
feat/startup-tracing
Jan 15, 2026
Merged

feat: Add startupTracingIntegration#1282
timfish merged 10 commits intomasterfrom
feat/startup-tracing

Conversation

@timfish
Copy link
Collaborator

@timfish timfish commented Jan 7, 2026

Used this like:

main.js

import * as Sentry from '@sentry/electron/main';

Sentry.init({
  dsn: '__DSN__',
  tracesSampleRate: 1,
  integrations: [Sentry.startupTracingIntegration()],
});

The startupTracingIntegration captures Electron startup events as tracing spans.

If you also use the browserTracingIntegration in the renderer, this envelope is intercepted and it's spans are added to the main process startup transaction.

renderer.js

import * as Sentry from '@sentry/electron/renderer';

Sentry.init({
  integrations: [Sentry.browserTracingIntegration()],
  tracesSampleRate: 1,
});

Outstanding issues

Once this is merged it will look like this:

image

@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • Add startupTracingIntegration by timfish in #1282
  • Add support for propagateTraceparent by timfish in #1277

Bug Fixes 🐛

  • TypeScript warning by timfish in #1281

Build / dependencies / internal 🔧

Release

  • Bump Craft version to fix issues by BYK in #1286
  • Switch from action-prepare-release to Craft by BYK in #1283

Other

  • (deps) Bump qs from 6.13.0 to 6.14.1 by dependabot in #1279
  • Auto SDK update PRs now include SDK version in name for release notes by timfish in #1288
  • Simpler Electron version lookup by timfish in #1280

Other

  • test: Fix another flakey test by timfish in #1284
  • test: New Sentry SDK version by github-actions in #1278
  • test: More Electron versions by timfish in #1273

🤖 This preview updates automatically when you update the PR.

@timfish timfish marked this pull request as ready for review January 12, 2026 18:38
@timfish timfish requested a review from AbhiPrasad January 12, 2026 18:38
Copy link
Contributor

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to enable this by default, but we can probably do that in the next major.

startTime,
},
(span) => {
span.end(startTime * 1000);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The span.end() method is called with timestamps multiplied by 1000, likely passing milliseconds instead of the expected seconds, which will result in incorrect span end times.
Severity: HIGH

🔍 Detailed Analysis

The code retrieves timestamps in seconds, for example from (Date.now() - uptimeMs) / 1000 or a Sentry event's start_timestamp. While startSpanManual() correctly uses these timestamps as seconds, subsequent calls to span.end() incorrectly multiply the timestamp value by 1000. This likely passes a millisecond value to a method that expects seconds, which would result in spans having invalid end timestamps set far in the future. This inconsistent handling suggests the multiplication is an error.

💡 Suggested Fix

Remove the * 1000 multiplication from all calls to span.end() to ensure timestamps are passed consistently in seconds, matching how they are used in startSpanManual().

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/main/integrations/startup-tracing.ts#L66

Potential issue: The code retrieves timestamps in seconds, for example from `(Date.now()
- uptimeMs) / 1000` or a Sentry event's `start_timestamp`. While `startSpanManual()`
correctly uses these timestamps as seconds, subsequent calls to `span.end()` incorrectly
multiply the timestamp value by 1000. This likely passes a millisecond value to a method
that expects seconds, which would result in spans having invalid end timestamps set far
in the future. This inconsistent handling suggests the multiplication is an error.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8493281

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timfish
Copy link
Collaborator Author

timfish commented Jan 12, 2026

It would be nice to enable this by default, but we can probably do that in the next major.

Until then I could add it to the docs config selector like we already do for browser tracing.

@timfish timfish merged commit bfdedd3 into master Jan 15, 2026
209 of 213 checks passed
@timfish timfish deleted the feat/startup-tracing branch January 15, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants