Skip to content

Commit

Permalink
Add EKS integration test for FluentBit log emission with custom envir…
Browse files Browse the repository at this point in the history
…onment (aws#432)
  • Loading branch information
zhihonl authored Nov 19, 2024
1 parent 3a6e4dc commit e453f35
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
42 changes: 41 additions & 1 deletion terraform/eks/daemon/entity/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ resource "aws_security_group_rule" "nodes_cluster_inbound" {
}

resource "null_resource" "clone_helm_chart" {
triggers = {
timestamp = "${timestamp()}" # Forces re-run on every apply
}
provisioner "local-exec" {
command = <<-EOT
if [ ! -d "./helm-charts" ]; then
Expand Down Expand Up @@ -272,9 +275,45 @@ resource "kubernetes_pod" "petclinic_instrumentation" {
}
}


resource "kubernetes_pod" "petclinic_custom_env" {
depends_on = [aws_eks_node_group.this, helm_release.aws_observability, null_resource.update_image]
metadata {
name = "petclinic-instrumentation-custom-env"
annotations = {
"instrumentation.opentelemetry.io/inject-java" = "true"
}
labels = {
app = "petclinic"
}
}

spec {
container {
name = "petclinic"
image = "506463145083.dkr.ecr.us-west-2.amazonaws.com/cwagent-integ-test-petclinic:latest"

port {
container_port = 8080
}

env {
name = "OTEL_SERVICE_NAME"
value = "petclinic-custom-service-name"
}

env {
name = "OTEL_RESOURCE_ATTRIBUTES"
value = "deployment.environment=petclinic-custom-environment"
}

}
}
}

# Traffic generator pod with bash command
resource "kubernetes_pod" "traffic_generator_instrumentation" {
depends_on = [kubernetes_pod.petclinic_instrumentation, kubernetes_service.petclinic_service]
depends_on = [kubernetes_pod.petclinic_instrumentation, kubernetes_pod.petclinic_custom_env, kubernetes_service.petclinic_service]
metadata {
name = "traffic-generator-instrumentation-default-env"
}
Expand Down Expand Up @@ -339,6 +378,7 @@ resource "null_resource" "validator" {
null_resource.update_image,
kubernetes_pod.log_generator,
kubernetes_pod.petclinic_instrumentation,
kubernetes_pod.petclinic_custom_env,
kubernetes_pod.traffic_generator_instrumentation
]

Expand Down
18 changes: 18 additions & 0 deletions test/entity/entity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,24 @@ func TestPutLogEventEntityEKS(t *testing.T) {
serviceNameSource: entityServiceNameSourceInstrumentation,
},
},
"Entity/InstrumentationServiceNameSourceCustomEnvironment": {
agentConfigPath: filepath.Join("resources", "compass_default_log.json"),
podName: "petclinic-instrumentation-custom-env",
expectedEntity: expectedEntity{
entityType: eksServiceEntityType,
// This service name comes from OTEL_SERVICE_NAME which is
// customized in the terraform code when creating the pod
name: "petclinic-custom-service-name",
environment: "petclinic-custom-environment",
platformType: entityEKSPlatform,
k8sWorkload: "petclinic-instrumentation-custom-env",
k8sNode: *instancePrivateDNS,
k8sNamespace: k8sDefaultNamespace,
eksCluster: env.EKSClusterName,
instanceId: env.InstanceId,
serviceNameSource: entityServiceNameSourceInstrumentation,
},
},
}
for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
Expand Down

0 comments on commit e453f35

Please sign in to comment.