Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-go
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
f251e420
Commit
f251e420
authored
1 year ago
by
ensiouel
Browse files
Options
Downloads
Patches
Plain Diff
fix typo
parent
bf035609
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pkg/cache/metrics_middleware.go
+3
-3
3 additions, 3 deletions
pkg/cache/metrics_middleware.go
pkg/metrics/cache.go
+7
-7
7 additions, 7 deletions
pkg/metrics/cache.go
pkg/metrics/request.go
+8
-8
8 additions, 8 deletions
pkg/metrics/request.go
with
18 additions
and
18 deletions
pkg/cache/metrics_middleware.go
+
3
−
3
View file @
f251e420
...
...
@@ -5,13 +5,13 @@ import (
"git.perx.ru/perxis/perxis-go/pkg/metrics"
"go.opentelemetry.io/otel/attribute"
metric
otel
"go.opentelemetry.io/otel/metric"
otel
metric
"go.opentelemetry.io/otel/metric"
)
type
metricsMiddleware
struct
{
next
Cache
cacheMetrics
*
metrics
.
CacheMetrics
attributes
metric
otel
.
MeasurementOption
attributes
otel
metric
.
MeasurementOption
}
// MetricsMiddleware возвращает обертку над кэшем, которая используется для отслеживания количества хитов и промахов в кэше.
...
...
@@ -19,7 +19,7 @@ func MetricsMiddleware(next Cache, cacheMetrics *metrics.CacheMetrics, keyValues
return
&
metricsMiddleware
{
next
:
next
,
cacheMetrics
:
cacheMetrics
,
attributes
:
metric
otel
.
WithAttributes
(
keyValues
...
),
attributes
:
otel
metric
.
WithAttributes
(
keyValues
...
),
}
}
...
...
This diff is collapsed.
Click to expand it.
pkg/metrics/cache.go
+
7
−
7
View file @
f251e420
...
...
@@ -2,34 +2,34 @@ package metrics
import
(
"go.opentelemetry.io/otel"
metric
otel
"go.opentelemetry.io/otel/metric"
otel
metric
"go.opentelemetry.io/otel/metric"
)
type
CacheMetrics
struct
{
HitsTotal
metric
otel
.
Int64Counter
MissesTotal
metric
otel
.
Int64Counter
InvalidatesTotal
metric
otel
.
Int64Counter
HitsTotal
otel
metric
.
Int64Counter
MissesTotal
otel
metric
.
Int64Counter
InvalidatesTotal
otel
metric
.
Int64Counter
}
func
NewCacheMetrics
(
scope
string
)
(
*
CacheMetrics
,
error
)
{
meter
:=
otel
.
Meter
(
scope
)
hitsTotal
,
err
:=
meter
.
Int64Counter
(
"cache_hits"
,
metric
otel
.
WithDescription
(
"Количество найденных в кэше значений"
),
otel
metric
.
WithDescription
(
"Количество найденных в кэше значений"
),
)
if
err
!=
nil
{
return
nil
,
err
}
missesTotal
,
err
:=
meter
.
Int64Counter
(
"cache_misses"
,
metric
otel
.
WithDescription
(
"Количество не найденных в кэше значений"
),
otel
metric
.
WithDescription
(
"Количество не найденных в кэше значений"
),
)
if
err
!=
nil
{
return
nil
,
err
}
invalidatesTotal
,
err
:=
meter
.
Int64Counter
(
"cache_invalidates"
,
metric
otel
.
WithDescription
(
"Количество инвалидаций кэша"
),
otel
metric
.
WithDescription
(
"Количество инвалидаций кэша"
),
)
if
err
!=
nil
{
return
nil
,
err
...
...
This diff is collapsed.
Click to expand it.
pkg/metrics/request.go
+
8
−
8
View file @
f251e420
...
...
@@ -2,13 +2,13 @@ package metrics
import
(
"go.opentelemetry.io/otel"
metric
otel
"go.opentelemetry.io/otel/metric"
otel
metric
"go.opentelemetry.io/otel/metric"
)
type
RequestMetrics
struct
{
Total
metric
otel
.
Int64Counter
FailedTotal
metric
otel
.
Int64Counter
DurationMilliseconds
metric
otel
.
Int64Histogram
Total
otel
metric
.
Int64Counter
FailedTotal
otel
metric
.
Int64Counter
DurationMilliseconds
otel
metric
.
Int64Histogram
}
// NewRequestMetrics возвращает метрики для подсчета количества удачных/неудачных запросов, а так же длительности ответов.
...
...
@@ -18,22 +18,22 @@ func NewRequestMetrics(scope string) (*RequestMetrics, error) {
meter
:=
otel
.
Meter
(
scope
)
total
,
err
:=
meter
.
Int64Counter
(
"requests"
,
metric
otel
.
WithDescription
(
"Количество запросов"
),
otel
metric
.
WithDescription
(
"Количество запросов"
),
)
if
err
!=
nil
{
return
nil
,
err
}
failedTotal
,
err
:=
meter
.
Int64Counter
(
"requests_failed"
,
metric
otel
.
WithDescription
(
"Количество запросов, вернувших ошибку"
),
otel
metric
.
WithDescription
(
"Количество запросов, вернувших ошибку"
),
)
if
err
!=
nil
{
return
nil
,
err
}
durationMilliseconds
,
err
:=
meter
.
Int64Histogram
(
"request_duration"
,
metric
otel
.
WithDescription
(
"Длительность обработки запроса"
),
metric
otel
.
WithUnit
(
"ms"
),
otel
metric
.
WithDescription
(
"Длительность обработки запроса"
),
otel
metric
.
WithUnit
(
"ms"
),
)
if
err
!=
nil
{
return
nil
,
err
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment