Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/appsec/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

func init() {
registerSCAAppConfigTelemetry()
registerAgenticOnboardingTelemetry()
}

// Register the global app telemetry configuration related to the Software Composition Analysis (SCA) product.
Expand All @@ -32,12 +33,21 @@ func registerSCAAppConfigTelemetry() {
}
}

// registerAgenticOnboardingTelemetry reports [EnvAgenticOnboarding] verbatim in configuration
// telemetry (RFC-1113), always emitted: unset reports an empty value with origin=default.
Comment thread
christophe-papazian marked this conversation as resolved.
func registerAgenticOnboardingTelemetry() {
stableconfig.String(EnvAgenticOnboarding, "")
}

// The following environment variables dictate the enablement of different the ASM products.
const (
// EnvEnabled controls ASM Threats Protection's enablement.
EnvEnabled = "DD_APPSEC_ENABLED"
// EnvSCAEnabled controls ASM Software Composition Analysis (SCA)'s enablement.
EnvSCAEnabled = "DD_APPSEC_SCA_ENABLED"
// EnvAgenticOnboarding is set by Datadog's agentic onboarding solution when it configures App &
// API Protection. It carries no behavior; its value is reported in configuration telemetry only.
EnvAgenticOnboarding = "DD_APPSEC_AGENTIC_ONBOARDING"
)

// StartOption is used to customize the AppSec configuration when invoked with appsec.Start()
Expand Down
48 changes: 48 additions & 0 deletions internal/appsec/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,54 @@ import (
"github.com/DataDog/dd-trace-go/v2/internal/telemetry/telemetrytest"
)

func TestAgenticOnboarding(t *testing.T) {
name := telemetry.EnvToTelemetryName(EnvAgenticOnboarding)
for _, tc := range []struct {
name string
envVarVal string
set bool
expectedValue string
expectedOrigin telemetry.Origin
}{
{
name: "set-true",
envVarVal: "true",
set: true,
expectedValue: "true",
expectedOrigin: telemetry.OriginEnvVar,
},
{
name: "set-arbitrary",
envVarVal: "false",
set: true,
expectedValue: "false",
expectedOrigin: telemetry.OriginEnvVar,
},
{
name: "unset",
expectedValue: "",
expectedOrigin: telemetry.OriginDefault,
},
} {
t.Run(tc.name, func(t *testing.T) {
if tc.set {
t.Setenv(EnvAgenticOnboarding, tc.envVarVal)
}

expected := []telemetry.Configuration{{Name: name, Value: tc.expectedValue, Origin: tc.expectedOrigin}}
telemetryClient := new(telemetrytest.MockClient)
telemetryClient.On("RegisterAppConfigs", expected).Return()
defer telemetry.MockClient(telemetryClient)()

registerAgenticOnboardingTelemetry()

// Always emitted, even when unset (RFC-1113).
telemetryClient.AssertCalled(t, "RegisterAppConfigs", expected)
telemetryClient.AssertNumberOfCalls(t, "RegisterAppConfigs", 1)
})
}
}

func TestSCAEnabled(t *testing.T) {
for _, tc := range []struct {
name string
Expand Down
1 change: 1 addition & 0 deletions internal/env/supported_configurations.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions internal/env/supported_configurations.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@
"default": "true"
}
],
"DD_APPSEC_AGENTIC_ONBOARDING": [
{
"implementation": "A",
"type": "string",
"default": ""
}
],
"DD_APPSEC_BODY_PARSING_SIZE_LIMIT": [
{
"implementation": "B",
Expand Down
Loading