This example uses the new WebApplication host that ships with .NET and shows how to setup:
- OpenTelemetry logging
- OpenTelemetry metrics
- OpenTelemetry tracing
ResourceBuilder is associated with OpenTelemetry to associate the
service name, version and the machine on which this program is running.
The sample rate is set to emit all the traces using AlwaysOnSampler.
You can try out different samplers like TraceIdRatioBasedSampler.
The example by default writes telemetry to stdout. To enable telemetry export
via OTLP, update the appsettings.json file to replace "console" with
"otlp". Launching the application will then send telemetry data via OTLP.
Use the provided "docker-compose.yaml" file to spin up the required dependencies, including:
- OTel Collector Accept telemetry and forwards them to Loki, Tempo, and Prometheus
- Prometheus to store metrics
- Grafana (UI) UI to view logs, metrics and traces. (Exemplars can be used to jump from metrics to traces)
- Tempo to store traces
- Loki to store logs
Once the Docker containers are running, you can access the Grafana UI at: http://localhost:3000