Goal: spin up a local OpenTelemetry stack and verify that a basic .NET app exports traces/metrics via otel-collector into Tempo/Prometheus, with visualization in Grafana.
From examples/Ydb.Sdk.AdoNet.OpenTelemetry:
# Preferred (Docker Compose v1 / legacy binary)
docker-compose -f compose-e2e.yaml up -d
# Alternative (Docker Compose v2 plugin, if available)
# docker compose -f compose-e2e.yaml up -dNote: the ydbplatform/local-ydb image is commonly used as linux/amd64. On Apple Silicon/arm64 (e.g. Colima), you may need x86_64 emulation (Rosetta) depending on your Docker VM setup.
This demo already exports app traces to the collector. To also export YDB server traces into the same collector:
# 1) edit ./ydb_config/ydb-config.yaml and add tracing_config
# (see ./ydb_config/otel-tracing-snippet.yaml)
#
# 2) recreate the ydb container to pick up the updated config
docker-compose -f compose-e2e.yaml up -d --force-recreate ydb- YDB local UI:
http://localhost:8765 - Grafana:
http://localhost:3000(anonymous access enabled) - Tempo API:
http://localhost:3200 - Loki API:
http://localhost:3100 - Prometheus:
http://localhost:9090 - OTel Collector
- OTLP gRPC:
localhost:4317 - OTLP HTTP:
http://localhost:4318 - healthcheck:
http://localhost:13133 - zPages:
http://localhost:55679/debug/tracez
- OTLP gRPC:
Prometheus scrapes the collector's Prometheus exporter at otel-collector:9464.
- If your .NET app exports metrics via OTLP, you will see them in Prometheus/Grafana.
- YDB metrics are not scraped in this demo by default (YDB → Collector metrics wiring depends on how YDB exposes metrics in your setup/version).
From examples/Ydb.Sdk.AdoNet.OpenTelemetry:
# Traces only (Docker Compose `app` uses this project)
dotnet run -c Release --project "Trace/Ydb.Sdk.AdoNet.OpenTelemetry.Trace.csproj"
# Metrics + traces (+ optional load generator)
dotnet run -c Release --project "Metrics/Ydb.Sdk.AdoNet.OpenTelemetry.Metrics.csproj"
dotnet run -c Release --project "Metrics/Ydb.Sdk.AdoNet.OpenTelemetry.Metrics.csproj" -- --load
# Logs (SDK logs exported via OTLP → Collector → Loki)
dotnet run -c Release --project "Logs/Ydb.Sdk.AdoNet.OpenTelemetry.Logs.csproj"-
Open Grafana → Explore → select datasource Tempo
-
Find service
ydb-sdk-otel-trace-sample/ydb-sdk-otel-metrics-sampleand inspect spans such asapp.startup.
Tip: spans are also printed in otel-collector logs (the debug exporter is enabled).
The Logs/ example wires an OpenTelemetry-backed ILoggerFactory into the SDK via
YdbConnectionStringBuilder.LoggerFactory. Every internal SDK log (driver init, session
pool, query execution, retries, ...) is then exported to the collector as an OTLP log
record, which the collector forwards to Loki.
To inspect the logs:
-
Open Grafana → Explore → select datasource Loki
-
Query by service, e.g.
{service_name="ydb-sdk-otel-logs-sample"}
Tip: logs are also printed in otel-collector logs (the debug exporter is enabled).