Pattern: Application metrics
pattern observability service designContext
You have applied the Microservice architecture pattern.
Problem
How to understand the behavior of an application and troubleshoot problems?
Forces
- Any solution should have minimal runtime overhead
Solution
Instrument a service to gather statistics about individual operations. Aggregate metrics in centralized metrics service, which provides reporting and alerting. There are two models for aggregating metrics:
- push - the service pushes metrics to the metrics service
- pull - the metrics services pulls metrics from the service
Examples
- Instrumentation libraries:
- Coda Hale/Yammer Java Metrics Library
- Prometheus client libraries
- Metrics aggregation services
Resulting context
This pattern has the following benefits:
- It provides deep insight into application behavior
This pattern has the following drawbacks:
- Metrics code is intertwined with business logic making it more complicated
This pattern has the following issues:
- Aggregating metrics can require significant infrastructure