Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion opentelemetry/Dockerfile-opentelemetry
Original file line number Diff line number Diff line change
@@ -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 / /

Expand Down
2 changes: 0 additions & 2 deletions opentelemetry/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,3 @@ services:
retries: 120
start_period: 5s
command: ["--config=/etc/otel-collector-config.yaml"]
ports:
- "${PORT_UI:-55679}:55679"
29 changes: 19 additions & 10 deletions opentelemetry/example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
*************************
Expand All @@ -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)

Expand Down Expand Up @@ -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::

Expand Down
4 changes: 1 addition & 3 deletions opentelemetry/otel-collector-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
extensions:
zpages:
endpoint: 0.0.0.0:55679
health_check:

receivers:
Expand Down Expand Up @@ -35,4 +33,4 @@ service:
processors: [memory_limiter, batch]
exporters: [debug]

extensions: [zpages, health_check]
extensions: [health_check]
17 changes: 13 additions & 4 deletions opentelemetry/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
"<!DOCTYPE html>" \
"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
Loading