Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nazarii-piontko/sample-dotnet-otel
Sample ASP.NET (.NET 8) project with OpenTelemetry integration
https://github.com/nazarii-piontko/sample-dotnet-otel
dotnet grafana jaeger loki metrics monitoring observability opentelemetry otel prometheus telemetry
Last synced: about 11 hours ago
JSON representation
Sample ASP.NET (.NET 8) project with OpenTelemetry integration
- Host: GitHub
- URL: https://github.com/nazarii-piontko/sample-dotnet-otel
- Owner: nazarii-piontko
- License: mit
- Created: 2022-12-27T13:54:47.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-20T20:35:24.000Z (about 1 year ago)
- Last Synced: 2024-01-29T11:14:31.690Z (12 months ago)
- Topics: dotnet, grafana, jaeger, loki, metrics, monitoring, observability, opentelemetry, otel, prometheus, telemetry
- Language: C#
- Homepage:
- Size: 1.54 MB
- Stars: 52
- Watchers: 3
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
* https://opentelemetry.io/
* https://opentelemetry.io/docs/There is a .NET SDK that helps to integrate .NET applications with OpenTelemetry:
* https://opentelemetry.io/docs/instrumentation/net/getting-started/
* https://github.com/open-telemetry/opentelemetry-dotnet
* https://www.nuget.org/packages/OpenTelemetry/## π― Goal
The goal of this project is to play around with exporting .NET service metrics to [Prometheus](https://prometheus.io/), tracing service-to-service communication with [Jaeger](https://www.jaegertracing.io/), and collecting logs with [Loki](https://grafana.com/oss/loki/) using OpenTelementry .NET SDK.
## π Components diagram
![Components Diagram](Images/Diagram.png)
[Open in app.diagrams.net](https://viewer.diagrams.net/?url=https://raw.githubusercontent.com/nazarii-piontko/sample-dotnet-otel/main/Diagram.xml)
## π 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
* Ensure you have `Docker` installed and running.
* Ensure you have `docker-compose` installed.
* Run `docker-compose build`
* Run `docker-compose up`
* As soon as `docker-compose` starts services they should be available via HTTP. Here are some links:
* Grafana pre-build dashboard should be accessible via http://localhost:3000/d/KdDACDp4z/asp-net-otel-metrics
* Jaeger should be accessible via http://localhost:16686/search
* Prometheus should be accessible via http://localhost:9090/graph
* Proxy service should be accessible via http://localhost:8080/hello## πΈ Screenshots
### Jaeger
#### Jaeger trace
##### Jaeger trace for HTTP
![Jaeger trace for HTTP](Images/JaegerTraceHTTP.png)##### Jaeger trace for RabbitMQ
![Jaeger trace for RabbitMQ](Images/JaegerTraceRabbitMQ.png)#### Jaeger monitor
![Jaeger monitor](Images/JaegerMonitor.png)
### 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](Images/GrafanaOTELMetrics1.png)
![Grafana dashboard part 2](Images/GrafanaOTELMetrics2.png)
## π€ How to Contribute
Interested in contributing? Check out our [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to make this project even better!