From 970fc1b6f71edaca21e0f298c6330b64e79690c2 Mon Sep 17 00:00:00 2001 From: Christopher Petito Date: Wed, 9 Apr 2025 13:48:04 +0200 Subject: [PATCH] Basic compose file for testing OTEL bits Signed-off-by: Christopher Petito --- contrib/otel/README.md | 28 ++++++++++++++++++++++++++++ contrib/otel/compose.yaml | 31 +++++++++++++++++++++++++++++++ contrib/otel/otelcol.yaml | 23 +++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 contrib/otel/README.md create mode 100644 contrib/otel/compose.yaml create mode 100644 contrib/otel/otelcol.yaml diff --git a/contrib/otel/README.md b/contrib/otel/README.md new file mode 100644 index 0000000000..9d089475df --- /dev/null +++ b/contrib/otel/README.md @@ -0,0 +1,28 @@ +# Sample stack for testing OTEL functionality with moby + +To easily test the OTEL functionality present in moby, you can spin up a small demo compose stack that includes: +- an OTEL collector container; +- a Jaeger container to visualize traces; +- an alternative Aspire Dashboard container to visualize traces; + +The OTEL collector is configured to export Traces to both the Jaeger and Aspire containers. + +The `contrib/otel` directory contains the compose file with the services configured, along with a basic configuration file for the OTEL collector. + +## How can I use it? + +1. Export the env var used to override the OTLP endpoint: + `export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318` (if running in a devcontainer or in other ways, you might have to change how you pass this env var to the daemon); +2. Start the moby engine you want to get traces from (make sure it gets the env var declared above); +3. Start the otel compose stack by running `docker compose up -d` in the `contrib/otel/` directory; +4. Make some calls to the engine using the Docker CLI to send some traces to the endpoint; +5. Browse Jaeger at `http://localhost:16686` or the Aspire Dashboard at `http://localhost:18888/traces`; +6. To see some traces from the engine, select `dockerd` in the top left dropdown + +> **Note**: The precise steps may vary based on how you're working on the codebase (buiding a binary and executing natively, running/debugging in a devcontainer, etc... ) + +## Cleanup? + +Simply run `docker compose down` in the `contrib/otel/` directory. + +You can also run `unset OTEL_EXPORTER_OTLP_ENDPOINT` to get rid of the OTLP env var from your environment diff --git a/contrib/otel/compose.yaml b/contrib/otel/compose.yaml new file mode 100644 index 0000000000..51542c1fd5 --- /dev/null +++ b/contrib/otel/compose.yaml @@ -0,0 +1,31 @@ +name: moby-otel + +services: + + jaeger: + image: jaegertracing/all-in-one:latest + restart: always + ports: + - 16686:16686 + + aspire-dashboard: + image: mcr.microsoft.com/dotnet/nightly/aspire-dashboard + restart: always + ports: + - 0.0.0.0:18888:18888 + environment: + DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS: 'true' + + otelcol: + image: otel/opentelemetry-collector-contrib:latest + restart: always + depends_on: + - jaeger + - aspire-dashboard + ports: + - 4318:4318 # default otlp http port + develop: + watch: + - action: sync+restart + path: ./otelcol.yaml + target: /etc/otelcol-contrib/config.yaml diff --git a/contrib/otel/otelcol.yaml b/contrib/otel/otelcol.yaml new file mode 100644 index 0000000000..65a4cb4380 --- /dev/null +++ b/contrib/otel/otelcol.yaml @@ -0,0 +1,23 @@ +# Receive signals over gRPC and HTTP +# moby currently uses http +receivers: + otlp: + protocols: + grpc: + endpoint: 0.0.0.0:4317 + http: + endpoint: 0.0.0.0:4318 + +exporters: + otlp/jaeger: + endpoint: jaeger:4317 + tls::insecure: true + otlp/aspire: + endpoint: aspire-dashboard:18889 + tls::insecure: true + +service: + pipelines: + traces: + receivers: [otlp] + exporters: [otlp/jaeger, otlp/aspire]