From fa6f35050f42462f4de3ea3bfa4da7ba0d42bca4 Mon Sep 17 00:00:00 2001 From: Shaaz Date: Fri, 6 Jun 2025 00:35:36 +0100 Subject: [PATCH] docs: add local testing instructions for custom metrics --- docs/telemetry/custom-metrics.mdx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/telemetry/custom-metrics.mdx b/docs/telemetry/custom-metrics.mdx index d44ffee1..86103e24 100644 --- a/docs/telemetry/custom-metrics.mdx +++ b/docs/telemetry/custom-metrics.mdx @@ -111,6 +111,28 @@ Here's what a tracing event looks like when exported: - Use `counter` for values that can go up and down - Use `histogram` for measuring distributions +## Testing Custom Metrics Locally + +Run the OpenTelemetry collector locally in one terminal: + +```bash +docker run \ + -p 127.0.0.1:4318:4318 \ + -p 127.0.0.1:55679:55679 \ + otel/opentelemetry-collector-contrib:0.97.0 \ + 2>&1 | tee collector-output.txt +``` + +In another terminal, start your Shuttle project and point it at the local collector: + +```bash +otel_exporter_otlp_endpoint=HTTP://localhost:4318 shuttle run +``` + +Hit your service locally (for example `curl http://localhost:8000`) and you should see metrics in `collector-output.txt`. + +For more on using OpenTelemetry in Rust see [Working with OpenTelemetry using Rust](https://www.shuttle.dev/blog/2024/04/10/using-opentelemetry-rust). + ## Learn More - [tracing documentation](https://docs.rs/tracing/latest/tracing/)