Skip to content

[SVLS-9526] Prototype: serverless-init inventory payload + 9-platform POC deploy scripts - #54918

Draft
nina9753 wants to merge 5 commits into
mainfrom
svls-9526/prototype
Draft

[SVLS-9526] Prototype: serverless-init inventory payload + 9-platform POC deploy scripts#54918
nina9753 wants to merge 5 commits into
mainfrom
svls-9526/prototype

Conversation

@nina9753

@nina9753 nina9753 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

What this is

A prototype branch containing the full stack of changes for SVLS-9526 in a single PR. Intended for review and discussion — these changes will be broken into the stacked PRs below before merge.

Stacked PRs (final form)

PR Branch Contents
#54537 svls-9526/force-collect ForceCollect() — send inventory payload on every cold start
#54538 svls-9526/diagnostic-v2 inventories_first_run_delay config key + diagnostic enhancements
#54543 svls-9526/serverless-agent-table cmd/serverless-init/inventory: serverless_* fields in inventoryagent payload

What's in this PR

Agent changes (will land via the stacked PRs above):

  • ForceCollect() added to inventoryagent.Component — fires before modeConf.Runner() so the inventory payload is sent before the container can scale to zero
  • inventories_first_run_delay config key to control startup delay
  • New cmd/serverless-init/inventory package: populates serverless_* fields (cloud provider, workload type, origin, resource name, deployment model, runtime, agent commit, DD config) into the inventoryagent payload
  • Enhanced startup diagnostics (DD_SERVERLESS_DIAGNOSTIC_INFO=true) including UUID, CCRID, and inventory pipeline config

POC deploy scripts (scripts/serverless-deploy/, not intended to merge to main):

  • Deploys 9 test services across GCP (Cloud Run Service/Job/Function) and Azure (Container App, Web App Containers, Web App SITECONTAINERS, Web App Linux Code)
  • demo.sh — one-command end-to-end runner: build → deploy all 9 → trigger cold starts → collect logs → print REDAPL SQL query

How to run the POC

export GCP_PROJECT=datadog-serverless-gcp-demo
export AZURE_SUBSCRIPTION_ID=<sub-id>
export DD_API_KEY=$(vault kv get -field=api_key kv/dd/api_keys/dddev)
export IMAGE_TAG=1.10.2-poc-$(date +%Y%m%d)

cd scripts/serverless-deploy
./demo.sh

###dd-auth command equivalent:

export DD_API_KEY=$(dd-auth vault kv get -field=api_key kv/dd/api_keys/dddev)

Or if it's wrapping the whole script:

dd-auth ./demo.sh

Then paste the generated SQL into go/redapl → Queries → SQL to see the agents in datadog_agent.

Key findings from 9-platform testing

Platform UUID behaviour datadog_agent rows
GCP Cloud Run New UUID per cold start ForceCollect() required — container scales to zero before 60s delay
Azure Container App Stable UUID per replica Upserts same row reliably
Azure Web App DMI UUID from underlying VM Apps on same App Service Plan share UUID → need CCRID-based PK

This motivates serverless_init_agent (SVLS-9604): a separate REDAPL table keyed by resource_id (CCRID) instead of Agent UUID.

Not in scope for merge

  • scripts/serverless-deploy/ — test infrastructure only, not shipped in the agent
  • scripts/serverless-deploy/diagnostic-results-*.txt — personal test output

nina9753 and others added 4 commits August 14, 2026 12:34
Adds a new cmd/serverless-init/diagnostic package that logs env vars,
agent config fields, and mode/origin detection when
DD_SERVERLESS_DIAGNOSTIC_INFO=true is set.

Gated by env var so it is safe to include in all builds — output only
appears when explicitly opted in. Secrets (API_KEY, TOKEN, SECRET,
PASSWORD) are masked before logging.

Used for investigating what platform identifiers are available across
Cloud Run, Azure Container Apps, and App Service workloads.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…estigation

Adds scripts/serverless-deploy/ containing:
- deploy.sh: deploys test services to all 5 serverless platforms
  (GCP Cloud Run Service, Cloud Run Job, Cloud Run Function v2,
   Azure Container App, Azure Web App) with DD_SERVERLESS_DIAGNOSTIC_INFO=true
- build-image.sh: builds custom serverless-init image from branch source
  and pushes to GCR Artifact Registry
- check-logs.sh: queries GCP Cloud Logging + Azure log streams for
  [SERVERLESS_DIAGNOSTIC] output to capture per-platform env var data
- app/: Python Flask test app with ddtrace auto-instrumentation
  (logs, traces, serverless.test.request_count metric)
- app/function/: Cloud Run Functions v2 handler
- .env.example: pre-filled with GCP_PROJECT + AZURE_SUBSCRIPTION_ID

Used for SVLS-9526/9527/9528 investigation: what identifiers and env
vars are available to serverless-init across each cloud workload type.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ics for fleet visibility

Combines all proposed PR changes onto the deploy-scripts test branch so the
Docker image can be rebuilt with the full stack:

