- Newest
- Most votes
- Most comments
Thank you for providing such detailed information about your setup. Let me help you understand what's happening and provide some guidance on how to proceed with exporting traces from your containerized app run by AppRunner to X-Ray.
When you enable observability with X-Ray in App Runner, several things happen under the hood:
- App Runner sets up the necessary infrastructure to collect and send traces to X-Ray.
- It uses the AWS Distro for OpenTelemetry (ADOT) to integrate with X-Ray.
- The X-Ray daemon is automatically deployed as part of your App Runner service.
The error you're seeing suggests that your application is trying to send traces to http://localhost:4317, but it's not able to connect. This is likely because the X-Ray daemon is not listening on that specific port in the App Runner environment.
To resolve this issue and properly export traces to X-Ray, you should make the following adjustments:
-
Instead of sending traces directly to
http://localhost:4317, you should configure your application to use the AWS X-Ray SDK or the ADOT SDK for trace collection. -
Update your Dockerfile to include the necessary OTEL dependencies. You can do this by adding the following to your Dockerfile:
RUN apt-get update && apt-get install -y curl RUN curl -L https://github.com/aws-observability/aws-otel-collector/releases/latest/download/aws-otel-collector-linux-amd64.tar.gz | tar -xz -
Set up the required environment variables in your App Runner service configuration. Add these to your
runtimeEnvironmentVariablesin the CDK code:runtimeEnvironmentVariables: [ { name: "OTEL_EXPORTER_OTLP_ENDPOINT", value: "http://localhost:4317" }, { name: "OTEL_RESOURCE_ATTRIBUTES", value: "service.name=YOUR_SERVICE_NAME" }, { name: "AWS_REGION", value: this.region }, ], -
In your Rust application, make sure you're using the OpenTelemetry SDK with the OTLP exporter configured to send traces to the X-Ray daemon. You might need to update your dependencies and code to ensure compatibility with the ADOT setup.
-
Ensure that your App Runner instance role (appRunnerInstanceRole in your CDK code) has the necessary permissions to write to X-Ray. You've already included the correct permissions in your code, which is good.
By making these changes, your application should be able to send traces to the X-Ray daemon, which will then forward them to the X-Ray service. You can then view your traces in the AWS X-Ray console or through the App Runner console's Observability tab.
Remember to rebuild and redeploy your application after making these changes. If you continue to experience issues, you may want to check the App Runner logs for any additional error messages or consult the AWS documentation for troubleshooting steps specific to App Runner and X-Ray integration.
Sources
Tracing for your App Runner application with X-Ray - AWS App Runner
AWS App Runner and X-Ray - AWS X-Ray
Release: App Runner launches built-in X-Ray support on April 12, 2022 - AWS App Runner
enum TraceConfigurationVendor · AWS CDK
answered 2 years ago
Relevant content
asked 3 years ago

Both are not available for rust lang.
Would it make more sense to send traces via http to the
https://xray.AWS Region.amazonaws.com/v1/tracesendpoint?