[PAR] trace private action executions#49526
[PAR] trace private action executions#49526julesmcrt merged 1 commit intojules.macret/Q/lightweight-tracer-improvementsfrom
Conversation
Go Package Import DifferencesBaseline: d0fef68
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb30791506
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
dd-gplassard
left a comment
There was a problem hiding this comment.
A few nits but looks good, thanks !
Should be merged with #49488 to propagate the trace from the backend (can be done as a followup)
| // priority and, if it signals reject (<= 0), the backend drops them. | ||
| // Standard values: -1 = USER_REJECT, 0 = AUTO_REJECT, 1 = AUTO_KEEP, | ||
| // 2 = USER_KEEP. Omit to use the tracer's default (USER_KEEP). | ||
| ApmSamplingPriority *int `json:"apmSamplingPriority,omitempty"` |
There was a problem hiding this comment.
feels like this should be managed at the AP level no ? (we have some metadata attributes on our task)
There was a problem hiding this comment.
Good point. I kept it on RunCommandInputs for this PR because we do not yet have a task-level metadata field on the types.Task envelope (only Attributes.Inputs, JobId, Client, etc. — see types/task.go). Happy to follow up once the backend/task envelope can carry arbitrary metadata; at that point the sampling-priority flag becomes generic across all actions. Tracking as a follow-up.
| span.SetService(rshellSpanService) | ||
| span.SetResourceName("execution") | ||
| defer func() { span.Finish(nil) }() | ||
| } |
There was a problem hiding this comment.
I think we could wrap action.Run and have it for all actions ?
https://github.com/DataDog/datadog-agent/pull/49526/changes#diff-9448fa3edd4678d5fd48c3f46775321ca7d2448d8660ac1f31c03904fdb19109L116
There was a problem hiding this comment.
Agreed that wrapping action.Run at the workflow-runner level would avoid duplicating span boilerplate in each action. I kept the rshell.script wrap inside the rshell handler for now because it serves as the service-boundary span: it's the span that flips the APM service from private-action-runner (the task wrap in WorkflowRunner.RunTask) to rshell, and every child command/pipeline/for/if span inherits that chain. If we wrap at action.Run in the runner, we need the action to declare its desired service name (e.g. via a new Action.Service() string method) so the runner knows what to stamp. Reasonable next step — happy to do it as a follow-up.
| // parSpanService is the Datadog APM service name used for spans that | ||
| // represent private-action-runner work itself (task dispatch, etc.). | ||
| // rshell-specific spans override this to "rshell" via [Span.SetService]. | ||
| const parSpanService = "private-action-runner" |
There was a problem hiding this comment.
can we put this in observability ? 🙏
There was a problem hiding this comment.
The constant now lives in the telemetry def package as partelemetry.ParServiceName (and RshellServiceName for the rshell override). I put it there rather than observability because comp/privateactionrunner/telemetry/impl/telemetry.go also needs it and comp/ cannot import pkg/ (depguard). Single source of truth for both sides, which also resolves the "duplicated" comment below.
|
Addressed the feedback from @chatgpt-codex-connector and @dd-gplassard in 8fa1291: Fixed
Follow-ups (replied inline)
|
Summary
Testing
No new commit was created (working tree was already clean), and I did not call |
| /comp/notableevents @DataDog/windows-products | ||
| /comp/offlinereporter @DataDog/agent-metric-pipelines | ||
| /comp/privateactionrunner @DataDog/action-platform | ||
| /comp/privateactionrunner/telemetry @DataDog/action-platform |
There was a problem hiding this comment.
should be implicit from the previous line no ?
| // Stamp error type only — don't pass err to Finish, which would | ||
| // record error.message / error.stack / error.details. Action | ||
| // errors can embed customer data (rshell parse errors quote the | ||
| // offending script fragment; HTTP action errors can carry URLs | ||
| // and response bodies). The task_id + error type is enough to | ||
| // correlate back to the action log for details. | ||
| defer func() { | ||
| if err != nil { | ||
| span.SetTag("error", 1) | ||
| span.SetTag("error.type", fmt.Sprintf("%T", err)) | ||
| } | ||
| span.Finish(nil) | ||
| }() |
There was a problem hiding this comment.
feels like we could create a errors.New making sure we construct it from "safe" values and keep idiomatic usage
jeremy-hanna
left a comment
There was a problem hiding this comment.
👍 for agent-runtime owned files
18ca58b to
e514c88
Compare
Files inventory check summaryFile checks results against ancestor d0fef680: Results for datadog-agent_7.80.0~devel.git.58.914e439.pipeline.108551498-1_amd64.deb:No change detected |
Regression DetectorRegression Detector ResultsMetrics dashboard Baseline: d0fef68 Optimization Goals: ✅ No significant changes detected
|
| perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
|---|---|---|---|---|---|---|
| ➖ | docker_containers_cpu | % cpu utilization | -3.51 | [-6.48, -0.53] | 1 | Logs |
Fine details of change detection per experiment
| perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
|---|---|---|---|---|---|---|
| ➖ | tcp_syslog_to_blackhole | ingress throughput | +0.80 | [+0.61, +0.99] | 1 | Logs |
| ➖ | ddot_metrics | memory utilization | +0.53 | [+0.34, +0.72] | 1 | Logs |
| ➖ | quality_gate_idle | memory utilization | +0.09 | [+0.04, +0.14] | 1 | Logs bounds checks dashboard |
| ➖ | file_to_blackhole_1000ms_latency | egress throughput | +0.07 | [-0.36, +0.51] | 1 | Logs |
| ➖ | docker_containers_memory | memory utilization | +0.05 | [-0.03, +0.13] | 1 | Logs |
| ➖ | ddot_logs | memory utilization | +0.02 | [-0.05, +0.08] | 1 | Logs |
| ➖ | otlp_ingest_metrics | memory utilization | +0.02 | [-0.14, +0.18] | 1 | Logs |
| ➖ | file_to_blackhole_500ms_latency | egress throughput | +0.01 | [-0.40, +0.42] | 1 | Logs |
| ➖ | ddot_metrics_sum_cumulativetodelta_exporter | memory utilization | +0.00 | [-0.22, +0.22] | 1 | Logs |
| ➖ | tcp_dd_logs_filter_exclude | ingress throughput | -0.00 | [-0.12, +0.11] | 1 | Logs |
| ➖ | file_to_blackhole_0ms_latency | egress throughput | -0.00 | [-0.51, +0.51] | 1 | Logs |
| ➖ | uds_dogstatsd_to_api_v3 | ingress throughput | -0.00 | [-0.20, +0.20] | 1 | Logs |
| ➖ | uds_dogstatsd_to_api | ingress throughput | -0.01 | [-0.21, +0.19] | 1 | Logs |
| ➖ | file_to_blackhole_100ms_latency | egress throughput | -0.04 | [-0.20, +0.11] | 1 | Logs |
| ➖ | otlp_ingest_logs | memory utilization | -0.07 | [-0.17, +0.03] | 1 | Logs |
| ➖ | uds_dogstatsd_20mb_12k_contexts_20_senders | memory utilization | -0.10 | [-0.15, -0.04] | 1 | Logs |
| ➖ | quality_gate_idle_all_features | memory utilization | -0.25 | [-0.29, -0.22] | 1 | Logs bounds checks dashboard |
| ➖ | ddot_metrics_sum_delta | memory utilization | -0.61 | [-0.79, -0.44] | 1 | Logs |
| ➖ | file_tree | memory utilization | -0.71 | [-0.77, -0.65] | 1 | Logs |
| ➖ | ddot_metrics_sum_cumulative | memory utilization | -0.81 | [-0.96, -0.66] | 1 | Logs |
| ➖ | quality_gate_metrics_logs | memory utilization | -1.06 | [-1.30, -0.82] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_logs | % cpu utilization | -2.23 | [-3.84, -0.62] | 1 | Logs bounds checks dashboard |
| ➖ | docker_containers_cpu | % cpu utilization | -3.51 | [-6.48, -0.53] | 1 | Logs |
Bounds Checks: ✅ Passed
| perf | experiment | bounds_check_name | replicates_passed | observed_value | links |
|---|---|---|---|---|---|
| ✅ | docker_containers_cpu | simple_check_run | 10/10 | 715 ≥ 26 | |
| ✅ | docker_containers_memory | memory_usage | 10/10 | 275.12MiB ≤ 370MiB | |
| ✅ | docker_containers_memory | simple_check_run | 10/10 | 676 ≥ 26 | |
| ✅ | file_to_blackhole_0ms_latency | memory_usage | 10/10 | 0.19GiB ≤ 1.20GiB | |
| ✅ | file_to_blackhole_0ms_latency | missed_bytes | 10/10 | 0B = 0B | |
| ✅ | file_to_blackhole_1000ms_latency | memory_usage | 10/10 | 0.24GiB ≤ 1.20GiB | |
| ✅ | file_to_blackhole_1000ms_latency | missed_bytes | 10/10 | 0B = 0B | |
| ✅ | file_to_blackhole_100ms_latency | memory_usage | 10/10 | 0.20GiB ≤ 1.20GiB | |
| ✅ | file_to_blackhole_100ms_latency | missed_bytes | 10/10 | 0B = 0B | |
| ✅ | file_to_blackhole_500ms_latency | memory_usage | 10/10 | 0.22GiB ≤ 1.20GiB | |
| ✅ | file_to_blackhole_500ms_latency | missed_bytes | 10/10 | 0B = 0B | |
| ✅ | quality_gate_idle | intake_connections | 10/10 | 4 = 4 | bounds checks dashboard |
| ✅ | quality_gate_idle | memory_usage | 10/10 | 175.65MiB ≤ 181MiB | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | intake_connections | 10/10 | 4 = 4 | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | memory_usage | 10/10 | 503.46MiB ≤ 550MiB | bounds checks dashboard |
| ✅ | quality_gate_logs | intake_connections | 10/10 | 4 ≤ 6 | bounds checks dashboard |
| ✅ | quality_gate_logs | memory_usage | 10/10 | 208.07MiB ≤ 220MiB | bounds checks dashboard |
| ✅ | quality_gate_logs | missed_bytes | 10/10 | 0B = 0B | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | cpu_usage | 10/10 | 344.47 ≤ 2000 | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | intake_connections | 10/10 | 4 ≤ 6 | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | memory_usage | 10/10 | 406.10MiB ≤ 475MiB | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | missed_bytes | 10/10 | 0B = 0B | bounds checks dashboard |
Explanation
Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%
Performance changes are noted in the perf column of each table:
- ✅ = significantly better comparison variant performance
- ❌ = significantly worse comparison variant performance
- ➖ = no significant change in performance
A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".
For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:
-
Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.
-
Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.
-
Its configuration does not mark it "erratic".
CI Pass/Fail Decision
✅ Passed. All Quality Gates passed.
- quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
- quality_gate_metrics_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
Emit an `action.run` span in WorkflowRunner.RunTask on service `private-action-runner`, with the action FQN as the resource name and the task id as a tag. Rshell's runCommand swaps the context service to `rshell` before invoking the interpreter so rshell's child spans inherit the rshell service. Bootstrap a fleet installer lightweight tracer in the PAR component lifecycle using api_key + configured site so spans reach the instrumentation-telemetry-intake. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
e514c88 to
914e439
Compare
ecf0698
into
jules.macret/Q/lightweight-tracer-improvements
### What does this PR do? Improve #49526 by getting the trace / span IDs from the backend This way all spans are linked in the UI of Datadog! Also requires backend PR DataDog/dd-source#412290 ### Motivation ### Describe how you validated your changes ### Additional Notes --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
What does this PR do?
Adds tracing in the Private Action Runner so each task dispatch emits a span on
service: private-action-runner. The rshell bundle swaps the context service torshellbefore invoking the interpreter, so rshell-emitted child spans land onservice: rshell.Span layout
Changes
WorkflowRunner.RunTaskwraps every dispatch in anaction.runspan. Resource = action FQN,task_idas a tag.rshell.runCommandsetsservice: rshellon the context before invokinginterp.Runner.Runso rshell's public callbacks (OnCommandDispatch, OnPipelineStart, …) attribute child spans correctly.fleettelemetry.Telemetryflusher at startup usingapi_key+ configuredsiteso spans ship to the instrumentation telemetry intake.pkg/privateactionrunner/observability/traces.goholds the service and operation name constants.Motivation
Give PAR and rshell runtime visibility in APM. Enables debugging blocked commands, rshell script performance, and cross-service latency breakdown without log-mining.
Depends on
jules.macret/Q/lightweight-tracer-improvements)Describe how you validated your changes
dda inv test --targets=./pkg/privateactionrunner/...)action.runspan withservice: private-action-runnerand rshell child spans withservice: rshellAdditional notes
Blocked by the two dependencies above. Merge base first, then this PR.