[SVLS-9526] Prototype: serverless-init inventory payload + 9-platform POC deploy scripts - #54918
[SVLS-9526] Prototype: serverless-init inventory payload + 9-platform POC deploy scripts#54918nina9753 wants to merge 5 commits into
Conversation
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>
|
@codex review |
There was a problem hiding this comment.
💡 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".
| config.BindEnvAndSetDefault("inventories_enabled", true) | ||
| config.BindEnvAndSetDefault("inventories_first_run_delay", 60) | ||
| config.BindEnvAndSetDefault("inventories_min_interval", 0) | ||
| config.BindEnvAndSetDefault("inventories_max_interval", 0) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 👍 / 👎.
| dogstatsd.Bundle(dogstatsdServer.Params{Serverless: true}), | ||
| secretsfx.Module(), | ||
| fx.Supply(logdef.ForOneShot(modeConf.LoggerName, "error", true)), | ||
| fx.Supply(logdef.ForOneShot(modeConf.LoggerName, "trace", true)), |
There was a problem hiding this comment.
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 👍 / 👎.
Go Package Import DifferencesBaseline: d1520bc
|
…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
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)
svls-9526/force-collectForceCollect()— send inventory payload on every cold startsvls-9526/diagnostic-v2inventories_first_run_delayconfig key + diagnostic enhancementssvls-9526/serverless-agent-tablecmd/serverless-init/inventory:serverless_*fields in inventoryagent payloadWhat's in this PR
Agent changes (will land via the stacked PRs above):
ForceCollect()added toinventoryagent.Component— fires beforemodeConf.Runner()so the inventory payload is sent before the container can scale to zeroinventories_first_run_delayconfig key to control startup delaycmd/serverless-init/inventorypackage: populatesserverless_*fields (cloud provider, workload type, origin, resource name, deployment model, runtime, agent commit, DD config) into the inventoryagent payloadDD_SERVERLESS_DIAGNOSTIC_INFO=true) including UUID, CCRID, and inventory pipeline configPOC deploy scripts (
scripts/serverless-deploy/, not intended to merge to main):demo.sh— one-command end-to-end runner: build → deploy all 9 → trigger cold starts → collect logs → print REDAPL SQL queryHow to run the POC
###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.shThen paste the generated SQL into go/redapl → Queries → SQL to see the agents in
datadog_agent.Key findings from 9-platform testing
datadog_agentrowsForceCollect()required — container scales to zero before 60s delayThis motivates
serverless_init_agent(SVLS-9604): a separate REDAPL table keyed byresource_id(CCRID) instead of Agent UUID.Not in scope for merge
scripts/serverless-deploy/— test infrastructure only, not shipped in the agentscripts/serverless-deploy/diagnostic-results-*.txt— personal test output