- comp/metadata/inventoryagent: add ForceCollect() to interface + mock
- comp/metadata/internal/util/inventory_payload: implement ForceCollect()
  (bypasses first-run delay, safe to call concurrently with periodic runner)
- pkg/config/setup: add inventories_first_run_delay config key
- cmd/serverless-init/inventory: new package — SetInventoryFields() populates
  serverless_* fields (cloud_provider, workload_type, origin, deployment_model,
  resource_name, runtime, dd_env/service/version, subscription_id, etc.)
  that feed the serverless_init_agent REDAPL table via EPRW decoder (SVLS-9607)
- cmd/serverless-init/main: call SetInventoryFields + ForceCollect before runner
- cmd/serverless-init/diagnostic: v2 — surfaces ForceCollect result, uuid,
  inventory pipeline config, ccrid, deployment_model, wrapped_command, version
- cmd/serverless-init/mode: add DeploymentModel + WrappedCommand to Conf
- scripts/serverless-deploy: 9-platform scripts, trigger_all(), updated Dockerfiles

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

@codex review

@dd-octo-sts dd-octo-sts Bot added internal Identify a non-fork PR team/fleet-automation labels Aug 14, 2026
@github-actions github-actions Bot added the long review PR is complex, plan time to review it label Aug 14, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e1aa87753b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +1636 to +1639
config.BindEnvAndSetDefault("inventories_enabled", true)
config.BindEnvAndSetDefault("inventories_first_run_delay", 60)
config.BindEnvAndSetDefault("inventories_min_interval", 0)
config.BindEnvAndSetDefault("inventories_max_interval", 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Register inventory settings in the schema

Move these registrations into the configuration schema by making the inventory settings available to serverless builds. initCommonBase is generated from core_schema.yaml, where these keys remain tagged full-agent-only:true; this new serverless() helper has no call site, and common_settings.go is also absent from the setup Bazel target. Consequently inventories_enabled is false/unknown in the serverless configuration, so InventoryEnabled disables the component and ForceCollect sends nothing.

Useful? React with 👍 / 👎.

// shutdown drain (forwarder_stop_timeout) then delivers it. Without this
// call, the first periodic inventory fires only after firstRunDelay +
// MinInterval (~60 s), which is longer than most scale-to-zero windows.
if err := inventoryAgentComp.ForceCollect(); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Populate serverless fields before collecting

Call inventory.SetInventoryFields before this collection. A repository-wide search finds only its definition and tests, so the component is force-collected with standard agent metadata only; none of the newly introduced serverless_* fields are ever added, defeating the new serverless_init_agent payload behavior on every platform.

Useful? React with 👍 / 👎.

Comment thread cmd/serverless-init/main.go Outdated
dogstatsd.Bundle(dogstatsdServer.Params{Serverless: true}),
secretsfx.Module(),
fx.Supply(logdef.ForOneShot(modeConf.LoggerName, "error", true)),
fx.Supply(logdef.ForOneShot(modeConf.LoggerName, "trace", true)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore the non-trace default log level

When DD_LOG_LEVEL is unset, ForOneShot uses this literal fallback, so every serverless-init deployment now enables all debug and trace logging rather than the previous error-only output. Long-running sidecars and busy telemetry paths will continuously emit normally filtered messages, increasing CPU and cloud-log volume even when diagnostic mode is disabled; keep the normal default and let explicit diagnostic/debug configuration opt into verbose logging. codereview_guideline.mdL75-L79

Useful? React with 👍 / 👎.

@dd-octo-sts

dd-octo-sts Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Go Package Import Differences

Baseline: d1520bc
Comparison: 21599d5

binaryosarchchange
dogstatsdlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
dogstatsdlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
process-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
process-agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
process-agentwindowsamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
process-agentdarwinamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
process-agentdarwinarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
heroku-process-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
security-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
security-agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
security-agentwindowsamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
sbomgenlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
sbomgenlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
system-probelinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
system-probelinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
system-probewindowsamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
system-probedarwinamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
system-probedarwinarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
trace-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
trace-agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
trace-agentwindowsamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
trace-agentdarwinamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
trace-agentdarwinarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
trace-agentaixppc64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
heroku-trace-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
otel-agentlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
otel-agentlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
host-profilerlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
host-profilerlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
loaderlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
loaderlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
loaderdarwinamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
loaderdarwinarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
installerlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
installerlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
installerwindowsamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
privateactionrunnerlinuxamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
privateactionrunnerlinuxarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
privateactionrunnerwindowsamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
privateactionrunnerdarwinamd64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults
privateactionrunnerdarwinarm64
+1, -0
+github.com/DataDog/datadog-agent/pkg/collector/check/defaults

…e ForceCollect

- Revert log level from "trace" back to "error" to avoid flooding logs when
  DD_LOG_LEVEL is unset; diagnostic/debug verbosity should require explicit opt-in
- Call inventory.SetInventoryFields before ForceCollect so all serverless_*
  fields (cloud provider, workload type, resource name, etc.) are present in
  the first payload sent per container lifecycle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Identify a non-fork PR long review PR is complex, plan time to review it team/fleet-automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant