Skip to content

fix(profiling): Accept dots in the JVM profiling traces dir path - #6334

Draft
runningcode wants to merge 2 commits into
mainfrom
no/fix-profiler-traces-dir-validation
Draft

runningcode wants to merge 2 commits into
mainfrom
no/fix-profiler-traces-dir-validation

Conversation

@runningcode

Copy link
Copy Markdown
Contributor

📜 Description

Fixes two problems in how JavaContinuousProfiler checks the profiling traces directory.

  • Dots no longer disable profiling. The profiler refused any traces directory whose path contained one of 26 characters, . among them. A cache dir like /home/app/.sentry or /opt/my.app/cache logged "Disabling profiling because traces directory path contains invalid character: .". async-profiler only treats two characters in the path specially:

    • , separates its arguments (start,jfr,...,file=<path>);
    • % starts a file-name pattern such as %p or %{ENV}.

    So those two are all it rejects now. The rest were never special: no shell runs the command, and async-profiler only splits key=value at the first =.

  • A rejected config now stays rejected. init() marked itself done before it checked the options and returned true on every later call. So only the first start was refused, and later starts went ahead with the same options, despite the "Disabling profiling" warning. It now remembers the result, as AndroidContinuousProfiler does. Sentry.init creates the traces directory before it builds the profiler, so nothing can make the options valid after the first start.

💡 Motivation and Context

Found while moving the sample system tests into the modules. Any checkout whose path has a dot, such as a worktree under .claude/worktrees/, fails 16 of JavaContinuousProfilerTest's 23 tests, because the fixture's relative tmp cache dir resolves to an absolute path. CI's checkout path has no dot, so it never saw this.

For users, the effect is a lost first profile chunk and a misleading warning, rather than profiling being disabled.

💚 How did you test it?

  • New tests:

    • one starts the profiler with a dot in the traces dir path;
    • one checks that a later start stays refused after the first was.

    Both fail against main's profiler and pass with the fix.

  • In a checkout with a dot in its path, JavaContinuousProfilerTest goes from 16 failures out of 23 to 25 passing. :sentry-async-profiler:check passes.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

None.

🤖 Generated with Claude Code

runningcode and others added 2 commits October 21, 2026 09:11
JavaContinuousProfiler refused any traces directory whose path held one
of 26 characters, including ".", so a cache dir like /home/app/.sentry
or /opt/my.app logged "Disabling profiling". async-profiler only treats
"," (its argument separator) and "%" (file name patterns) specially, so
those are the only characters it still rejects.

The check also only stopped the first start: init() marked itself done
before validating and returned true from then on, so later starts went
ahead with the rejected options. It now remembers the result, as the
Android profiler does.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@sentry

sentry Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.61.0 (1) release

⚙️ sentry-android Build Distribution Settings

This branch has not been deployed

No deployments
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.

1 participant