Adding Custom Metrics
In the previous chapter, we looked into manual distributed tracing instrumentation, which should help us debug individual operations or analyze service usage with ad hoc queries. Here, we’ll talk about metrics. First, we’ll learn when to use them, understand cardinality requirements, and then see how traces and metrics complement each other. We’ll explore the metrics API’s evolution in .NET and then spend most of this chapter talking about OpenTelemetry metrics. We’ll cover instruments such as counters, gauges, and histograms, and learn about each of them in depth.
We will cover the following topics in the chapter:
- The benefits, limitations, and evolution of metrics in .NET
- How and when to use different counters
- How to record and use gauges
- How to record value distribution with histograms
By the end of this chapter, you should be able to pick the right instrument for each scenario and implement and...