---
title: "Logging, Metrics, and Distributed Tracing in .NET with OpenTelemetry and ClickStack"
description: "The post presents a walkthrough of instrumenting two ASP.NET services—an Order API and a Payment Service—with OpenTelemetry and sending traces, logs, and metrics to ClickStack. The demo uses SQLite for persistence, with Entity Framework Core instrumentation capturing database operations without manually creating spans. The configuration adds ASP.NET, HTTP client, and EF Core instrumentation, custom sources and meters, OpenTelemetry logging, and OTLP/gRPC exporters directed by OTEL_EXPORTER_OTLP_ENDPOINT. In ClickStack, the signals are correlated so a request can be followed across service boundaries, application work, and database calls, while the UI and ClickHouse SQL provide exploration options. The conclusion is that a relatively small ASP.NET setup replaces isolated timeout logs with an end-to-end view of timing, errors, logs, and database activity."
---

# Logging, Metrics, and Distributed Tracing in .NET with OpenTelemetry and ClickStack

[Clickhouse](https://yomu.fyi/company/clickhouse) · Jun 3, 2026

**Type:** Tutorial

## Summary

The post presents a walkthrough of instrumenting two ASP.NET services—an Order API and a Payment Service—with OpenTelemetry and sending traces, logs, and metrics to ClickStack. The demo uses SQLite for persistence, with Entity Framework Core instrumentation capturing database operations without manually creating spans. The configuration adds ASP.NET, HTTP client, and EF Core instrumentation, custom sources and meters, OpenTelemetry logging, and OTLP/gRPC exporters directed by OTEL\_EXPORTER\_OTLP\_ENDPOINT. In ClickStack, the signals are correlated so a request can be followed across service boundaries, application work, and database calls, while the UI and ClickHouse SQL provide exploration options. The conclusion is that a relatively small ASP.NET setup replaces isolated timeout logs with an end-to-end view of timing, errors, logs, and database activity.

## Context

A single timeout log does not reveal which service failed or where time was spent. The walkthrough addresses this by showing how distributed tracing can connect activity across the Order API, Payment Service, HTTP calls, application work, and database operations.

## Approach / What changed

The demo runs ClickStack and two ASP.NET services in Docker Compose. OpenTelemetry captures incoming and outgoing HTTP requests, Entity Framework Core database operations, custom spans, metrics, and logs, then exports all three signals through OTLP/gRPC to ClickStack. ClickStack stores the telemetry in ClickHouse and provides correlated exploration through its UI and SQL access.

## Takeaways

- Entity Framework Core instrumentation makes SQLite database operations appear as telemetry spans without manual span creation.
- AddAspNetCoreInstrumentation, AddHttpClientInstrumentation, and AddEntityFrameworkCoreInstrumentation cover incoming HTTP requests, outgoing HTTP calls, and database operations.
- ClickStack correlates traces, logs, and metrics, allowing a request to be followed across services and database calls under one trace ID.

**Tags:** [Docker](https://yomu.fyi/topic/docker), [Observability](https://yomu.fyi/topic/observability)

- Source: [Clickhouse](https://clickhouse.com/blog/logging-metrics-distributed-tracing-dotnet-otel-clickstack)
- Source URL: https://clickhouse.com/blog/logging-metrics-distributed-tracing-dotnet-otel-clickstack
- Ingested by Yomu: 2026-08-29T01:34:13.003Z

[Read original post](https://clickhouse.com/blog/logging-metrics-distributed-tracing-dotnet-otel-clickstack)
