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

Add APM Single Step Instrumentation #981

Closed
wants to merge 11 commits into from
4 changes: 4 additions & 0 deletions apis/datadoghq/common/envvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ const (
DDAPMNonLocalTraffic = "DD_APM_NON_LOCAL_TRAFFIC"
DDAPMReceiverPort = "DD_APM_RECEIVER_PORT"
DDAPMReceiverSocket = "DD_APM_RECEIVER_SOCKET"
DDAPMInstrumentationEnabled = "DD_APM_INSTRUMENTATION_ENABLED"
DDAPMInstrumentationEnabledNamespaces = "DD_APM_INSTRUMENTATION_ENABLED_NAMESPACES"
DDAPMInstrumentationDisabledNamespaces = "DD_APM_INSTRUMENTATION_DISABLED_NAMESPACES"
DDAPMInstrumentationLibVersions = "DD_APM_INSTRUMENTATION_LIB_VERSIONS"
DDAppKey = "DD_APP_KEY"
DDAuthTokenFilePath = "DD_AUTH_TOKEN_FILE_PATH"
DDClcRunnerEnabled = "DD_CLC_RUNNER_ENABLED"
Expand Down
11 changes: 9 additions & 2 deletions apis/datadoghq/v2alpha1/datadogagent_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const (
// defaultOOMKillEnabled bool = false
// defaultTCPQueueLengthEnabled bool = false

// defaultAPMEnabled bool = false
defaultAPMEnabled bool = true
defaultAPMHostPortEnabled bool = false
defaultAPMHostPort int32 = 8126
defaultAPMSocketEnabled bool = true
Expand Down Expand Up @@ -163,7 +163,14 @@ func defaultFeaturesConfig(ddaSpec *DatadogAgentSpec) {
}

// APM Feature
if ddaSpec.Features.APM != nil && ddaSpec.Features.APM.Enabled != nil && *ddaSpec.Features.APM.Enabled {
// APM is enabled by default
if ddaSpec.Features.APM == nil {
ddaSpec.Features.APM = &APMFeatureConfig{}
}

apiutils.DefaultBooleanIfUnset(&ddaSpec.Features.APM.Enabled, defaultAPMEnabled)

if *ddaSpec.Features.APM.Enabled {
if ddaSpec.Features.APM.HostPortConfig == nil {
ddaSpec.Features.APM.HostPortConfig = &HostPortConfig{}
}
Expand Down
115 changes: 112 additions & 3 deletions apis/datadoghq/v2alpha1/datadogagent_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ func Test_defaultFeatures(t *testing.T) {
Path: apiutils.NewStringPointer(defaultDogstatsdHostSocketPath),
},
},
APM: &APMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMEnabled),
HostPortConfig: &HostPortConfig{
Port: apiutils.NewInt32Pointer(defaultAPMHostPort),
Enabled: apiutils.NewBoolPointer(defaultAPMHostPortEnabled),
},
UnixDomainSocketConfig: &UnixDomainSocketConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMSocketEnabled),
Path: apiutils.NewStringPointer(defaultAPMSocketHostPath),
},
},
CharlyF marked this conversation as resolved.
Show resolved Hide resolved
OTLP: &OTLPFeatureConfig{Receiver: OTLPReceiverConfig{Protocols: OTLPProtocolsConfig{
GRPC: &OTLPGRPCConfig{
Enabled: apiutils.NewBoolPointer(defaultOTLPGRPCEnabled),
Expand Down Expand Up @@ -369,6 +380,17 @@ func Test_defaultFeatures(t *testing.T) {
MutateUnlabelled: apiutils.NewBoolPointer(defaultAdmissionControllerMutateUnlabelled),
ServiceName: apiutils.NewStringPointer(defaultAdmissionServiceName),
},
APM: &APMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMEnabled),
HostPortConfig: &HostPortConfig{
Port: apiutils.NewInt32Pointer(defaultAPMHostPort),
Enabled: apiutils.NewBoolPointer(defaultAPMHostPortEnabled),
},
UnixDomainSocketConfig: &UnixDomainSocketConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMSocketEnabled),
Path: apiutils.NewStringPointer(defaultAPMSocketHostPath),
},
},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultRemoteConfigurationEnabled),
},
Expand Down Expand Up @@ -437,6 +459,17 @@ func Test_defaultFeatures(t *testing.T) {
MutateUnlabelled: apiutils.NewBoolPointer(defaultAdmissionControllerMutateUnlabelled),
ServiceName: apiutils.NewStringPointer(defaultAdmissionServiceName),
},
APM: &APMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMEnabled),
HostPortConfig: &HostPortConfig{
Port: apiutils.NewInt32Pointer(defaultAPMHostPort),
Enabled: apiutils.NewBoolPointer(defaultAPMHostPortEnabled),
},
UnixDomainSocketConfig: &UnixDomainSocketConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMSocketEnabled),
Path: apiutils.NewStringPointer(defaultAPMSocketHostPath),
},
},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultRemoteConfigurationEnabled),
},
Expand Down Expand Up @@ -568,6 +601,17 @@ func Test_defaultFeatures(t *testing.T) {
Enabled: apiutils.NewBoolPointer(defaultClusterChecksEnabled),
UseClusterChecksRunners: apiutils.NewBoolPointer(defaultUseClusterChecksRunners),
},
APM: &APMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMEnabled),
HostPortConfig: &HostPortConfig{
Port: apiutils.NewInt32Pointer(defaultAPMHostPort),
Enabled: apiutils.NewBoolPointer(defaultAPMHostPortEnabled),
},
UnixDomainSocketConfig: &UnixDomainSocketConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMSocketEnabled),
Path: apiutils.NewStringPointer(defaultAPMSocketHostPath),
},
},
AdmissionController: &AdmissionControllerFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultAdmissionControllerEnabled),
MutateUnlabelled: apiutils.NewBoolPointer(defaultAdmissionControllerMutateUnlabelled),
Expand Down Expand Up @@ -640,6 +684,17 @@ func Test_defaultFeatures(t *testing.T) {
MutateUnlabelled: apiutils.NewBoolPointer(defaultAdmissionControllerMutateUnlabelled),
ServiceName: apiutils.NewStringPointer(defaultAdmissionServiceName),
},
APM: &APMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMEnabled),
HostPortConfig: &HostPortConfig{
Port: apiutils.NewInt32Pointer(defaultAPMHostPort),
Enabled: apiutils.NewBoolPointer(defaultAPMHostPortEnabled),
},
UnixDomainSocketConfig: &UnixDomainSocketConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMSocketEnabled),
Path: apiutils.NewStringPointer(defaultAPMSocketHostPath),
},
},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultRemoteConfigurationEnabled),
},
Expand Down Expand Up @@ -691,6 +746,17 @@ func Test_defaultFeatures(t *testing.T) {
KubeStateMetricsCore: &KubeStateMetricsCoreFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultKubeStateMetricsCoreEnabled),
},
APM: &APMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMEnabled),
HostPortConfig: &HostPortConfig{
Port: apiutils.NewInt32Pointer(defaultAPMHostPort),
Enabled: apiutils.NewBoolPointer(defaultAPMHostPortEnabled),
},
UnixDomainSocketConfig: &UnixDomainSocketConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMSocketEnabled),
Path: apiutils.NewStringPointer(defaultAPMSocketHostPath),
},
},
ExternalMetricsServer: &ExternalMetricsServerFeatureConfig{
Enabled: apiutils.NewBoolPointer(valueTrue),
RegisterAPIService: apiutils.NewBoolPointer(defaultRegisterAPIService),
Expand Down Expand Up @@ -766,6 +832,17 @@ func Test_defaultFeatures(t *testing.T) {
MutateUnlabelled: apiutils.NewBoolPointer(defaultAdmissionControllerMutateUnlabelled),
ServiceName: apiutils.NewStringPointer(defaultAdmissionServiceName),
},
APM: &APMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMEnabled),
HostPortConfig: &HostPortConfig{
Port: apiutils.NewInt32Pointer(defaultAPMHostPort),
Enabled: apiutils.NewBoolPointer(defaultAPMHostPortEnabled),
},
UnixDomainSocketConfig: &UnixDomainSocketConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMSocketEnabled),
Path: apiutils.NewStringPointer(defaultAPMSocketHostPath),
},
},
RemoteConfiguration: &RemoteConfigurationFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultRemoteConfigurationEnabled),
},
Expand All @@ -787,6 +864,17 @@ func Test_defaultFeatures(t *testing.T) {
LiveContainerCollection: &LiveContainerCollectionFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultLiveContainerCollectionEnabled),
},
APM: &APMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMEnabled),
HostPortConfig: &HostPortConfig{
Port: apiutils.NewInt32Pointer(defaultAPMHostPort),
Enabled: apiutils.NewBoolPointer(defaultAPMHostPortEnabled),
},
UnixDomainSocketConfig: &UnixDomainSocketConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMSocketEnabled),
Path: apiutils.NewStringPointer(defaultAPMSocketHostPath),
},
},
ProcessDiscovery: &ProcessDiscoveryFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultProcessDiscoveryEnabled),
},
Expand Down Expand Up @@ -872,6 +960,17 @@ func Test_defaultFeatures(t *testing.T) {
EventCollection: &EventCollectionFeatureConfig{
CollectKubernetesEvents: apiutils.NewBoolPointer(defaultCollectKubernetesEvents),
},
APM: &APMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMEnabled),
HostPortConfig: &HostPortConfig{
Port: apiutils.NewInt32Pointer(defaultAPMHostPort),
Enabled: apiutils.NewBoolPointer(defaultAPMHostPortEnabled),
},
UnixDomainSocketConfig: &UnixDomainSocketConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMSocketEnabled),
Path: apiutils.NewStringPointer(defaultAPMSocketHostPath),
},
},
OrchestratorExplorer: &OrchestratorExplorerFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultOrchestratorExplorerEnabled),
ScrubContainers: apiutils.NewBoolPointer(defaultOrchestratorExplorerScrubContainers),
Expand Down Expand Up @@ -929,9 +1028,19 @@ func Test_defaultFeatures(t *testing.T) {
ProcessDiscovery: &ProcessDiscoveryFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultProcessDiscoveryEnabled),
},
OOMKill: &OOMKillFeatureConfig{},
TCPQueueLength: &TCPQueueLengthFeatureConfig{},
APM: &APMFeatureConfig{},
OOMKill: &OOMKillFeatureConfig{},
TCPQueueLength: &TCPQueueLengthFeatureConfig{},
APM: &APMFeatureConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMEnabled),
HostPortConfig: &HostPortConfig{
Port: apiutils.NewInt32Pointer(defaultAPMHostPort),
Enabled: apiutils.NewBoolPointer(defaultAPMHostPortEnabled),
},
UnixDomainSocketConfig: &UnixDomainSocketConfig{
Enabled: apiutils.NewBoolPointer(defaultAPMSocketEnabled),
Path: apiutils.NewStringPointer(defaultAPMSocketHostPath),
},
},
CSPM: &CSPMFeatureConfig{},
CWS: &CWSFeatureConfig{},
NPM: &NPMFeatureConfig{},
Expand Down
31 changes: 31 additions & 0 deletions apis/datadoghq/v2alpha1/datadogagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,37 @@ type APMFeatureConfig struct {
// Path Default: `/var/run/datadog/apm.socket`
// +optional
UnixDomainSocketConfig *UnixDomainSocketConfig `json:"unixDomainSocketConfig,omitempty"`

// Single Step Instrumentation allows the agent to inject the Datadog APM libraries into all pods in the cluster.
// Feature is in beta.
// See also: https://docs.datadoghq.com/tracing/trace_collection/single-step-apm
// Enabled Default: false
// +optional
SingleStepInstrumentation *SingleStepInstrumentation `json:"singleStepInstrumentation,omitempty"`
}

