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:
2026-08-17 15:27:44 +03:00
parent 5842667fff
commit c58fbb50b1
10 changed files with 285 additions and 55 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/go-redis/redis/v8"
"trip-planner/internal/metrics"
"trip-planner/internal/airports"
"trip-planner/internal/routing"
"trip-planner/internal/storage"
@@ -54,7 +55,7 @@ func newMockHandlerContext() *HandlerContext {
// Create Yandex client
yandexClient := yandex.NewClient("test-key")
return NewHandlerContext(redisClient, router, yandexClient)
return NewHandlerContext(redisClient, router, yandexClient, metrics.New())
}
func TestHandlerCityAutocomplete(t *testing.T) {