Commit ce86459 1 parent b7fcf2b commit ce86459 Copy full SHA for ce86459
File tree 1 file changed +13
-3
lines changed
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,20 @@ package ingester
3
3
import (
4
4
"sync"
5
5
6
- "github.com/grafana/dskit/services"
6
+ "github.com/prometheus/client_golang/prometheus"
7
+ "github.com/prometheus/client_golang/prometheus/promauto"
7
8
"go.uber.org/atomic"
9
+
10
+ "github.com/grafana/loki/v3/pkg/util/constants"
8
11
)
9
12
10
- type ownedStreamService struct {
11
- services.Service
13
+ var notOwnedStreamsMetric = promauto .NewGaugeVec (prometheus.GaugeOpts {
14
+ Namespace : constants .Loki ,
15
+ Name : "ingester_not_owned_streams" ,
16
+ Help : "The total number of not owned streams in memory per tenant." ,
17
+ }, []string {"tenant" })
12
18
19
+ type ownedStreamService struct {
13
20
tenantID string
14
21
limiter * Limiter
15
22
fixedLimit * atomic.Int32
@@ -53,13 +60,15 @@ func (s *ownedStreamService) incOwnedStreamCount() {
53
60
func (s * ownedStreamService ) incNotOwnedStreamCount () {
54
61
s .lock .Lock ()
55
62
defer s .lock .Unlock ()
63
+ notOwnedStreamsMetric .WithLabelValues (s .tenantID ).Inc ()
56
64
s .notOwnedStreamCount ++
57
65
}
58
66
59
67
func (s * ownedStreamService ) decOwnedStreamCount () {
60
68
s .lock .Lock ()
61
69
defer s .lock .Unlock ()
62
70
if s .notOwnedStreamCount > 0 {
71
+ notOwnedStreamsMetric .WithLabelValues (s .tenantID ).Dec ()
63
72
s .notOwnedStreamCount --
64
73
return
65
74
}
@@ -71,4 +80,5 @@ func (s *ownedStreamService) resetStreamCounts() {
71
80
defer s .lock .Unlock ()
72
81
s .ownedStreamCount = 0
73
82
s .notOwnedStreamCount = 0
83
+ notOwnedStreamsMetric .WithLabelValues (s .tenantID ).Set (0 )
74
84
}
You can’t perform that action at this time.
0 commit comments