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

fix

parent 6845af08
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ type CacheMetrics struct { ...@@ -14,7 +14,7 @@ type CacheMetrics struct {
func NewCacheMetrics(scope string) (*CacheMetrics, error) { func NewCacheMetrics(scope string) (*CacheMetrics, error) {
var ( var (
meter = otel.Meter(scope) meter = otel.Meter(scope)
cacheMetrics *CacheMetrics cacheMetrics = new(CacheMetrics)
err error err error
) )
......
...@@ -15,33 +15,30 @@ type RequestMetrics struct { ...@@ -15,33 +15,30 @@ type RequestMetrics struct {
// //
// Для RequestMetrics.DurationMilliseconds значения buckets по умолчанию равно []float64{0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000} // Для RequestMetrics.DurationMilliseconds значения buckets по умолчанию равно []float64{0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000}
func NewRequestMetrics(scope string) (*RequestMetrics, error) { func NewRequestMetrics(scope string) (*RequestMetrics, error) {
meter := otel.Meter(scope) var (
meter = otel.Meter(scope)
requestMetrics = new(RequestMetrics)
err error
)
total, err := meter.Int64Counter("requests", if requestMetrics.Total, err = meter.Int64Counter("requests",
otelmetric.WithDescription("Количество запросов"), otelmetric.WithDescription("Количество запросов"),
) ); err != nil {
if err != nil {
return nil, err return nil, err
} }
failedTotal, err := meter.Int64Counter("requests_failed", if requestMetrics.FailedTotal, err = meter.Int64Counter("requests_failed",
otelmetric.WithDescription("Количество запросов, вернувших ошибку"), otelmetric.WithDescription("Количество запросов, вернувших ошибку"),
) ); err != nil {
if err != nil {
return nil, err return nil, err
} }
durationMilliseconds, err := meter.Int64Histogram("request_duration", if requestMetrics.DurationMilliseconds, err = meter.Int64Histogram("request_duration",
otelmetric.WithDescription("Длительность обработки запроса"), otelmetric.WithDescription("Длительность обработки запроса"),
otelmetric.WithUnit("ms"), otelmetric.WithUnit("ms"),
) ); err != nil {
if err != nil {
return nil, err return nil, err
} }
return &RequestMetrics{ return requestMetrics, nil
Total: total,
FailedTotal: failedTotal,
DurationMilliseconds: durationMilliseconds,
}, nil
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment