1\ Understanding the behavior and performance of your ASP.NET Core application are critical for ensuring its reliability and availability.
With the right tools, you can monitor key performance indicators, track error rates, and resource utilization.
2\ So what to measure exactly? π€
Everything. Any data can be viable and bring unique tech and business insights:
- System resources: RAM, CPU, Network, Disk, etc
- Endpoints: throughput, response time, error rate
- Status codes: 200, 500, etc
- Validation errors
3\ The industry has seen various ways of achieving that, from in-house-made solutions to AppMetrics.
Now the de-facto standard for it is OpenTelemetry.
4\ OpenTelemetry is an amazing collection of tools, APIs, and SDKs that can help you measure the performance of your web apps. With OpenTelemetry you can instrument, collect, generate, and export metrics, logs, and traces to gain valuable insights into the behavior of your code.
5\ Why OpenTelemetry is a real dealβ
- Open-source
- Standardized
- Vendor agnostic
- Tech agnostic (use it in any programming language or framework)
- Community
6\ That might sound so cool, so how to integrate it into an existing #aspnet web application?
βA couple of NuGet packages
βTen lines of code
Let's implement it. We're going to use OpenTelemeterty to collect metrics. Prometheus and Grafana to visualize it π
7\ That's the nuggets I use for this showcase.
But eventually, if you just search for OpenTelemetry you're going to find plenty more. Different instrumentation, exporters.
The controversial stuff - the ecosystem seems to be huge, but all of the packages are still pre-release
8\ With that setup, you're able to access the new endpoint "/metrics", which has all the data we're monitoring, in the Prometheus format.
Let's see how it looks π
9\ Last step - visualisation.
For it, you can use any tools you like, I'll stick to #grafana and #prometheus.
They're easy to set up with docker, and much fun to work with π
10\ A little bit more configuration and that's the result π
All the data is on one dashboard, easy to navigate, and easy to observe. #grafana dashboards are configurable, so you might customize them according to your needs.
11\ In conclusion, if you're looking for a powerful and flexible solution for observability in ASP.NET Core, look no further than OpenTelemetry. With its rich set of features, community support, and commitment to open standards, it's just the best choice
BTW, this thread and overall investigation about OpenTelemetery was highly inspired by @davidfowl short tweet
@davidfowl If you find this thread insightful consider liking, RT, and subscribing. I regularly write about different ASP.NET tips and techniques, so don't miss it! π
β’ β’ β’
Missing some Tweet in this thread? You can try to
force a refresh
You've got health checks in place. With just one HTTP call you can check if an app is healthy.
So how do you make it automatic, so you'll be the first to know if the system goes down?
1\ With the rise of distributed systems, it's increasingly important to have a robust monitoring solution in place. Health checks allow you to monitor the health of your apps and detect any issues before they escalate.
And then it has to be monitored all the time.
2\ The benefits of continuous monitoring and alerting are numerous. It allows you to detect issues early, minimize downtime, and improve user experience. It also helps you respond quickly to incidents and resolve them before they become bigger problems.