.NET OpenTelemetry Demo

Made in Ukraine Build status

Terms of use

By using this project or its source code, for any purpose and in any shape or form, you grant your implicit agreement to all the following statements:

  • You condemn Russia and its military aggression against Ukraine
  • You recognize that Russia is an occupant that unlawfully invaded a sovereign state
  • You support Ukraine's territorial integrity, including its claims over temporarily occupied territories of Crimea and Donbas
  • You reject false narratives perpetuated by Russian state propaganda

Glory to Ukraine! 🇺🇦

Table of contents

Project description

This project contains example of using OpenTelemetry with .NET web applications. It uses OTEL Collector and Grafana OSS backend for dealing with data.

It consists of:

Solution consists of multiple services that use common infrastructure building blocks:

Solution architecture

Architecture diagram

How to run?

You could run solution fully in containers, using

docker compose up --build -d

Or bump infrastructure up in containers with docker compose and run standalone projects in your IDE.

In both cases entry point will be available by address http://localhost:5200/swagger

Services overview

Alpha

Aggregating service. Available on http://localhost:5201 or via API gateway on http://localhost:5200/alpha.

Under the hood it does two requests to Epsilon service, using Refit and Mu, using MassTransit's request/response feature. It is a good entrypoint to look how request will be routed through the system components.

Epsilon

Service that uses Elasticsearch. Available on http://localhost:5204 or via API gateway on http://localhost:5200/epsilon.

Data in elastic index is seeded on service launch. Currently it contains a single document, extracted by a simple filter.

Mu

Service built over MassTransit. Available on http://localhost:5203 or via API gateway on http://localhost:5200/mu.

Exposes two endpoints for sending command and publishing event. Handlers, receives this messages are in this service. Also has a handler for responding to Alpha's request via MassTransit.

Nu

Service that uses MongoDB. Available on http://localhost:5205 or via API gateway on http://localhost:5200/nu.

Data in MongoDB is seeded on service launch. Currently it contains a single document, extracted by a simple filter.

Omicron

API Gateway build with Ocelot. Acts as a reverse proxy. Available on http://localhost:5200. Also aggregates downstream services' swagger docs, using SwaggerForOcelot project.

Exposes aggregated Swagger UI & Swagger Doc on http://localhost:5200/swagger.

Sigma

Service that uses PostgreSQL and Redis. Available on http://localhost:5202 or via API gateway on http://localhost:5200/sigma.

Exposes 3 endpoints:

  • Getting entity by id. Using Redis over IDistributedCache for searching. If entity is not found - goes to SQL with EF Core
  • Getting all entities. Loads them from SQL with Dapper
  • Creating entity. Entity is created in SQL with EF Core.

Data flows

  • Logs. Are passed directly to Loki, using corresponding Serilog's sink.
  • Metrics. Are exported to OTEL and scrapped by Prometheus from it.
  • Traces. Are exported to OTEL and passed to Tempo by OTEL.

Contributing

Contributing is welcomed here. If it is something standalone (i.e. GRPC), feel free to add a new service. It is preferable to use a corresponding letter of greek alphabet (like Gamma for GRPC). Also if it is something small, it could be appended to the existing service.