// SingleStepInstrumentation contains the config for the namespaces to target and the library to inject.
type SingleStepInstrumentation struct {
// Enabled enables injecting the Datadog APM libraries into all pods in the cluster.
// Default: false
// +optional
Enabled *bool `json:"enabled,omitempty"`

// EnabledNamespaces specifies the namespaces of the pods to inject the Datadog APM libraries into.
// +optional
// +listType=set
EnabledNamespaces []string `json:"enabledNamespaces,omitempty"`

// DisabledNamespaces specifies the namespaces of the pods to not inject the Datadog APM libraries into.
// +optional
// +listType=set
DisabledNamespaces []string `json:"disabledNamespaces,omitempty"`

// Inject specific version of tracing libraries with Single Step Instrumentation
// <Library>: <Version>
// ex: "java": "v1.18.0"
// +optional
LibVersions map[string]string `json:"libVersions,omitempty"`
}

// LogCollectionFeatureConfig contains Logs configuration.
Expand Down
42 changes: 42 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.

24 changes: 24 additions & 0 deletions config/crd/bases/v1/datadoghq.com_datadogagents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7839,6 +7839,30 @@ spec:
format: int32
type: integer
type: object
singleStepInstrumentation:
description: 'Single Step Instrumentation allows the agent to inject the Datadog APM libraries into all pods in the cluster. Feature is in beta. See also: https://docs.datadoghq.com/tracing/trace_collection/single-step-apm Enabled Default: false'
properties:
disabledNamespaces:
description: DisabledNamespaces specifies the namespaces of the pods to not inject the Datadog APM libraries into.
items:
type: string
type: array
x-kubernetes-list-type: set
enabled:
description: 'Enabled enables injecting the Datadog APM libraries into all pods in the cluster. Default: false'
type: boolean
enabledNamespaces:
description: EnabledNamespaces specifies the namespaces of the pods to inject the Datadog APM libraries into.
items:
type: string
type: array
x-kubernetes-list-type: set
libVersions:
additionalProperties:
type: string
description: 'Inject specific version of tracing libraries with Single Step Instrumentation <Library>: <Version> ex: "java": "v1.18.0"'
type: object
type: object
unixDomainSocketConfig:
description: 'UnixDomainSocketConfig contains socket configuration. See also: https://docs.datadoghq.com/agent/kubernetes/apm/?tab=helm#agent-environment-variables Enabled Default: true Path Default: `/var/run/datadog/apm.socket`'
properties:
Expand Down
24 changes: 24 additions & 0 deletions config/crd/bases/v1beta1/datadoghq.com_datadogagents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15389,6 +15389,30 @@ spec:
format: int32
type: integer
type: object
singleStepInstrumentation:
description: 'Single Step Instrumentation allows the agent to inject the Datadog APM libraries into all pods in the cluster. Feature is in beta. See also: https://docs.datadoghq.com/tracing/trace_collection/single-step-apm Enabled Default: false'
properties:
disabledNamespaces:
description: DisabledNamespaces specifies the namespaces of the pods to not inject the Datadog APM libraries into.
items:
type: string
type: array
x-kubernetes-list-type: set
enabled:
description: 'Enabled enables injecting the Datadog APM libraries into all pods in the cluster. Default: false'
type: boolean
enabledNamespaces:
description: EnabledNamespaces specifies the namespaces of the pods to inject the Datadog APM libraries into.
items:
type: string
type: array
x-kubernetes-list-type: set
libVersions:
additionalProperties:
type: string
description: 'Inject specific version of tracing libraries with Single Step Instrumentation <Library>: <Version> ex: "java": "v1.18.0"'
type: object
type: object
unixDomainSocketConfig:
description: 'UnixDomainSocketConfig contains socket configuration. See also: https://docs.datadoghq.com/agent/kubernetes/apm/?tab=helm#agent-environment-variables Enabled Default: true Path Default: `/var/run/datadog/apm.socket`'
properties:
Expand Down
Loading