Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(observability): enable sampled Sentry profiling

Steven Enamakelb31fdc250ac2
diff --git a/app/src/services/__tests__/analytics.test.ts b/app/src/services/__tests__/analytics.test.ts
index 0df4f31b33..abe157ba5e 100644
--- a/app/src/services/__tests__/analytics.test.ts
+++ b/app/src/services/__tests__/analytics.test.ts
@@ -17,6 +17,8 @@ const hoisted = vi.hoisted(() => ({
browserApiErrorsIntegration: vi.fn(() => ({ name: 'BrowserApiErrors' })),
globalHandlersIntegration: vi.fn(() => ({ name: 'GlobalHandlers' })),
httpContextIntegration: vi.fn(() => ({ name: 'HttpContext' })),
+ browserTracingIntegration: vi.fn(() => ({ name: 'BrowserTracing' })),
+ browserProfilingIntegration: vi.fn(() => ({ name: 'BrowserProfiling' })),
// Config state
analyticsEnabled: false,
appEnvironment: 'staging' as 'staging' | 'production' | 'development',
@@ -37,6 +39,8 @@ vi.mock('@sentry/react', () => ({
browserApiErrorsIntegration: hoisted.browserApiErrorsIntegration,
globalHandlersIntegration: hoisted.globalHandlersIntegration,
httpContextIntegration: hoisted.httpContextIntegration,
+ browserTracingIntegration: hoisted.browserTracingIntegration,
+ browserProfilingIntegration: hoisted.browserProfilingIntegration,
}));
// `initSentry()` reads `getCoreStateSnapshot().snapshot.analyticsEnabled` to
@@ -326,16 +330,20 @@ describe('initSentry beforeSend manual-staging bypass', () => {
const opts = hoisted.init.mock.calls[0][0] as {
release: string;
tracesSampleRate: number;
+ profileSessionSampleRate: number;
replaysSessionSampleRate: number;
replaysOnErrorSampleRate: number;
integrations: Array<{ name?: string }>;
};
expect(opts.release).toBe('openhuman@test+abc');
- expect(opts.tracesSampleRate).toBe(0);
+ expect(opts.tracesSampleRate).toBe(0.1);
+ expect(opts.profileSessionSampleRate).toBe(0.1);
expect(opts.replaysSessionSampleRate).toBe(0);
expect(opts.replaysOnErrorSampleRate).toBe(0);
const names = opts.integrations.map(i => i.name).filter(Boolean);
expect(names).toContain('HttpContext');
+ expect(names).toContain('BrowserTracing');
+ expect(names).toContain('BrowserProfiling');
});
test('registers inboundFiltersIntegration so ignoreErrors is not inert (#3963)', async () => {
diff --git a/app/src/services/analytics.ts b/app/src/services/analytics.ts
index b358a5ad66..23600039f6 100644
--- a/app/src/services/analytics.ts
+++ b/app/src/services/analytics.ts
@@ -154,7 +154,10 @@ export function initSentry(): void {
// Privacy: disable EVERYTHING that could leak sensitive state.
replaysSessionSampleRate: 0,
replaysOnErrorSampleRate: 0,
- tracesSampleRate: 0,
+ // Collect sampled performance transactions and CPU profiles from
+ // browser/WebView sessions.
+ tracesSampleRate: 0.1,
+ profileSessionSampleRate: 0.1,
defaultIntegrations: false,
integrations: [
// #3963: `defaultIntegrations: false` (above) drops the integration that
@@ -178,6 +181,8 @@ export function initSentry(): void {
// narrows what survives from the request envelope (headers only, UA
// only) to keep this aligned with the privacy contract.
Sentry.httpContextIntegration(),
+ Sentry.browserTracingIntegration(),
+ Sentry.browserProfilingIntegration(),
],
sendDefaultPii: false,
diff --git a/crates/openhuman-embed/src/process_sentry.rs b/crates/openhuman-embed/src/process_sentry.rs
index 579e6ce4c9..886c39e9e3 100644
--- a/crates/openhuman-embed/src/process_sentry.rs
+++ b/crates/openhuman-embed/src/process_sentry.rs
@@ -144,6 +144,10 @@ pub fn client_options(config: SentryConfig) -> ClientOptions {
send_default_pii: false,
before_send: Some(Arc::new(move |event| before_send(event, user_id))),
sample_rate: 1.0,
+ // Sample performance transactions emitted by the shared Sentry
+ // tracing layer. This applies to the embedded desktop core and the
+ // CLI/TUI hosts that use the same options.
+ traces_sample_rate: 0.1,
transport: Some(Arc::new(openhuman_core::core::sentry_transport::factory)),
..ClientOptions::default()
}
diff --git a/crates/openhuman-embed/src/process_sentry_tests.rs b/crates/openhuman-embed/src/process_sentry_tests.rs
index 0718d45405..9b7220023d 100644
--- a/crates/openhuman-embed/src/process_sentry_tests.rs
+++ b/crates/openhuman-embed/src/process_sentry_tests.rs
@@ -226,6 +226,7 @@ fn client_options_wire_the_chain_and_the_transport() {
release_tag("1.0.0", None),
"test".into(),
));
+ assert_eq!(options.traces_sample_rate, 0.1);
assert!(options.dsn.is_none(), "an unparsable DSN sends nothing");
assert_eq!(options.release.as_deref(), Some("[email protected]"));
assert_eq!(options.environment.as_deref(), Some("test"));