Repository navigation
Expand file tree
/
Copy pathmanager.go
More file actions
68 lines (61 loc) · 2.27 KB
/
Copy pathmanager.go
File metadata and controls
68 lines (61 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package stats
import (
gostats "github.com/lyft/gostats"
)
// Manager is the interface that wraps initialization of stat structures.
type Manager interface {
// NewStats provides a RateLimitStats structure associated with a given descriptorKey.
// Multiple calls with the same descriptorKey argument are guaranteed to be equivalent.
NewStats(descriptorKey string) RateLimitStats
// Gets stats for a domain (when no descriptors are found)
// Multiple calls with the same domain argument are guaranteed to be equivalent.
NewDomainStats(domain string) DomainStats
// Initializes a ShouldRateLimitStats structure.
// Multiple calls to this method are idempotent.
NewShouldRateLimitStats() ShouldRateLimitStats
// Initializes a ServiceStats structure.
// Multiple calls to this method are idempotent.
NewServiceStats() ServiceStats
// Returns the stats.Store wrapped by the Manager.
GetStatsStore() gostats.Store
// SanitizeDescriptorMetricDots reports whether '.' in descriptor keys/values should be
// replaced with '_' when building metric names (SANITIZE_DESCRIPTOR_METRIC_DOTS).
SanitizeDescriptorMetricDots() bool
}
type ManagerImpl struct {
store gostats.Store
rlStatsScope gostats.Scope
serviceStatsScope gostats.Scope
shouldRateLimitScope gostats.Scope
sanitizeDescriptorMetricDots bool
}
// Stats for panic recoveries.
// Identifies if a recovered panic is a redis.RedisError or a ServiceError.
type ShouldRateLimitStats struct {
RedisError gostats.Counter
ServiceError gostats.Counter
}
// Stats for server errors.
// Keeps failure and success metrics.
type ServiceStats struct {
ConfigLoadSuccess gostats.Counter
ConfigLoadError gostats.Counter
ShouldRateLimit ShouldRateLimitStats
GlobalShadowMode gostats.Counter
}
// Stats for an individual rate limit config entry.
type RateLimitStats struct {
Key string
TotalHits gostats.Counter
OverLimit gostats.Counter
NearLimit gostats.Counter
OverLimitWithLocalCache gostats.Counter
WithinLimit gostats.Counter
ShadowMode gostats.Counter
TotalNegativeHits gostats.Counter
}
// Stats for a domain entry
type DomainStats struct {
Key string
NotFound gostats.Counter
}