diff --git a/opentelemetry/Dockerfile-opentelemetry b/opentelemetry/Dockerfile-opentelemetry index a3346050..1963629b 100644 --- a/opentelemetry/Dockerfile-opentelemetry +++ b/opentelemetry/Dockerfile-opentelemetry @@ -1,7 +1,7 @@ FROM alpine:3.24@sha256:be2656061b536c1883c4034790e21d0a09c5aaaf51968b89368a3c0371ea2c9a AS otelc_curl RUN apk --update add curl -FROM otel/opentelemetry-collector:0.151.0@sha256:49a12827519134ed72881a64247ea43fbf4bdac50cfa41ceb495fc1c684451e2 +FROM otel/opentelemetry-collector:0.165.0@sha256:34b24b740c3c88d3467740e8642a397c13898ef76d7295c5425164c482ed1b73 COPY --from=otelc_curl / / diff --git a/opentelemetry/docker-compose.yaml b/opentelemetry/docker-compose.yaml index 153da43e..28774d48 100644 --- a/opentelemetry/docker-compose.yaml +++ b/opentelemetry/docker-compose.yaml @@ -67,5 +67,3 @@ services: retries: 120 start_period: 5s command: ["--config=/etc/otel-collector-config.yaml"] - ports: - - "${PORT_UI:-55679}:55679" diff --git a/opentelemetry/example.rst b/opentelemetry/example.rst index fe02c59c..56711f8d 100644 --- a/opentelemetry/example.rst +++ b/opentelemetry/example.rst @@ -41,7 +41,7 @@ propagating the spans (parent/child/shared context) generated by the OpenTelemet Each span records the latency of upstream API calls as well as information needed to correlate the span with other related spans (e.g., the trace ID). -The OpenTelemetry collector provides a web UI for viewing the collected traces on port ``55679``. +The OpenTelemetry collector is configured with the ``debug`` exporter, which logs the spans it receives to its output. Step 1: Build the sandbox ************************* @@ -63,7 +63,7 @@ To build this sandbox example, and start the example services run the following opentelemetry_envoy-1_1 /docker-entrypoint.sh /usr ... Up 10000/tcp opentelemetry_envoy-2_1 /docker-entrypoint.sh /usr ... Up 10000/tcp opentelemetry_envoy-front-proxy_1 /docker-entrypoint.sh /usr ... Up 0.0.0.0:10000->10000/tcp - opentelemetry_opentelemetry_1 /otelcol --config=/etc/ote ... Up (healthy) 4317/tcp, 55678/tcp, 0.0.0.0:55679->55679/tcp + opentelemetry_opentelemetry_1 /otelcol --config=/etc/ote ... Up (healthy) 4317-4318/tcp opentelemetry_service-1_1 python3 /code/service.py Up (healthy) opentelemetry_service-2_1 python3 /code/service.py Up (healthy) @@ -98,19 +98,28 @@ This will be routed via all 3 of the Envoy proxies: $ curl localhost:10000/trace/2 Hello from behind Envoy (service 2)! -Step 4: View the traces in OpenTelemetry UI -******************************************* +Step 4: View the traces in the collector's logs +*********************************************** -Point your browser to http://localhost:55679/debug/tracez. +The collector is configured with the ``debug`` exporter, which logs the spans it receives +to its output. View the collected traces with: -You should see the OpenTelemetry dashboard. +.. code-block:: console + + $ docker compose logs opentelemetry -.. image:: /start/sandboxes/_static/opentelemetry-ui.png +Each request produced a trace. You should see its spans exported — for example +``routeToEnvoy1`` for the request to ``service-1`` and ``routeToEnvoy2ViaEnvoy1`` for the +request to ``service-2`` — each with its trace ID and the Envoy service that emitted it: -In the ``Latency Samples`` of ``opentelemetry.proto.collector.trace.v1.TraceService/Export`` you can explore the traces by clicking any value of -``[>0s][>10µs][>100µs][>1ms][>10ms][>100ms][>1s][>10s][>1m40s]``. +.. code-block:: console -.. image:: /start/sandboxes/_static/opentelemetry-ui-traces.png + opentelemetry-1 | ResourceSpans #0 + opentelemetry-1 | -> service.name: Str(front-envoy) + opentelemetry-1 | ScopeSpans #0 + opentelemetry-1 | Span #0 + opentelemetry-1 | Trace ID : f6b2cd33dd2cb890bf5d702e1829e0ca + opentelemetry-1 | Name : routeToEnvoy1 .. seealso:: diff --git a/opentelemetry/otel-collector-config.yaml b/opentelemetry/otel-collector-config.yaml index 8f8dcf96..9e76a970 100755 --- a/opentelemetry/otel-collector-config.yaml +++ b/opentelemetry/otel-collector-config.yaml @@ -1,6 +1,4 @@ extensions: - zpages: - endpoint: 0.0.0.0:55679 health_check: receivers: @@ -35,4 +33,4 @@ service: processors: [memory_limiter, batch] exporters: [debug] - extensions: [zpages, health_check] + extensions: [health_check] diff --git a/opentelemetry/verify.sh b/opentelemetry/verify.sh index b5b48c09..142c1578 100755 --- a/opentelemetry/verify.sh +++ b/opentelemetry/verify.sh @@ -18,7 +18,16 @@ responds_with \ "Hello from behind Envoy (service 2)!" \ "http://localhost:${PORT_PROXY}/trace/2" -run_log "View the traces in OpenTelemetry UI" -responds_with \ - "" \ - "http://localhost:${PORT_UI}/debug/tracez" +run_log "View the traces in the collector's debug output" +# The collector's `debug` exporter logs the spans it receives to its stdout. Each request +# produced a trace; its spans appear once the batch processor flushes (a second or two). +check_span () { + "${DOCKER_COMPOSE[@]}" logs opentelemetry | grep -q "$1" +} +for span in routeToEnvoy1 routeToEnvoy2ViaEnvoy1; do + for _ in $(seq 1 15); do + check_span "$span" && break + sleep 1 + done + "${DOCKER_COMPOSE[@]}" logs opentelemetry | grep "$span" +done