Tracing on Amazon EKS¶
Distributed tracing helps you have end-to-end visibility between transactions in distributed nodes.
How tracing works in v3¶
The eks-monitoring module configures traces collection depending on the
collector profile:
| Profile | Traces support | Exporter |
|---|---|---|
self-managed-amp |
Yes (toggle with enable_tracing) |
OTLP → AWS X-Ray |
cloudwatch-otlp |
Yes (always enabled) | OTLP → AWS X-Ray |
managed-metrics |
No (metrics only) | — |
The OpenTelemetry Collector receives traces via the OTLP protocol (gRPC on port 4317, HTTP on port 4318) and exports them to AWS X-Ray.
Note
To disable tracing in the self-managed-amp profile, set
enable_tracing = false in the
module configuration.
Instrumentation¶
Applications send traces to the OTel Collector using the OpenTelemetry SDK. Point your application's OTLP exporter at the collector service:
env:
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "http://otel-collector.otel-collector.svc.cluster.local:4317"
Note
To learn more about instrumenting with OpenTelemetry, visit the OpenTelemetry documentation for your programming language.
Example: Go sample application¶
Let's use a sample application that is already instrumented with the OpenTelemetry SDK.
git clone https://github.com/aws-observability/aws-otel-community.git
cd aws-otel-community/sample-apps/go-sample-app
Building and publishing the container image¶
docker build -t go-sample-app .
docker buildx build -t go-sample-app . --platform=linux/amd64
Publish to Amazon ECR:
export ECR_REPOSITORY_URI=$(aws ecr create-repository --repository go-sample-app --query repository.repositoryUri --output text)
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REPOSITORY_URI
docker tag go-sample-app:latest "${ECR_REPOSITORY_URI}:latest"
docker push "${ECR_REPOSITORY_URI}:latest"
Deploying on Amazon EKS¶
| eks.yaml | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
Deploy and test:
kubectl apply -f eks.yaml
kubectl port-forward deployment/go-sample-app 8080:8080
curl http://localhost:8080/
curl http://localhost:8080/outgoing-http-call
curl http://localhost:8080/aws-sdk-call
Visualizing traces¶
Open your Amazon Managed Grafana workspace and add the AWS X-Ray data source. In the Grafana Explorer view, select the X-Ray data source and use Query Type: Trace List to browse traces.
You can also view traces in the CloudWatch console, which provides a service map and trace detail views. If your logs are stored in CloudWatch Logs, the trace detail page can correlate logs automatically.