OpenTelemetry

If the otel feature is enabled, Roadster will initialize various OpenTelemetry resources in the init_tracing, which is used in the default implementation of App#init_tracing. In particular, Roadster will set the OTEL service name and version and configure trace and metrics exporters.

Sample OTEL configuration

[tracing]
# Explicitly provide the service name. If not provided, will
# use the `app.name` config field, converted to `snake_case`.
service-name = "example-service-name"
trace-propagation = true
otlp-endpoint = "localhost:1234"
# Export metrics every 1 minute. Adjust based on your app's needs.
metrics-export-interval = 60000

# Set the endpoint to use as a fallback if the trace/metric endpoint is not provided
[tracing.otlp.endpoint]
protocol = "grpc"
url = "http://localhost:4317"

# Set the endpoint to use for traces
[tracing.otlp.trace-endpoint]
# The `http` protocol is enabled by default when the `otel` feature is enabled.
protocol = "http"
url = "http://localhost:4318/v1/traces"
# Traces can also be exported via grpc
#protocol = "grpc"
#url = "http://localhost:4317"

[tracing.otlp.metric-endpoint]
# The `grpc` protocol requires the `otel-grpc` feature to be enabled.
protocol = "grpc"
url = "http://localhost:4317"
# Metrics can also be exported via http
#protocol = "http"
#url = "http://localhost:4318/v1/metrics"

View metrics and traces locally

You can also view traces locally using, for example, Jaeger, Grafana, or SigNoz.

Jaeger

Probably the easiest way to view OpenTelemetry Traces locally is by running Jaeger. Jaeger only supports traces, however. To visualize metrics, use one of the other options mentioned in this section.

  1. Configure your OTLP endpoint in your app's configs. An example is provided above.
  2. Run the following command:
    docker run --rm --name jaeger \
     -p 16686:16686 \
     -p 4317:4317 \
     -p 4318:4318 \
     -p 5778:5778 \
     -p 9411:9411 \
     jaegertracing/jaeger:2.4.0
    
  3. Navigate to the UI, which is available at localhost:16686.

Grafana

Another option to view traces and metrics locally is to run Grafana's "LGTM" docker image, which is a pre-built image intended for use in development environments. It's not intended for production use, but is useful for viewing traces and metrics locally.

  1. Configure your OTLP endpoint in your app's configs. An example is provided above.
  2. Run the following command:
    docker run -p 4000:3000 -p 4317:4317 -p 4318:4318 --rm -ti grafana/otel-lgtm
    
  3. Navigate to the UI, which is available at localhost:4000.

Signoz

Another option to view traces and metrics locally is to run Signoz.

  1. Configure your OTLP endpoint in your app's configs. An example is provided above.
  2. Install and run Signoz in a directory of your choice
    # Clone the repo
    git clone -b main https://github.com/SigNoz/signoz.git && cd signoz/deploy/
    # Remove the sample application: https://signoz.io/docs/operate/docker-standalone/#remove-the-sample-application-from-signoz-dashboard
    vim docker/clickhouse-setup/docker-compose.yaml
    # Remove the `services.hotrod` and `services.load-hotrod` sections, then exit `vim`
    # Run the `docker compose` command
    ./install.sh
    
  3. Navigate to the UI, which is available at localhost:3301.
  4. To stop Signoz, run the following:
    docker compose -f docker/clickhouse-setup/docker-compose.yaml stop