Skip to content

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Distributed Tracing in .NET with OpenTelemetry and ClickStack

Two ASP.NET services instrumented with OpenTelemetry, shipping traces, logs, and metrics to ClickStack.

Companion demo to the Structured Logging with Serilog and ClickHouse blog post. That demo showed "bring your own schema, write directly to ClickHouse via Serilog"; this one shows "use the standard OTel pipeline and let ClickStack light up automatically."

Architecture

┌─────────────┐     HTTP      ┌──────────────────┐
│  Order API  │──────────────▶│ Payment Service  │
│  :5000      │               │  :5001           │
└──────┬──────┘               └────────┬─────────┘
       │ OTLP/gRPC                     │ OTLP/gRPC
       │                               │
       ▼                               ▼
┌──────────────────────────────────────────────────┐
│              ClickStack  :8080                   │
│  (OTel Collector → ClickHouse → UI)              │
└──────────────────────────────────────────────────┘

Both services export traces, logs, and metrics via OTLP/gRPC to ClickStack's built-in OpenTelemetry collector.

Quick Start

docker compose up -d

Wait for all services to start (~30s), then:

The seed-data container automatically generates traffic on startup.

Endpoints

Order API (port 5000)

Method Path Description
POST /orders Place a new order
GET /orders/{id} Get order by ID
GET /products List all products
GET /products/{id} Get product by ID
GET /health Health check
POST /generate-traffic Generate sample traffic

Payment Service (port 5001)

Method Path Description
POST /payments Process a payment
GET /payments/{id} Get payment by ID
GET /health Health check

Experimentation

Place an order

curl -X POST http://localhost:5000/orders \
  -H 'Content-Type: application/json' \
  -d '{"userId":"test","productId":1,"quantity":1,"paymentMethod":"credit_card"}'

Try out-of-stock product (product 4)

curl -X POST http://localhost:5000/orders \
  -H 'Content-Type: application/json' \
  -d '{"userId":"test","productId":4,"quantity":1,"paymentMethod":"credit_card"}'

Generate more traffic

curl -X POST http://localhost:5000/generate-traffic

What to Explore in ClickStack

  1. Service Map — see order-api → payment-service dependency
  2. Distributed Traces — click a trace to see spans across both services
  3. Error Traces — filter for error traces to see timeouts and failures
  4. Log-to-Trace — click a log entry to jump to its parent trace
  5. Metrics — view orders.placed, payments.processed, and HTTP metrics

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages