in pkg/instrumentation/defaultinstrumentation.go [53:139]
func getDefaultInstrumentation(agentConfig *adapters.CwaConfig, additionalEnvs map[Type]map[string]string, isWindowsPod bool) (*v1alpha1.Instrumentation, error) {
javaInstrumentationImage, ok := os.LookupEnv("AUTO_INSTRUMENTATION_JAVA")
if !ok {
return nil, errors.New("unable to determine java instrumentation image")
}
pythonInstrumentationImage, ok := os.LookupEnv("AUTO_INSTRUMENTATION_PYTHON")
if !ok {
return nil, errors.New("unable to determine python instrumentation image")
}
dotNetInstrumentationImage, ok := os.LookupEnv("AUTO_INSTRUMENTATION_DOTNET")
if !ok {
return nil, errors.New("unable to determine dotnet instrumentation image")
}
nodeJSInstrumentationImage, ok := os.LookupEnv("AUTO_INSTRUMENTATION_NODEJS")
if !ok {
return nil, errors.New("unable to determine nodejs instrumentation image")
}
cloudwatchAgentServiceEndpoint := "cloudwatch-agent.amazon-cloudwatch"
if isWindowsPod {
// Windows pods use the headless service endpoint due to limitations with the agent on host network mode
// https://kubernetes.io/docs/concepts/services-networking/windows-networking/#limitations
cloudwatchAgentServiceEndpoint = "cloudwatch-agent-windows-headless.amazon-cloudwatch.svc.cluster.local"
}
// set protocol by checking cloudwatch agent config for tls setting
exporterPrefix := http
isApplicationSignalsEnabled := agentConfig != nil && agentConfig.GetApplicationSignalsMetricsConfig() != nil
if isApplicationSignalsEnabled {
if agentConfig.GetApplicationSignalsMetricsConfig().TLS != nil {
exporterPrefix = https
}
}
return &v1alpha1.Instrumentation{
Status: v1alpha1.InstrumentationStatus{},
TypeMeta: metav1.TypeMeta{
APIVersion: defaultAPIVersion,
Kind: defaultKind,
},
ObjectMeta: metav1.ObjectMeta{
Name: defaultInstrumentation,
Namespace: defaultNamespace,
},
Spec: v1alpha1.InstrumentationSpec{
Propagators: []v1alpha1.Propagator{
v1alpha1.TraceContext,
v1alpha1.Baggage,
v1alpha1.B3,
v1alpha1.XRay,
},
Java: v1alpha1.Java{
Image: javaInstrumentationImage,
Env: getJavaEnvs(isApplicationSignalsEnabled, cloudwatchAgentServiceEndpoint, exporterPrefix, additionalEnvs[TypeJava]),
Resources: corev1.ResourceRequirements{
Limits: getInstrumentationConfigForResource(java, limit),
Requests: getInstrumentationConfigForResource(java, request),
},
},
Python: v1alpha1.Python{
Image: pythonInstrumentationImage,
Env: getPythonEnvs(isApplicationSignalsEnabled, cloudwatchAgentServiceEndpoint, exporterPrefix, additionalEnvs[TypePython]),
Resources: corev1.ResourceRequirements{
Limits: getInstrumentationConfigForResource(python, limit),
Requests: getInstrumentationConfigForResource(python, request),
},
},
DotNet: v1alpha1.DotNet{
Image: dotNetInstrumentationImage,
Env: getDotNetEnvs(isApplicationSignalsEnabled, cloudwatchAgentServiceEndpoint, exporterPrefix, additionalEnvs[TypeDotNet]),
Resources: corev1.ResourceRequirements{
Limits: getInstrumentationConfigForResource(dotNet, limit),
Requests: getInstrumentationConfigForResource(dotNet, request),
},
},
NodeJS: v1alpha1.NodeJS{
Image: nodeJSInstrumentationImage,
Env: getNodeJSEnvs(isApplicationSignalsEnabled, cloudwatchAgentServiceEndpoint, exporterPrefix, additionalEnvs[TypeDotNet]),
Resources: corev1.ResourceRequirements{
Limits: getInstrumentationConfigForResource(nodeJS, limit),
Requests: getInstrumentationConfigForResource(nodeJS, request),
},
},
},
}, nil
}