Skip to content

nazarii-piontko/sample-dotnet-otel

Repository files navigation

Sample ASP.NET (.NET 8) project with OpenTelemetry integration

📡 OpenTelemetry

OpenTelemetry is a collection of tools, APIs, and SDKs to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) to help you analyze your software’s performance and behavior.

Links:

There is a .NET SDK that helps to integrate .NET applications with OpenTelemetry:

🎯 Goal

The goal of this project is to play around with exporting .NET service metrics to Prometheus, tracing service-to-service communication with Jaeger, and collecting logs with Loki using OpenTelementry .NET SDK.

📊 Components diagram

Components Diagram

Open in app.diagrams.net

🔍 Implementation details

Two .NET services have been implemented:

The first one is SampleDotNetOTEL.BusinessService. It exposes 3 endpoints:

  • Get fake auto-generated weather records from the database (PostgreSQL).
  • Get "Hello World" string
  • Get "Hello {USER_NAME}" string for the passed username parameter.

Also SampleDotNetOTEL.BusinessService has injected "faults" to simulate service errors.

And also SampleDotNetOTEL.BusinessService reads messages from RabbitMQ and logs them.

The second one is SampleDotNetOTEL.ProxyService. It exposes the same 3 endpoints as the first service but it just makes an HTTP request to SampleDotNetOTEL.BusinessService and forwards the response as it is. Also, it provides the fourth endpoint to POST message which will be queued to RabbitMQ and later read by SampleDotNetOTEL.BusinessService to log it.

All services could be run with docker-compose.

docker-compose.yml contains as one of the services a dummy client called spammer which makes requests to 3 endpoints every half a second.

🚀 How to run locally

📸 Screenshots

Jaeger

Jaeger trace

Jaeger trace for HTTP

Jaeger trace for HTTP

Jaeger trace for RabbitMQ

Jaeger trace for RabbitMQ

Jaeger monitor

Jaeger monitor

Grafana

Dashboard: https://grafana.com/grafana/dashboards/17706-asp-net-otel-metrics

Note: due to regular updates in OTEL metric names, ensure you download the appropriate dashboard revision.

Grafana dashboard part 1

Grafana dashboard part 2

🤝 How to Contribute

Interested in contributing? Check out our CONTRIBUTING.md for guidelines on how to make this project even better!