feat: implement observability and metrics (Task 22)
- Add metrics package tracking cache hit-rate, API quota, circuit breaker trips, search time - Integrate metrics with cache layer, yandex client, and API handlers - Add /metrics HTTP endpoint for Prometheus-compatible metrics exposure - Write tests for metrics functionality across cache, yandex, and API handlers - Update test files to support new metrics infrastructure
This commit is contained in:
@@ -5,20 +5,23 @@ import (
|
||||
"fmt"
|
||||
|
||||
"trip-planner/internal/cache"
|
||||
"trip-planner/internal/metrics"
|
||||
"trip-planner/internal/yandex"
|
||||
)
|
||||
|
||||
// SearchCacheService handles caching and on-demand Yandex /search calls.
|
||||
type SearchCacheService struct {
|
||||
cache *cache.CacheAside
|
||||
yclient *yandex.Client
|
||||
cache *cache.CacheAside
|
||||
yclient *yandex.Client
|
||||
metrics *metrics.Metrics
|
||||
}
|
||||
|
||||
// NewSearchCacheService creates a new search cache service.
|
||||
func NewSearchCacheService(cacheStore cache.Cache, yclient *yandex.Client) *SearchCacheService {
|
||||
func NewSearchCacheService(cacheStore cache.Cache, yclient *yandex.Client, m *metrics.Metrics) *SearchCacheService {
|
||||
return &SearchCacheService{
|
||||
cache: cache.NewCacheAside(cacheStore),
|
||||
cache: cache.NewCacheAside(cacheStore, m),
|
||||
yclient: yclient,
|
||||
metrics: m,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user