Add Tracing Via Fastrace #5

Merged
vanhouc merged 3 commits from feature/tracing into main 2025-06-11 21:15:15 -04:00
vanhouc commented 2025-06-11 21:12:49 -04:00 (Migrated from github.com)

This pull request introduces OpenTelemetry tracing to the project, updates dependencies, and adds a Docker Compose file for containerized development. The most important changes include integrating OpenTelemetry with the fastrace library, adding environment variables to configure tracing, and setting up Docker Compose services for the application and Jaeger.

OpenTelemetry Integration:

  • Cargo.toml: Added dependencies for OpenTelemetry (opentelemetry, opentelemetry-otlp, opentelemetry_sdk) and fastrace-opentelemetry to enable distributed tracing.
  • src/main.rs: Replaced the ConsoleReporter with OpenTelemetryReporter for tracing. Configured the reporter with an OTLP exporter and resource attributes such as service.name.

Environment Variables for Tracing:

  • src/main.rs: Added support for the OLTP_EXPORTER_ENDPOINT environment variable to configure the OTLP exporter endpoint. Updated PORT parsing to ensure it is a valid u16. [1] [2]

Docker Compose Setup:

  • docker-compose.yml: Added services for the application and Jaeger. Configured ports, environment variables, and health checks for Jaeger. Mounted the assets directory as a volume for the application.
This pull request introduces OpenTelemetry tracing to the project, updates dependencies, and adds a Docker Compose file for containerized development. The most important changes include integrating OpenTelemetry with the `fastrace` library, adding environment variables to configure tracing, and setting up Docker Compose services for the application and Jaeger. ### OpenTelemetry Integration: * [`Cargo.toml`](diffhunk://#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542R14-R27): Added dependencies for OpenTelemetry (`opentelemetry`, `opentelemetry-otlp`, `opentelemetry_sdk`) and `fastrace-opentelemetry` to enable distributed tracing. * [`src/main.rs`](diffhunk://#diff-42cb6807ad74b3e201c5a7ca98b911c5fa08380e942be6e4ac5807f8377f87fcL25-R56): Replaced the `ConsoleReporter` with `OpenTelemetryReporter` for tracing. Configured the reporter with an OTLP exporter and resource attributes such as `service.name`. ### Environment Variables for Tracing: * [`src/main.rs`](diffhunk://#diff-42cb6807ad74b3e201c5a7ca98b911c5fa08380e942be6e4ac5807f8377f87fcL25-R56): Added support for the `OLTP_EXPORTER_ENDPOINT` environment variable to configure the OTLP exporter endpoint. Updated `PORT` parsing to ensure it is a valid `u16`. [[1]](diffhunk://#diff-42cb6807ad74b3e201c5a7ca98b911c5fa08380e942be6e4ac5807f8377f87fcL25-R56) [[2]](diffhunk://#diff-42cb6807ad74b3e201c5a7ca98b911c5fa08380e942be6e4ac5807f8377f87fcL37-R76) ### Docker Compose Setup: * [`docker-compose.yml`](diffhunk://#diff-e45e45baeda1c1e73482975a664062aa56f20c03dd9d64a827aba57775bed0d3R1-R30): Added services for the application and Jaeger. Configured ports, environment variables, and health checks for Jaeger. Mounted the `assets` directory as a volume for the application.
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2025-06-11 21:13:20 -04:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull Request Overview

This PR introduces OpenTelemetry tracing into the project by integrating the fastrace library with an OpenTelemetry reporter, updates dependency versions, and adds a Docker Compose setup for containerized development with Jaeger for visualization.

  • Integrates OpenTelemetryReporter and configures it with an OTLP exporter.
  • Adds environment variable support for the exporter endpoint and updates port parsing.
  • Provides a Docker Compose file with application and Jaeger services.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/main.rs Updates reporter configuration and environment setup
docker-compose.yml Adds containerized development and Jaeger healthcheck
Cargo.toml Updates dependencies for OpenTelemetry and fastrace
Comments suppressed due to low confidence (2)

src/main.rs:35

  • [nitpick] Consider verifying that the environment variable name 'OLTP_EXPORTER_ENDPOINT' is intentional; typically, OpenTelemetry uses the acronym 'OTLP' for its protocol, which might require adjustment for clarity.
std::env::var("OLTP_EXPORTER_ENDPOINT").expect("OLTP_EXPORTER_ENDPOINT must be defined")

docker-compose.yml:27

  • Ensure that the 'jaeger' container image includes 'wget' or consider using an alternative command like 'curl' for the healthcheck, to guarantee consistent behavior across environments.
test: ["CMD", "wget", "--spider", "http://localhost:16686"]
## Pull Request Overview This PR introduces OpenTelemetry tracing into the project by integrating the fastrace library with an OpenTelemetry reporter, updates dependency versions, and adds a Docker Compose setup for containerized development with Jaeger for visualization. - Integrates OpenTelemetryReporter and configures it with an OTLP exporter. - Adds environment variable support for the exporter endpoint and updates port parsing. - Provides a Docker Compose file with application and Jaeger services. ### Reviewed Changes Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments. | File | Description | | ---------------- | ------------------------------------------------------ | | src/main.rs | Updates reporter configuration and environment setup | | docker-compose.yml | Adds containerized development and Jaeger healthcheck | | Cargo.toml | Updates dependencies for OpenTelemetry and fastrace | <details> <summary>Comments suppressed due to low confidence (2)</summary> **src/main.rs:35** * [nitpick] Consider verifying that the environment variable name 'OLTP_EXPORTER_ENDPOINT' is intentional; typically, OpenTelemetry uses the acronym 'OTLP' for its protocol, which might require adjustment for clarity. ``` std::env::var("OLTP_EXPORTER_ENDPOINT").expect("OLTP_EXPORTER_ENDPOINT must be defined") ``` **docker-compose.yml:27** * Ensure that the 'jaeger' container image includes 'wget' or consider using an alternative command like 'curl' for the healthcheck, to guarantee consistent behavior across environments. ``` test: ["CMD", "wget", "--spider", "http://localhost:16686"] ``` </details>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cameron/website!5
No description provided.