Skip to content

fix(telemetry): Resolve default org via ValueSource at execution (GRADLE-82)#1263

Merged
runningcode merged 3 commits into
mainfrom
no/config-cache-telemetry-org
Jun 9, 2026
Merged

fix(telemetry): Resolve default org via ValueSource at execution (GRADLE-82)#1263
runningcode merged 3 commits into
mainfrom
no/config-cache-telemetry-org

Conversation

@runningcode

@runningcode runningcode commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

When telemetry is enabled (the default), the plugin resolved the default Sentry organization and CLI version during the configuration phase via two ValueSources (SentryCliInfoValueSource running sentry-cli info, and SentryCliVersionValueSource running sentry-cli --version). Because both were .get()-ed during configuration, Gradle tracked them as configuration inputs and re-evaluated them on every configuration-cache-hit build — spawning two sentry-cli processes on every build even when no Sentry task ran. On a ~100-module project this added ~38% configuration overhead.

This replaces them with a single SentryOrgValueSource that is queried lazily on the first tracked task, so the sentry-cli process runs during execution and stays off the configuration phase. The CLI version now comes directly from BuildConfig.CliVersion.

This is one of two PRs splitting the config-cache work; the companion PR (#GRADLE-70) makes the sentry-cli path resolution config-cache friendly. Whichever lands second will drop the now-unused cliExecutable parameter still threaded through configure().

image

Behavioral note: when the default org attaches

Previously the default org was resolved at configuration time and set on the telemetry scope inside start() (at taskGraph.whenReady), so it was attached before execution began. Now it attaches lazily on the first telemetry-tracked task to execute (via attachDefaultOrg(), called from startTask).

Every Sentry upload task is telemetry-wrapped (withSentryTelemetrystartTask) — mappings, native symbols, app artifact, source bundle, the ProGuard UUID/dependency-report tasks, etc. — so any build that actually does a Sentry upload runs at least one tracked task and gets the default org attached. The only events that would miss the default org are those captured strictly before any tracked task runs (e.g. a failure during the configuration phase). That's an inherent and acceptable consequence of moving the sentry-cli info call off the configuration phase, which is the whole point of this change; an explicitly configured org is still set eagerly in start() and is unaffected.

Fixes GRADLE-82

🤖 Generated with Claude Code

@linear-code

linear-code Bot commented Jun 4, 2026

Copy link
Copy Markdown

GRADLE-82

@runningcode
runningcode force-pushed the no/config-cache-telemetry-org branch from ce7be81 to a5eb5b8 Compare June 4, 2026 12:43

@romtsn romtsn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

dope!

runningcode and others added 3 commits June 9, 2026 09:18
…DLE-82)

When telemetry is enabled (the default), the plugin resolved the default
Sentry organization and CLI version at configuration time via two
ValueSources that each spawned a sentry-cli process. Because they were
`.get()`-ed during configuration, Gradle tracked them as configuration
inputs and re-ran both processes on every configuration-cache-hit build,
adding significant overhead even when no Sentry task executed.

Replace them with a single SentryOrgValueSource that is queried lazily on
the first tracked task, so the sentry-cli process runs during execution
and stays off the configuration phase. The CLI version now comes
straight from BuildConfig.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
attachDefaultOrg() runs on the first tracked task and may be invoked
concurrently from parallel task threads. Replace the plain Boolean flag
and its check-then-set with an AtomicBoolean compareAndSet so the attach
body runs exactly once and the flag's visibility is guaranteed across
threads.

This is a robustness tightening, not a fix for duplicate sentry-cli
processes: the process is spawned inside the SentryOrgValueSource, which
Gradle evaluates at most once per build regardless of this flag.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@runningcode
runningcode force-pushed the no/config-cache-telemetry-org branch from a5eb5b8 to 0ad3a9e Compare June 9, 2026 07:26

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0ad3a9e. Configure here.

}
}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Parallel tasks miss default org

Low Severity

attachDefaultOrg uses compareAndSet so only one caller runs orgProvider, while other concurrent startTask calls return immediately. If Gradle runs multiple telemetry-wrapped tasks in parallel, siblings can start spans before the winning thread finishes sentry-cli info and updates the scope user, so early events may lack the default organization.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0ad3a9e. Configure here.

@runningcode
runningcode merged commit 42ff7d7 into main Jun 9, 2026
23 checks passed
@runningcode
runningcode deleted the no/config-cache-telemetry-org branch June 9, 2026 07:51
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