Skip to content

fix: apply the tracer snapshot/log rate policy to sampling defaults (DEBUG-5730)#2241

Draft
p-datadog wants to merge 2 commits into
DataDog:mainfrom
p-datadog:ddsign/capture-expressions-snapshot-rate
Draft

fix: apply the tracer snapshot/log rate policy to sampling defaults (DEBUG-5730)#2241
p-datadog wants to merge 2 commits into
DataDog:mainfrom
p-datadog:ddsign/capture-expressions-snapshot-rate

Conversation

@p-datadog

@p-datadog p-datadog commented Jul 15, 2026

Copy link
Copy Markdown
Member

Motivation

Log probes default sampling_snapshots_per_second to 5000 (the log rate) when no explicit sampling is set. That's correct for plain log probes, but a probe that emits a snapshot — a full captureSnapshot or capture expressions — is cost-equivalent to a snapshot and should be limited like one. Running snapshots under the log rate limit is the DEBUG-5730 apm-processing CPU spike.

The Ruby tracer already encodes this policy (probe.rb): (@capture_snapshot || capture_expressions present) ? 1 : 5000. This applies the same policy in the shared parser, which is where PHP (and other libdatadog consumers) get their defaults.

Change

  • Name the two defaults: SNAPSHOT_SAMPLING_SNAPSHOTS_PER_SECOND = 1, LOG_SAMPLING_SNAPSHOTS_PER_SECOND = 5000 (previously bare literals, and 5000 was duplicated).
  • Absent explicit sampling, default any snapshot-emitting log probe (full snapshot or capture expressions) to the snapshot rate; plain log probes keep the log rate.
  • Tests for all three branches (capture-expression default, snapshot default, plain-log default).

Behavior change / open questions

  • This now also lowers the default for plain captureSnapshot probes with no explicit sampling (5000 → 1). That matches Ruby and is arguably a latent-bug fix, but it's a behavior change for any libdatadog consumer relying on the old 5000 default for snapshot probes — please sanity-check.
  • The value 1 is imported from the Ruby tracer's convention; confirming it's the intended snapshot rate for the other consumers would be good.
  • I could not compile locally (repo Cargo.lock is v4, toolchain is 1.75); relying on CI.
  • One of a 4-PR chain to enable PHP capture expressions (libdatadog \u2192 dd-trace-php \u2192 dd-source \u2192 web-ui). Draft until reviewed.

When a log probe carries captureExpressions and no explicit sampling,
default its sampling_snapshots_per_second to 1/s (snapshot rate) instead
of the 5000/s log default. Evaluating capture expressions is
cost-equivalent to a full snapshot; running them under the log rate
limit spikes apm-processing CPU (the same class of issue that gated
Java <1.64.0 and Python <4.11.0).
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 8 Pipeline jobs failed

Clippy Annotation Reporter | clippy-annotation-reporter   View in Datadog   GitHub Actions

Metadata, docs and deps | dependency-check   View in Datadog   GitHub Actions

Metadata, docs and deps | missing-docs   View in Datadog   GitHub Actions

View all 8 failed jobs.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c29a74e | Docs | Datadog PR Page | Give us feedback!

Name the two defaults (SNAPSHOT_SAMPLING_SNAPSHOTS_PER_SECOND = 1,
LOG_SAMPLING_SNAPSHOTS_PER_SECOND = 5000) and, absent explicit sampling,
default any snapshot-emitting log probe (full captureSnapshot OR capture
expressions) to the snapshot rate, matching the Ruby tracer's
(@capture_snapshot || capture_expressions present) ? 1 : 5000 policy.
Plain log probes keep the log rate. Also removes the duplicated 5000
literal on the service-config default.
@p-datadog p-datadog changed the title fix: default capture-expression probes to snapshot rate (DEBUG-5730) fix: apply the tracer snapshot/log rate policy to sampling defaults (DEBUG-5730) Jul 15, 2026
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