Metrics Types
A metric in OTel will be one of the four types below.
Counter​
- A metric that only increases by a fixed value (usually 1)
- Ideal for representing cumulative events like the number of processed requests, errors that occurred, etc.
Can only be incremented, never decremented
Gauge​
- Represents a value that can go up or down freely.
- Useful for metrics that show a current state, such as memory in use, number of active connections, temperature, etc.
Can increase or decrease at any time
Histogram​
- Measures the distribution of values across a set of intervals.
- Allows calculating statistics such as mean, percentiles (p50, p95, p99).
- Widely used to measure response times, operation latencies
- Groups values into predefined buckets
UpDownCounter​
- Similar to Gauge, but with counter semantics.
- Can be incremented or decremented.
- Useful for representing metrics that can increase or decrease, maintaining a cumulative record.
Each type of metric serves a specific purpose and helps capture different aspects of a system's behavior and performance.
Knowing this, we can manually create metrics in our project.
It's important to remember that a metric can be handled with queries in prometheus, it's not necessary to reset a metric month by month, just get the metric range for 1 month.