Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PROF-10073: Add suport for feature.profiling #1271

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions apis/datadoghq/common/envvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
DDAdmissionControllerAppsecEnabled = "DD_ADMISSION_CONTROLLER_AUTO_INSTRUMENTATION_APPSEC_ENABLED"
DDAdmissionControllerAppsecSCAEnabled = "DD_ADMISSION_CONTROLLER_AUTO_INSTRUMENTATION_APPSEC_SCA_ENABLED"
DDAdmissionControllerIASTEnabled = "DD_ADMISSION_CONTROLLER_AUTO_INSTRUMENTATION_IAST_ENABLED"
DDAdmissionControllerProfilingEnabled = "DD_ADMISSION_CONTROLLER_AUTO_INSTRUMENTATION_PROFILING_ENABLED"
DDAPIKey = "DD_API_KEY"
DDAPMEnabled = "DD_APM_ENABLED"
DDAPMInstrumentationInstallTime = "DD_INSTRUMENTATION_INSTALL_TIME"
Expand Down
8 changes: 8 additions & 0 deletions apis/datadoghq/v2alpha1/datadogagent_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ const (
defaultAdmissionASMSCAEnabled bool = false
defaultAdmissionASMIASTEnabled bool = false

defaultAdmissionProfilingEnabled string = ""

defaultOrchestratorExplorerEnabled bool = true
defaultOrchestratorExplorerScrubContainers bool = true

Expand Down Expand Up @@ -298,6 +300,12 @@ func defaultFeaturesConfig(ddaSpec *DatadogAgentSpec) {
}
apiutils.DefaultBooleanIfUnset(&ddaSpec.Features.ASM.IAST.Enabled, defaultAdmissionASMIASTEnabled)

// Profiling Feature
if ddaSpec.Features.Profiling == nil {
ddaSpec.Features.Profiling = &ProfilingFeatureConfig{}
}
apiutils.DefaultStringIfUnset(&ddaSpec.Features.Profiling.Enabled, defaultAdmissionProfilingEnabled)

// CSPM (Cloud Security Posture Management) Feature
if ddaSpec.Features.CSPM == nil {
ddaSpec.Features.CSPM = &CSPMFeatureConfig{}
Expand Down
42 changes: 42 additions & 0 deletions apis/datadoghq/v2alpha1/datadogagent_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ func Test_defaultFeatures(t *testing.T) {
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMIASTEnabled),
},
},
Profiling: &ProfilingFeatureConfig{
Enabled: apiutils.NewStringPointer(defaultAdmissionProfilingEnabled),
},
CSPM: &CSPMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultCSPMEnabled),
},
Expand Down Expand Up @@ -313,6 +316,9 @@ func Test_defaultFeatures(t *testing.T) {
Enabled: apiutils.NewBoolPointer(valueFalse),
},
},
Profiling: &ProfilingFeatureConfig{
Enabled: apiutils.NewStringPointer(defaultAdmissionProfilingEnabled),
},
CSPM: &CSPMFeatureConfig{
Enabled: apiutils.NewBoolPointer(valueFalse),
},
Expand Down Expand Up @@ -395,6 +401,9 @@ func Test_defaultFeatures(t *testing.T) {
Enabled: apiutils.NewBoolPointer(valueFalse),
},
},
Profiling: &ProfilingFeatureConfig{
Enabled: apiutils.NewStringPointer(defaultAdmissionProfilingEnabled),
},
CSPM: &CSPMFeatureConfig{
Enabled: apiutils.NewBoolPointer(valueFalse),
},
Expand Down Expand Up @@ -516,6 +525,9 @@ func Test_defaultFeatures(t *testing.T) {
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMIASTEnabled),
},
},
Profiling: &ProfilingFeatureConfig{
Enabled: apiutils.NewStringPointer(defaultAdmissionProfilingEnabled),
},
CSPM: &CSPMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultCSPMEnabled),
},
Expand Down Expand Up @@ -646,6 +658,9 @@ func Test_defaultFeatures(t *testing.T) {
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMIASTEnabled),
},
},
Profiling: &ProfilingFeatureConfig{
Enabled: apiutils.NewStringPointer(defaultAdmissionProfilingEnabled),
},
CSPM: &CSPMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultCSPMEnabled),
},
Expand Down Expand Up @@ -771,6 +786,9 @@ func Test_defaultFeatures(t *testing.T) {
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMIASTEnabled),
},
},
Profiling: &ProfilingFeatureConfig{
Enabled: apiutils.NewStringPointer(defaultAdmissionProfilingEnabled),
},
CSPM: &CSPMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultCSPMEnabled),
},
Expand Down Expand Up @@ -896,6 +914,9 @@ func Test_defaultFeatures(t *testing.T) {
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMIASTEnabled),
},
},
Profiling: &ProfilingFeatureConfig{
Enabled: apiutils.NewStringPointer(defaultAdmissionProfilingEnabled),
},
CSPM: &CSPMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultCSPMEnabled),
},
Expand Down Expand Up @@ -1030,6 +1051,9 @@ func Test_defaultFeatures(t *testing.T) {
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMIASTEnabled),
},
},
Profiling: &ProfilingFeatureConfig{
Enabled: apiutils.NewStringPointer(defaultAdmissionProfilingEnabled),
},
CSPM: &CSPMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultCSPMEnabled),
},
Expand Down Expand Up @@ -1155,6 +1179,9 @@ func Test_defaultFeatures(t *testing.T) {
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMIASTEnabled),
},
},
Profiling: &ProfilingFeatureConfig{
Enabled: apiutils.NewStringPointer(defaultAdmissionProfilingEnabled),
},
CSPM: &CSPMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultCSPMEnabled),
},
Expand Down Expand Up @@ -1283,6 +1310,9 @@ func Test_defaultFeatures(t *testing.T) {
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMIASTEnabled),
},
},
Profiling: &ProfilingFeatureConfig{
Enabled: apiutils.NewStringPointer(defaultAdmissionProfilingEnabled),
},
CSPM: &CSPMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultCSPMEnabled),
},
Expand Down Expand Up @@ -1400,6 +1430,9 @@ func Test_defaultFeatures(t *testing.T) {
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMIASTEnabled),
},
},
Profiling: &ProfilingFeatureConfig{
Enabled: apiutils.NewStringPointer(defaultAdmissionProfilingEnabled),
},
ProcessDiscovery: &ProcessDiscoveryFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultProcessDiscoveryEnabled),
},
Expand Down Expand Up @@ -1539,6 +1572,9 @@ func Test_defaultFeatures(t *testing.T) {
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMIASTEnabled),
},
},
Profiling: &ProfilingFeatureConfig{
Enabled: apiutils.NewStringPointer(defaultAdmissionProfilingEnabled),
},
CSPM: &CSPMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultCSPMEnabled),
},
Expand Down Expand Up @@ -1686,6 +1722,9 @@ func Test_defaultFeatures(t *testing.T) {
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMIASTEnabled),
},
},
Profiling: &ProfilingFeatureConfig{
Enabled: apiutils.NewStringPointer(defaultAdmissionProfilingEnabled),
},
CSPM: &CSPMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultCSPMEnabled),
},
Expand Down Expand Up @@ -1814,6 +1853,9 @@ func Test_defaultFeatures(t *testing.T) {
Enabled: apiutils.NewBoolPointer(defaultAdmissionASMIASTEnabled),
},
},
Profiling: &ProfilingFeatureConfig{
Enabled: apiutils.NewStringPointer(defaultAdmissionProfilingEnabled),
},
CSPM: &CSPMFeatureConfig{
Enabled: apiutils.NewBoolPointer(valueTrue),
HostBenchmarks: &CSPMHostBenchmarksConfig{
Expand Down
13 changes: 13 additions & 0 deletions apis/datadoghq/v2alpha1/datadogagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ type DatadogFeatures struct {
APM *APMFeatureConfig `json:"apm,omitempty"`
// ASM (Application Security Management) configuration.
ASM *ASMFeatureConfig `json:"asm,omitempty"`
// Continuous Profiler configuration.
Profiling *ProfilingFeatureConfig `json:"profiling,omitempty"`
// CSPM (Cloud Security Posture Management) configuration.
CSPM *CSPMFeatureConfig `json:"cspm,omitempty"`
// CWS (Cloud Workload Security) configuration.
Expand Down Expand Up @@ -212,6 +214,17 @@ type ASMIASTConfig struct {
Enabled *bool `json:"enabled,omitempty"`
}

// ProfilingFeatureConfig contains Continuous Profiler configuration.
// Note that this will only affect pods where the Datadog client libraries are installed or APM Single Step Instrumentation is enabled.
type ProfilingFeatureConfig struct {
// Enabled enables Continuous Profiler.
// Default: ""
// Valid values: "", "true", "false", "auto"
szegedi marked this conversation as resolved.
Show resolved Hide resolved
// +kubebuilder:validation:Enum:=true;false;auto
// +optional
Enabled *string `json:"enabled,omitempty"`
}

// LogCollectionFeatureConfig contains Logs configuration.
// Logs collection is run in the Agent.
type LogCollectionFeatureConfig struct {
Expand Down
7 changes: 7 additions & 0 deletions apis/datadoghq/v2alpha1/test/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,13 @@ func (builder *DatadogAgentBuilder) WithASMEnabled(threats, sca, iast bool) *Dat
return builder
}

func (builder *DatadogAgentBuilder) WithProfilingEnabled(enabled string) *DatadogAgentBuilder {
builder.datadogAgent.Spec.Features.Profiling = &v2alpha1.ProfilingFeatureConfig{
Enabled: apiutils.NewStringPointer(enabled),
}
return builder
}

// OTLP

func (builder *DatadogAgentBuilder) initOTLP() {
Expand Down
25 changes: 25 additions & 0 deletions apis/datadoghq/v2alpha1/zz_generated.deepcopy.go

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

8 changes: 7 additions & 1 deletion apis/datadoghq/v2alpha1/zz_generated.openapi.go

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

28 changes: 28 additions & 0 deletions config/crd/bases/v1/datadoghq.com_datadogagents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,20 @@ spec:
Default: true
type: boolean
type: object
profiling:
description: Continuous Profiler configuration.
properties:
enabled:
description: |-
Enabled enables Continuous Profiler.
Default: ""
Valid values: "", "true", "false", "auto"
enum:
- true
- false
- auto
type: string
type: object
prometheusScrape:
description: PrometheusScrape configuration.
properties:
Expand Down Expand Up @@ -7157,6 +7171,20 @@ spec:
Default: true
type: boolean
type: object
profiling:
description: Continuous Profiler configuration.
properties:
enabled:
description: |-
Enabled enables Continuous Profiler.
Default: ""
Valid values: "", "true", "false", "auto"
enum:
- true
- false
- auto
type: string
type: object
prometheusScrape:
description: PrometheusScrape configuration.
properties:
Expand Down
9 changes: 9 additions & 0 deletions config/crd/bases/v1beta1/datadoghq.com_datadogagents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,15 @@ spec:
description: 'Enabled enables the Process Discovery check in the Agent. Default: true'
type: boolean
type: object
profiling:
description: Profiling configuration.
properties:
enabled:
description: |-
Enabled enables Profiling.
Default: ""
type: string
type: object
prometheusScrape:
description: PrometheusScrape configuration.
properties:
Expand Down
1 change: 1 addition & 0 deletions controllers/datadogagent/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
_ "github.com/DataDog/datadog-operator/controllers/datadogagent/feature/orchestratorexplorer"
_ "github.com/DataDog/datadog-operator/controllers/datadogagent/feature/otlp"
_ "github.com/DataDog/datadog-operator/controllers/datadogagent/feature/processdiscovery"
_ "github.com/DataDog/datadog-operator/controllers/datadogagent/feature/profiling"
_ "github.com/DataDog/datadog-operator/controllers/datadogagent/feature/prometheusscrape"
_ "github.com/DataDog/datadog-operator/controllers/datadogagent/feature/remoteconfig"
_ "github.com/DataDog/datadog-operator/controllers/datadogagent/feature/sbom"
Expand Down
2 changes: 2 additions & 0 deletions controllers/datadogagent/feature/ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const (
APMIDType = "apm"
// ASMIDType ASM feature
ASMIDType = "asm"
// ProfilingIDType Profiling feature
ProfilingIDType = "profiling"
// AdmissionControllerIDType Admission controller feature
AdmissionControllerIDType = "admission_controller"
// OTLPIDType OTLP ingest feature
Expand Down
Loading
Loading