This is personal playground template project to get working configuration for the telemetry (distributed tracing) and metrics within Devcontainers. All credits for OpenTelemetry and OpenTelemetry Collector Contrib projects.
The test demo server was taken from the OpenTelemetry Collector Demo without any changes. It is written in go language but that is not important for the matter of the example. The demo server is using OpenTelemetry API to report telemetry traces to the open source distributed tracing applications like Jaeger and Zipkin through special OpenTelemetry connector. The demo test server can be replaced with any application of your language choice as soon as it is using OpenTelemetry API.
The demo endpoint can be triggered as HTTP GET to http://localhost:7080/hello Please che Devcontainer configuration for the list of the exposed ports.
- OpenTelemetry collector providing OpenTelemetry API.
- Jaeger and Zipkin to collect distributed traces (telemetry).
- Prometheus to collect metrics.
- Grafana default username/pwd: admin/admin
- Two different devcontainer with different network configurations:
- Bridged network - default in docker-compose
- DB network - default in devcontainers
The common approach I found in devcontainer template examples is to configure Devcontainer network to use network mode like this (when using docker-container configuration):
...
network_mode: service:telemetry-test-db
where "telemetry-test-db" is the network used by DB service. That allows to use Devcontainer "forwardPorts" (in the devcontainer.json) to forward ports outside of the Devcontainer.
I wasn't able to make this network configuration work properly. So, I have configured more classic bridge network within the Devcontainer and have port forwarding "standard" docker-compose way. It doesn't show port forwarded in Devcontainer "Ports" panel (at the bottom of the VSCode). But all ports are still forwarded with docker-compose itself so available at the host system.