Skip to content

Adding integration test for nodejs instrumentation (#191) #210

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

Closed
wants to merge 8 commits into from
Closed
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 Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ARG VERSION_DATE
ARG AGENT_VERSION
ARG AUTO_INSTRUMENTATION_JAVA_VERSION
ARG AUTO_INSTRUMENTATION_PYTHON_VERSION
ARG AUTO_INSTRUMENTATION_NODEJS_VERSION
ARG AUTO_INSTRUMENTATION_DOTNET_VERSION
ARG DCMG_EXPORTER_VERSION
ARG NEURON_MONITOR_VERSION
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ VERSION_PKG ?= "github.com/aws/amazon-cloudwatch-agent-operator/internal/version
AGENT_VERSION ?= "$(shell grep -v '\#' versions.txt | grep cloudwatch-agent | awk -F= '{print $$2}')"
AUTO_INSTRUMENTATION_JAVA_VERSION ?= "$(shell grep -v '\#' versions.txt | grep aws-otel-java-instrumentation | awk -F= '{print $$2}')"
AUTO_INSTRUMENTATION_PYTHON_VERSION ?= "$(shell grep -v '\#' versions.txt | grep aws-otel-python-instrumentation | awk -F= '{print $$2}')"
AUTO_INSTRUMENTATION_NODEJS_VERSION ?= "$(shell grep -v '\#' versions.txt | grep aws-otel-nodejs-instrumentation | awk -F= '{print $$2}')"
AUTO_INSTRUMENTATION_DOTNET_VERSION ?= "$(shell grep -v '\#' versions.txt | grep aws-otel-dotnet-instrumentation | awk -F= '{print $$2}')"
DCGM_EXPORTER_VERSION ?= "$(shell grep -v '\#' versions.txt | grep dcgm-exporter | awk -F= '{print $$2}')"
NEURON_MONITOR_VERSION ?= "$(shell grep -v '\#' versions.txt | grep neuron-monitor | awk -F= '{print $$2}')"
Expand Down Expand Up @@ -154,6 +155,7 @@ generate: controller-gen api-docs
# buildx is used to ensure same results for arm based systems (m1/2 chips)
.PHONY: container
container:
docker buildx build --load --platform linux/${ARCH} -t ${IMG} --build-arg VERSION_PKG=${VERSION_PKG} --build-arg VERSION=${VERSION} --build-arg VERSION_DATE=${VERSION_DATE} --build-arg AGENT_VERSION=${AGENT_VERSION} --build-arg AUTO_INSTRUMENTATION_JAVA_VERSION=${AUTO_INSTRUMENTATION_JAVA_VERSION} --build-arg AUTO_INSTRUMENTATION_PYTHON_VERSION=${AUTO_INSTRUMENTATION_PYTHON_VERSION} --build-arg AUTO_INSTRUMENTATION_NODEJS_VERSION=${AUTO_INSTRUMENTATION_NODEJS_VERSION} --build-arg DCGM_EXPORTER_VERSION=${DCGM_EXPORTER_VERSION} --build-arg NEURON_MONITOR_VERSION=${NEURON_MONITOR_VERSION} .
docker buildx build --load --platform linux/${ARCH} -t ${IMG} --build-arg VERSION_PKG=${VERSION_PKG} --build-arg VERSION=${VERSION} --build-arg VERSION_DATE=${VERSION_DATE} --build-arg AGENT_VERSION=${AGENT_VERSION} --build-arg AUTO_INSTRUMENTATION_JAVA_VERSION=${AUTO_INSTRUMENTATION_JAVA_VERSION} --build-arg AUTO_INSTRUMENTATION_PYTHON_VERSION=${AUTO_INSTRUMENTATION_PYTHON_VERSION} --build-arg AUTO_INSTRUMENTATION_DOTNET_VERSION=${AUTO_INSTRUMENTATION_DOTNET_VERSION} --build-arg DCGM_EXPORTER_VERSION=${DCGM_EXPORTER_VERSION} --build-arg NEURON_MONITOR_VERSION=${NEURON_MONITOR_VERSION} .

# Push the container image, used only for local dev purposes
Expand Down
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const (
autoInstrumentationJavaImageRepository = "public.ecr.aws/aws-observability/adot-autoinstrumentation-java"
autoInstrumentationPythonImageRepository = "public.ecr.aws/aws-observability/adot-autoinstrumentation-python"
autoInstrumentationDotNetImageRepository = "ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-dotnet"

autoInstrumentationNodeJSImageRepository = "ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-nodejs"
dcgmExporterImageRepository = "nvcr.io/nvidia/k8s/dcgm-exporter"
neuronMonitorImageRepository = "public.ecr.aws/neuron"
)
Expand Down Expand Up @@ -118,6 +120,7 @@ func main() {
autoInstrumentationJava string
autoInstrumentationPython string
autoInstrumentationDotNet string
autoInstrumentationNodeJS string
autoAnnotationConfigStr string
autoInstrumentationConfigStr string
webhookPort int
Expand All @@ -132,13 +135,18 @@ func main() {
stringFlagOrEnv(&agentImage, "agent-image", "RELATED_IMAGE_COLLECTOR", fmt.Sprintf("%s:%s", cloudwatchAgentImageRepository, v.AmazonCloudWatchAgent), "The default CloudWatch Agent image. This image is used when no image is specified in the CustomResource.")
stringFlagOrEnv(&autoInstrumentationJava, "auto-instrumentation-java-image", "RELATED_IMAGE_AUTO_INSTRUMENTATION_JAVA", fmt.Sprintf("%s:%s", autoInstrumentationJavaImageRepository, v.AutoInstrumentationJava), "The default OpenTelemetry Java instrumentation image. This image is used when no image is specified in the CustomResource.")
stringFlagOrEnv(&autoInstrumentationPython, "auto-instrumentation-python-image", "RELATED_IMAGE_AUTO_INSTRUMENTATION_PYTHON", fmt.Sprintf("%s:%s", autoInstrumentationPythonImageRepository, v.AutoInstrumentationPython), "The default OpenTelemetry Python instrumentation image. This image is used when no image is specified in the CustomResource.")
stringFlagOrEnv(&autoInstrumentationNodeJS, "auto-instrumentation-nodejs-image", "RELATED_IMAGE_AUTO_INSTRUMENTATION_NODEJS", fmt.Sprintf("%s:%s", autoInstrumentationNodeJSImageRepository, v.AutoInstrumentationNodeJS), "The default OpenTelemetry NodeJS instrumentation image. This image is used when no image is specified in the CustomResource.")
stringFlagOrEnv(&autoInstrumentationDotNet, "auto-instrumentation-dotnet-image", "RELATED_IMAGE_AUTO_INSTRUMENTATION_DOTNET", fmt.Sprintf("%s:%s", autoInstrumentationDotNetImageRepository, v.AutoInstrumentationDotNet), "The default OpenTelemetry Dotnet instrumentation image. This image is used when no image is specified in the CustomResource.")
stringFlagOrEnv(&autoAnnotationConfigStr, "auto-annotation-config", "AUTO_ANNOTATION_CONFIG", "", "The configuration for auto-annotation.")
pflag.StringVar(&autoInstrumentationConfigStr, "auto-instrumentation-config", "", "The configuration for auto-instrumentation.")
stringFlagOrEnv(&dcgmExporterImage, "dcgm-exporter-image", "RELATED_IMAGE_DCGM_EXPORTER", fmt.Sprintf("%s:%s", dcgmExporterImageRepository, v.DcgmExporter), "The default DCGM Exporter image. This image is used when no image is specified in the CustomResource.")
stringFlagOrEnv(&neuronMonitorImage, "neuron-monitor-image", "RELATED_IMAGE_NEURON_MONITOR", fmt.Sprintf("%s:%s", neuronMonitorImageRepository, v.NeuronMonitor), "The default Neuron monitor image. This image is used when no image is specified in the CustomResource.")
pflag.Parse()

// set supported languages instrumentation images in environment variable to be used for default instrumentation
os.Setenv("AUTO_INSTRUMENTATION_JAVA", autoInstrumentationJava)
os.Setenv("AUTO_INSTRUMENTATION_PYTHON", autoInstrumentationPython)
os.Setenv("AUTO_INSTRUMENTATION_NODEJS", autoInstrumentationNodeJS)
// set instrumentation cpu and memory limits in environment variables to be used for default instrumentation; default values received from https://github.com/open-telemetry/opentelemetry-operator/blob/main/apis/v1alpha1/instrumentation_webhook.go
autoInstrumentationConfig := map[string]map[string]map[string]string{"java": {"limits": {"cpu": "500m", "memory": "64Mi"}, "requests": {"cpu": "50m", "memory": "64Mi"}}, "python": {"limits": {"cpu": "500m", "memory": "32Mi"}, "requests": {"cpu": "50m", "memory": "32Mi"}}, "dotnet": {"limits": {"cpu": "500m", "memory": "128Mi"}, "requests": {"cpu": "50m", "memory": "128Mi"}}}
err := json.Unmarshal([]byte(autoInstrumentationConfigStr), &autoInstrumentationConfig)
Expand Down Expand Up @@ -168,6 +176,7 @@ func main() {
"cloudwatch-agent", agentImage,
"auto-instrumentation-java", autoInstrumentationJava,
"auto-instrumentation-python", autoInstrumentationPython,
"auto-instrumentation-nodejs", autoInstrumentationNodeJS,
"auto-instrumentation-dotnet", autoInstrumentationDotNet,
"dcgm-exporter", dcgmExporterImage,
"neuron-monitor", neuronMonitorImage,
Expand All @@ -183,6 +192,7 @@ func main() {
config.WithCollectorImage(agentImage),
config.WithAutoInstrumentationJavaImage(autoInstrumentationJava),
config.WithAutoInstrumentationPythonImage(autoInstrumentationPython),
config.WithAutoInstrumentationNodeJSImage(autoInstrumentationNodeJS),
config.WithAutoInstrumentationDotNetImage(autoInstrumentationDotNet),
config.WithDcgmExporterImage(dcgmExporterImage),
config.WithNeuronMonitorImage(neuronMonitorImage),
Expand Down Expand Up @@ -280,6 +290,7 @@ func main() {
instrumentation.NewTypeSet(
instrumentation.TypeJava,
instrumentation.TypePython,
instrumentation.TypeNodeJS,
instrumentation.TypeDotNet,
),
)
Expand Down
3 changes: 3 additions & 0 deletions pkg/instrumentation/auto/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "github.com/aws/amazon-cloudwatch-agent-operator/pkg/instrumentation"
type AnnotationConfig struct {
Java AnnotationResources `json:"java"`
Python AnnotationResources `json:"python"`
NodeJS AnnotationResources `json:"nodejs"`
DotNet AnnotationResources `json:"dotnet"`
}

Expand All @@ -19,6 +20,8 @@ func (c AnnotationConfig) getResources(instType instrumentation.Type) Annotation
return c.Java
case instrumentation.TypePython:
return c.Python
case instrumentation.TypeNodeJS:
return c.NodeJS
case instrumentation.TypeDotNet:
return c.DotNet
default:
Expand Down
10 changes: 10 additions & 0 deletions pkg/instrumentation/auto/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,29 @@ func TestConfig(t *testing.T) {
DaemonSets: []string{"ds2"},
StatefulSets: []string{"ss2"},
},
NodeJS: AnnotationResources{
Namespaces: []string{"n3"},
Deployments: []string{"d3"},
DaemonSets: []string{"ds3"},
StatefulSets: []string{"ss3"},
},
DotNet: AnnotationResources{
Namespaces: []string{"n3"},
Deployments: []string{"d3"},
DaemonSets: []string{"ds3"},
StatefulSets: []string{"ss3"},
},
}

assert.Equal(t, cfg.Java, cfg.getResources(instrumentation.TypeJava))
assert.Equal(t, []string{"n1"}, getNamespaces(cfg.Java))
assert.Equal(t, []string{"d1"}, getDeployments(cfg.Java))
assert.Equal(t, cfg.Python, cfg.getResources(instrumentation.TypePython))
assert.Equal(t, []string{"ds2"}, getDaemonSets(cfg.Python))
assert.Equal(t, []string{"ss2"}, getStatefulSets(cfg.Python))
assert.Equal(t, cfg.NodeJS, cfg.getResources(instrumentation.TypeNodeJS))
assert.Equal(t, []string{"ds3"}, getDaemonSets(cfg.NodeJS))
assert.Equal(t, []string{"ss3"}, getStatefulSets(cfg.NodeJS))
assert.Equal(t, cfg.DotNet, cfg.getResources(instrumentation.TypeDotNet))
assert.Equal(t, []string{"ds3"}, getDaemonSets(cfg.DotNet))
assert.Equal(t, []string{"ss3"}, getStatefulSets(cfg.DotNet))
Expand Down
27 changes: 22 additions & 5 deletions pkg/instrumentation/defaultinstrumentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
)

const (
defaultAPIVersion = "cloudwatch.aws.amazon.com/v1alpha1"
defaultInstrumenation = "java-instrumentation"
defaultNamespace = "default"
defaultKind = "Instrumentation"
defaultAPIVersion = "cloudwatch.aws.amazon.com/v1alpha1"
defaultInstrumentation = "java-instrumentation"
defaultNamespace = "default"
defaultKind = "Instrumentation"

http = "http"
https = "https"
Expand Down Expand Up @@ -58,6 +58,10 @@ func getDefaultInstrumentation(agentConfig *adapters.CwaConfig, isWindowsPod boo
if !ok {
return nil, errors.New("unable to determine python instrumentation image")
}
nodeJSInstrumentationImage, ok := os.LookupEnv("AUTO_INSTRUMENTATION_NODEJS")
if !ok {
return nil, errors.New("unable to determine nodejs instrumentation image")
}
dotNetInstrumentationImage, ok := os.LookupEnv("AUTO_INSTRUMENTATION_DOTNET")
if !ok {
return nil, errors.New("unable to determine dotnet instrumentation image")
Expand Down Expand Up @@ -86,7 +90,7 @@ func getDefaultInstrumentation(agentConfig *adapters.CwaConfig, isWindowsPod boo
Kind: defaultKind,
},
ObjectMeta: metav1.ObjectMeta{
Name: defaultInstrumenation,
Name: defaultInstrumentation,
Namespace: defaultNamespace,
},
Spec: v1alpha1.InstrumentationSpec{
Expand Down Expand Up @@ -157,6 +161,19 @@ func getDefaultInstrumentation(agentConfig *adapters.CwaConfig, isWindowsPod boo
Requests: getInstrumentationConfigForResource(dotNet, request),
},
},
NodeJS: v1alpha1.NodeJS{
Image: nodeJSInstrumentationImage,
Env: []corev1.EnvVar{
{Name: "OTEL_AWS_APPLICATION_SIGNALS_ENABLED", Value: "true"},
{Name: "OTEL_TRACES_SAMPLER_ARG", Value: fmt.Sprintf("endpoint=%s://%s:2000", exporterPrefix, cloudwatchAgentServiceEndpoint)},
{Name: "OTEL_TRACES_SAMPLER", Value: "xray"},
{Name: "OTEL_EXPORTER_OTLP_PROTOCOL", Value: "http/protobuf"},
{Name: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", Value: fmt.Sprintf("%s://%s:4316/v1/traces", exporterPrefix, cloudwatchAgentServiceEndpoint)},
{Name: "OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT", Value: fmt.Sprintf("%s://%s:4316/v1/metrics", exporterPrefix, cloudwatchAgentServiceEndpoint)},
{Name: "OTEL_METRICS_EXPORTER", Value: "none"},
{Name: "OTEL_LOGS_EXPORTER", Value: "none"},
},
},
},
}, nil
}
77 changes: 68 additions & 9 deletions pkg/instrumentation/defaultinstrumentation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
package instrumentation

import (
"fmt"
"os"
"reflect"
"testing"

"github.com/google/go-cmp/cmp"

"k8s.io/apimachinery/pkg/api/resource"

corev1 "k8s.io/api/core/v1"
Expand All @@ -20,6 +22,7 @@ import (
func Test_getDefaultInstrumentationLinux(t *testing.T) {
os.Setenv("AUTO_INSTRUMENTATION_JAVA", defaultJavaInstrumentationImage)
os.Setenv("AUTO_INSTRUMENTATION_PYTHON", defaultPythonInstrumentationImage)
os.Setenv("AUTO_INSTRUMENTATION_NODEJS", defaultNodeJSInstrumentationImage)
os.Setenv("AUTO_INSTRUMENTATION_DOTNET", defaultDotNetInstrumentationImage)
os.Setenv("AUTO_INSTRUMENTATION_JAVA_CPU_LIMIT", "500m")
os.Setenv("AUTO_INSTRUMENTATION_JAVA_MEM_LIMIT", "64Mi")
Expand All @@ -41,7 +44,7 @@ func Test_getDefaultInstrumentationLinux(t *testing.T) {
Kind: defaultKind,
},
ObjectMeta: metav1.ObjectMeta{
Name: defaultInstrumenation,
Name: defaultInstrumentation,
Namespace: defaultNamespace,
},
Spec: v1alpha1.InstrumentationSpec{
Expand Down Expand Up @@ -130,6 +133,19 @@ func Test_getDefaultInstrumentationLinux(t *testing.T) {
},
},
},
NodeJS: v1alpha1.NodeJS{
Image: defaultNodeJSInstrumentationImage,
Env: []corev1.EnvVar{
{Name: "OTEL_AWS_APPLICATION_SIGNALS_ENABLED", Value: "true"},
{Name: "OTEL_TRACES_SAMPLER_ARG", Value: "endpoint=http://cloudwatch-agent.amazon-cloudwatch:2000"},
{Name: "OTEL_TRACES_SAMPLER", Value: "xray"},
{Name: "OTEL_EXPORTER_OTLP_PROTOCOL", Value: "http/protobuf"},
{Name: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", Value: "http://cloudwatch-agent.amazon-cloudwatch:4316/v1/traces"},
{Name: "OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT", Value: "http://cloudwatch-agent.amazon-cloudwatch:4316/v1/metrics"},
{Name: "OTEL_METRICS_EXPORTER", Value: "none"},
{Name: "OTEL_LOGS_EXPORTER", Value: "none"},
},
},
},
}
httpsInst := &v1alpha1.Instrumentation{
Expand All @@ -139,7 +155,7 @@ func Test_getDefaultInstrumentationLinux(t *testing.T) {
Kind: defaultKind,
},
ObjectMeta: metav1.ObjectMeta{
Name: defaultInstrumenation,
Name: defaultInstrumentation,
Namespace: defaultNamespace,
},
Spec: v1alpha1.InstrumentationSpec{
Expand Down Expand Up @@ -228,6 +244,19 @@ func Test_getDefaultInstrumentationLinux(t *testing.T) {
},
},
},
NodeJS: v1alpha1.NodeJS{
Image: defaultNodeJSInstrumentationImage,
Env: []corev1.EnvVar{
{Name: "OTEL_AWS_APPLICATION_SIGNALS_ENABLED", Value: "true"},
{Name: "OTEL_TRACES_SAMPLER_ARG", Value: "endpoint=https://cloudwatch-agent.amazon-cloudwatch:2000"},
{Name: "OTEL_TRACES_SAMPLER", Value: "xray"},
{Name: "OTEL_EXPORTER_OTLP_PROTOCOL", Value: "http/protobuf"},
{Name: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", Value: "https://cloudwatch-agent.amazon-cloudwatch:4316/v1/traces"},
{Name: "OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT", Value: "https://cloudwatch-agent.amazon-cloudwatch:4316/v1/metrics"},
{Name: "OTEL_METRICS_EXPORTER", Value: "none"},
{Name: "OTEL_LOGS_EXPORTER", Value: "none"},
},
},
},
}

Expand Down Expand Up @@ -281,17 +310,19 @@ func Test_getDefaultInstrumentationLinux(t *testing.T) {
t.Errorf("getDefaultInstrumentation() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("getDefaultInstrumentation() got = %v, want %v", got, tt.want)
if diff := cmp.Diff(tt.want, got); diff != "" {
t.Errorf("getDefaultInstrumentation() mismatch (-want +got):\n%s", diff)
}
})
}

}

func Test_getDefaultInstrumentationWindows(t *testing.T) {
os.Setenv("AUTO_INSTRUMENTATION_JAVA", defaultJavaInstrumentationImage)
os.Setenv("AUTO_INSTRUMENTATION_PYTHON", defaultPythonInstrumentationImage)
os.Setenv("AUTO_INSTRUMENTATION_DOTNET", defaultDotNetInstrumentationImage)
os.Setenv("AUTO_INSTRUMENTATION_NODEJS", defaultNodeJSInstrumentationImage)
os.Setenv("AUTO_INSTRUMENTATION_JAVA_CPU_LIMIT", "500m")
os.Setenv("AUTO_INSTRUMENTATION_JAVA_MEM_LIMIT", "64Mi")
os.Setenv("AUTO_INSTRUMENTATION_JAVA_CPU_REQUEST", "50m")
Expand All @@ -312,7 +343,7 @@ func Test_getDefaultInstrumentationWindows(t *testing.T) {
Kind: defaultKind,
},
ObjectMeta: metav1.ObjectMeta{
Name: defaultInstrumenation,
Name: defaultInstrumentation,
Namespace: defaultNamespace,
},
Spec: v1alpha1.InstrumentationSpec{
Expand Down Expand Up @@ -401,6 +432,19 @@ func Test_getDefaultInstrumentationWindows(t *testing.T) {
},
},
},
NodeJS: v1alpha1.NodeJS{
Image: defaultNodeJSInstrumentationImage,
Env: []corev1.EnvVar{
{Name: "OTEL_AWS_APPLICATION_SIGNALS_ENABLED", Value: "true"},
{Name: "OTEL_TRACES_SAMPLER_ARG", Value: "endpoint=http://cloudwatch-agent-windows-headless.amazon-cloudwatch.svc.cluster.local:2000"},
{Name: "OTEL_TRACES_SAMPLER", Value: "xray"},
{Name: "OTEL_EXPORTER_OTLP_PROTOCOL", Value: "http/protobuf"},
{Name: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", Value: "http://cloudwatch-agent-windows-headless.amazon-cloudwatch.svc.cluster.local:4316/v1/traces"},
{Name: "OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT", Value: "http://cloudwatch-agent-windows-headless.amazon-cloudwatch.svc.cluster.local:4316/v1/metrics"},
{Name: "OTEL_METRICS_EXPORTER", Value: "none"},
{Name: "OTEL_LOGS_EXPORTER", Value: "none"},
},
},
},
}
httpsInst := &v1alpha1.Instrumentation{
Expand All @@ -410,7 +454,7 @@ func Test_getDefaultInstrumentationWindows(t *testing.T) {
Kind: defaultKind,
},
ObjectMeta: metav1.ObjectMeta{
Name: defaultInstrumenation,
Name: defaultInstrumentation,
Namespace: defaultNamespace,
},
Spec: v1alpha1.InstrumentationSpec{
Expand Down Expand Up @@ -499,6 +543,19 @@ func Test_getDefaultInstrumentationWindows(t *testing.T) {
},
},
},
NodeJS: v1alpha1.NodeJS{
Image: defaultNodeJSInstrumentationImage,
Env: []corev1.EnvVar{
{Name: "OTEL_AWS_APPLICATION_SIGNALS_ENABLED", Value: "true"},
{Name: "OTEL_TRACES_SAMPLER_ARG", Value: "endpoint=https://cloudwatch-agent-windows-headless.amazon-cloudwatch.svc.cluster.local:2000"},
{Name: "OTEL_TRACES_SAMPLER", Value: "xray"},
{Name: "OTEL_EXPORTER_OTLP_PROTOCOL", Value: "http/protobuf"},
{Name: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", Value: "https://cloudwatch-agent-windows-headless.amazon-cloudwatch.svc.cluster.local:4316/v1/traces"},
{Name: "OTEL_AWS_APPLICATION_SIGNALS_EXPORTER_ENDPOINT", Value: "https://cloudwatch-agent-windows-headless.amazon-cloudwatch.svc.cluster.local:4316/v1/metrics"},
{Name: "OTEL_METRICS_EXPORTER", Value: "none"},
{Name: "OTEL_LOGS_EXPORTER", Value: "none"},
},
},
},
}

Expand Down Expand Up @@ -548,12 +605,14 @@ func Test_getDefaultInstrumentationWindows(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := getDefaultInstrumentation(tt.args.agentConfig, true)
fmt.Println(got)
fmt.Println("___------__---__")
if (err != nil) != tt.wantErr {
t.Errorf("getDefaultInstrumentation() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("getDefaultInstrumentation() got = %v, want %v", got, tt.want)
if diff := cmp.Diff(tt.want, got); diff != "" {
t.Errorf("getDefaultInstrumentation() mismatch (-want +got):\n%s", diff)
}
})
}
Expand Down
Loading
Loading