Full lesson
Explore the full explanation, examples, and visuals at your own pace.
Part 1
General knowledgeThe OpenTelemetry Collector receives telemetry, processes it, and forwards it onward. Telemetry just means traces, metrics, and logs, the signals your software emits about what it's doing. Today, a fake client called telemetrygen sends traces to a Collector running locally, and we'll follow them through.
Before you start
You need three things. Docker runs the Collector, so we pull image 0.164.0. Go installs telemetrygen, a fake client that generates telemetry. And GOBIN, set so installed Go binaries land on your PATH and you can run telemetrygen.
- Docker: runs the Collector
- Go: installs telemetrygen
- GOBIN set: binaries on your PATH
Start the Collector
General knowledgeThis docker run command starts the Collector. Each dash p flag publishes a container port on 127.0.0.1, so only your own machine can reach it. The last part pipes the output through tee, which shows the logs in your terminal and also saves them to collector-output.txt, so we can check them later.
docker run \
-p 127.0.0.1:4317:4317 \
-p 127.0.0.1:4318:4318 \
-p 127.0.0.1:55679:55679 \
otel/opentelemetry-collector:0.164.0 \
2>&1 | tee collector-output.txtThree ports, three jobs
The Collector has three separate doors. Port 4317 takes OTLP over gRPC, the default for most SDKs. Port 4318 takes OTLP over HTTP, for clients that don't support gRPC. Port 55679 is different: it's ZPages, a built-in debug page you open in a browser to look inside the Collector.
OTLP: the shared language clients use to send telemetry
General knowledgeOTLP is the OpenTelemetry protocol, the shared language clients use to send telemetry. The data stays the same over gRPC or HTTP; only the transport differs.
Second terminal: send 3 traces
General knowledgeIn a second terminal, we run telemetrygen to act as the client. The traces subcommand with --traces 3 generates three traces. The --otlp-insecure flag skips TLS, which is fine for local use. The log line says traces generated, three. By default, telemetrygen sends them to localhost on port 4317.
$GOBIN/telemetrygen traces --otlp-insecure --traces 3
INFO traces/worker.go:99 traces generated {"worker": 0, "traces": 3}
INFO traces/traces.go:58 stop the batch span processorFollowing the 3 traces
General knowledgeFollow the three traces. telemetrygen sends them to the Receiver, which accepts OTLP over gRPC on port 4317. The Receiver passes the spans to the Processor, and the Processor forwards them to the Exporter. In this demo, the Exporter doesn't send to a real backend. It prints the spans to the terminal, so you can see them arrive.
collector-output.txt
General knowledgeThis is proof the data arrived. The grep command pulls just the useful lines from the saved collector output. Each Span is one timed operation. You can see its Trace ID, its own ID, a Name like lets-go or okey-dokey, and a Kind, Client or Server.
$ grep -E '^Span|(ID|Name|Kind)\s+:' ./collector-output.txt
Span #0
Trace ID : f30faffbde5fcf71432f89da1bf7bc14
Parent ID : 6f1ff7f9cf4ec1c7
ID : 8d1e820c1ac57337
Name : okey-dokey
Kind : Server
Span #1
Trace ID : f30faffbde5fcf71432f89da1bf7bc14
Parent ID :
ID : 6f1ff7f9cf4ec1c7
Name : lets-go
Kind : ClientOne trace, two linked spans
Read the output as a tree. Both spans share trace ID f30faffb, so they belong to one trace. The span lets-go has no Parent ID, which makes it the root. The span okey-dokey lists lets-go's ID as its Parent ID, so lets-go is its parent.
Port 55679: ZPages, a debug view in your browser
Port 55679 serves ZPages, a built-in debug UI. While the Collector runs, you can open it in your browser, giving you a second way to inspect it.
Same pipeline, different destinations
In real setups, only the export end changes. telemetrygen sends OTLP into the Collector, and the Collector forwards that same telemetry onward. Here it lands in your terminal, but it could just as well go to Jaeger or Prometheus. Think of the Collector as a relay between sources and backends.
Control-C stops it. A local demo, not production.
When you're done, press Control-C in the Collector terminal to stop it. Remember, this is a local demo, not production-ready. Configuration comes in the next lesson.
The Collector is a relay: receive on ports, process, export onward.
The Collector is a relay: receive on ports, process, export onward. To use it, send OTLP to port 4317 or 4318, then check the output.
