Skip to content

feat(instrumentation)!: gate continuous profiler behind profiler_enabled#166

Open
kamranf wants to merge 1 commit into
mainfrom
kamranf/decouple-profiler-from-instrumentation
Open

feat(instrumentation)!: gate continuous profiler behind profiler_enabled#166
kamranf wants to merge 1 commit into
mainfrom
kamranf/decouple-profiler-from-instrumentation

Conversation

@kamranf

@kamranf kamranf commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Why

The continuous profiler is gated on instrumentation.enabled — the same flag that turns on APM tracing. So every service running with enabled: true also runs the profiler, and there is no way to keep tracing while turning the profiler off. Because the profiler bills per host, that inflates continuous-profiler host usage in environments where profiling isn't wanted.

What

Decouple the profiler from tracing with its own opt-in flag:

  • config.go: add ProfilerEnabled bool (mapstructure:"profiler_enabled").
  • profiler.go: NewProfiler now gates on config.ProfilerEnabled instead of config.Enabled. Tracer gating (router.go, on Enabled) is unchanged.
  • Tests: profiler_test.go covers the gating matrix (off by default, opt-in on, decoupled from Enabled).
  • README: document the opt-in + the default-off behavior with a settings example.

Profiling is now off by default and enabled per-environment via profiler_enabled: true (typically production).

⚠️ Breaking change

The profiler no longer starts based on instrumentation.enabled. Services that want profiling (e.g. in production) must set profiler_enabled: true, or their profiles stop on upgrade. Tracing is unaffected. The commit carries a BREAKING CHANGE: footer, so semantic-release cuts a major version.

Rollout: after this releases, bump go-sdk in consumer services and set profiler_enabled: true in their production config where profiling is wanted.

Verification

  • CI build job (go build + go test ./...) passing on this branch.

@kamranf
kamranf force-pushed the kamranf/decouple-profiler-from-instrumentation branch from 9e10c9e to 0b9ea7a Compare July 14, 2026 14:22
The profiler was gated on `enabled` — the same flag that turns on tracing — so
every service with `enabled: true` also ran the continuous profiler. That makes
the profiler impossible to turn off without also losing tracing, and drives up
continuous-profiler per-host usage in environments where profiling isn't needed.

Add a dedicated `profiler_enabled` setting so the profiler is off by default and
controlled independently of `enabled`. Tracing is unaffected. To keep profiling,
set `profiler_enabled: true` in the environments where it is wanted (typically
production).

BREAKING CHANGE: the continuous profiler no longer starts based on
`instrumentation.enabled`. It is off unless `instrumentation.profiler_enabled`
is true. Services that want profiling (e.g. in production) must opt in by
setting `profiler_enabled: true`, otherwise their profiles will stop.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kamranf
kamranf force-pushed the kamranf/decouple-profiler-from-instrumentation branch from 0b9ea7a to 01f560c Compare July 14, 2026 14:24
@kamranf
kamranf marked this pull request as ready for review July 14, 2026 14:55
@kamranf
kamranf requested a review from a team as a code owner July 14, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant