Skip to content
Snippets Groups Projects
Commit f251e420 authored by ensiouel's avatar ensiouel
Browse files

fix typo

parent bf035609
No related branches found
No related tags found
No related merge requests found
...@@ -5,13 +5,13 @@ import ( ...@@ -5,13 +5,13 @@ import (
"git.perx.ru/perxis/perxis-go/pkg/metrics" "git.perx.ru/perxis/perxis-go/pkg/metrics"
"go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/attribute"
metricotel "go.opentelemetry.io/otel/metric" otelmetric "go.opentelemetry.io/otel/metric"
) )
type metricsMiddleware struct { type metricsMiddleware struct {
next Cache next Cache
cacheMetrics *metrics.CacheMetrics cacheMetrics *metrics.CacheMetrics
attributes metricotel.MeasurementOption attributes otelmetric.MeasurementOption
} }
// MetricsMiddleware возвращает обертку над кэшем, которая используется для отслеживания количества хитов и промахов в кэше. // MetricsMiddleware возвращает обертку над кэшем, которая используется для отслеживания количества хитов и промахов в кэше.
...@@ -19,7 +19,7 @@ func MetricsMiddleware(next Cache, cacheMetrics *metrics.CacheMetrics, keyValues ...@@ -19,7 +19,7 @@ func MetricsMiddleware(next Cache, cacheMetrics *metrics.CacheMetrics, keyValues
return &metricsMiddleware{ return &metricsMiddleware{
next: next, next: next,
cacheMetrics: cacheMetrics, cacheMetrics: cacheMetrics,
attributes: metricotel.WithAttributes(keyValues...), attributes: otelmetric.WithAttributes(keyValues...),
} }
} }
......
...@@ -2,34 +2,34 @@ package metrics ...@@ -2,34 +2,34 @@ package metrics
import ( import (
"go.opentelemetry.io/otel" "go.opentelemetry.io/otel"
metricotel "go.opentelemetry.io/otel/metric" otelmetric "go.opentelemetry.io/otel/metric"
) )
type CacheMetrics struct { type CacheMetrics struct {
HitsTotal metricotel.Int64Counter HitsTotal otelmetric.Int64Counter
MissesTotal metricotel.Int64Counter MissesTotal otelmetric.Int64Counter
InvalidatesTotal metricotel.Int64Counter InvalidatesTotal otelmetric.Int64Counter
} }
func NewCacheMetrics(scope string) (*CacheMetrics, error) { func NewCacheMetrics(scope string) (*CacheMetrics, error) {
meter := otel.Meter(scope) meter := otel.Meter(scope)
hitsTotal, err := meter.Int64Counter("cache_hits", hitsTotal, err := meter.Int64Counter("cache_hits",
metricotel.WithDescription("Количество найденных в кэше значений"), otelmetric.WithDescription("Количество найденных в кэше значений"),
) )
if err != nil { if err != nil {
return nil, err return nil, err
} }
missesTotal, err := meter.Int64Counter("cache_misses", missesTotal, err := meter.Int64Counter("cache_misses",
metricotel.WithDescription("Количество не найденных в кэше значений"), otelmetric.WithDescription("Количество не найденных в кэше значений"),
) )
if err != nil { if err != nil {
return nil, err return nil, err
} }
invalidatesTotal, err := meter.Int64Counter("cache_invalidates", invalidatesTotal, err := meter.Int64Counter("cache_invalidates",
metricotel.WithDescription("Количество инвалидаций кэша"), otelmetric.WithDescription("Количество инвалидаций кэша"),
) )
if err != nil { if err != nil {
return nil, err return nil, err
......
...@@ -2,13 +2,13 @@ package metrics ...@@ -2,13 +2,13 @@ package metrics
import ( import (
"go.opentelemetry.io/otel" "go.opentelemetry.io/otel"
metricotel "go.opentelemetry.io/otel/metric" otelmetric "go.opentelemetry.io/otel/metric"
) )
type RequestMetrics struct { type RequestMetrics struct {
Total metricotel.Int64Counter Total otelmetric.Int64Counter
FailedTotal metricotel.Int64Counter FailedTotal otelmetric.Int64Counter
DurationMilliseconds metricotel.Int64Histogram DurationMilliseconds otelmetric.Int64Histogram
} }
// NewRequestMetrics возвращает метрики для подсчета количества удачных/неудачных запросов, а так же длительности ответов. // NewRequestMetrics возвращает метрики для подсчета количества удачных/неудачных запросов, а так же длительности ответов.
...@@ -18,22 +18,22 @@ func NewRequestMetrics(scope string) (*RequestMetrics, error) { ...@@ -18,22 +18,22 @@ func NewRequestMetrics(scope string) (*RequestMetrics, error) {
meter := otel.Meter(scope) meter := otel.Meter(scope)
total, err := meter.Int64Counter("requests", total, err := meter.Int64Counter("requests",
metricotel.WithDescription("Количество запросов"), otelmetric.WithDescription("Количество запросов"),
) )
if err != nil { if err != nil {
return nil, err return nil, err
} }
failedTotal, err := meter.Int64Counter("requests_failed", failedTotal, err := meter.Int64Counter("requests_failed",
metricotel.WithDescription("Количество запросов, вернувших ошибку"), otelmetric.WithDescription("Количество запросов, вернувших ошибку"),
) )
if err != nil { if err != nil {
return nil, err return nil, err
} }
durationMilliseconds, err := meter.Int64Histogram("request_duration", durationMilliseconds, err := meter.Int64Histogram("request_duration",
metricotel.WithDescription("Длительность обработки запроса"), otelmetric.WithDescription("Длительность обработки запроса"),
metricotel.WithUnit("ms"), otelmetric.WithUnit("ms"),
) )
if err != nil { if err != nil {
return nil, err return nil, err
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment