@@ -78,7 +78,7 @@ var NilMetrics = newIngesterMetrics(nil, constants.Loki)
78
78
func TestLabelsCollisions (t * testing.T ) {
79
79
limits , err := validation .NewOverrides (defaultLimitsTestConfig (), nil )
80
80
require .NoError (t , err )
81
- limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ))
81
+ limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ), & TenantBasedStrategy { limits : limits } )
82
82
83
83
i , err := newInstance (defaultConfig (), defaultPeriodConfigs , "test" , limiter , loki_runtime .DefaultTenantConfigs (), noopWAL {}, NilMetrics , & OnceSwitch {}, nil , nil , nil , NewStreamRateCalculator (), nil , nil )
84
84
require .Nil (t , err )
@@ -106,7 +106,7 @@ func TestLabelsCollisions(t *testing.T) {
106
106
func TestConcurrentPushes (t * testing.T ) {
107
107
limits , err := validation .NewOverrides (defaultLimitsTestConfig (), nil )
108
108
require .NoError (t , err )
109
- limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ))
109
+ limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ), & TenantBasedStrategy { limits : limits } )
110
110
111
111
inst , err := newInstance (defaultConfig (), defaultPeriodConfigs , "test" , limiter , loki_runtime .DefaultTenantConfigs (), noopWAL {}, NilMetrics , & OnceSwitch {}, nil , nil , nil , NewStreamRateCalculator (), nil , nil )
112
112
require .Nil (t , err )
@@ -158,7 +158,7 @@ func TestConcurrentPushes(t *testing.T) {
158
158
func TestGetStreamRates (t * testing.T ) {
159
159
limits , err := validation .NewOverrides (defaultLimitsTestConfig (), nil )
160
160
require .NoError (t , err )
161
- limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ))
161
+ limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ), & TenantBasedStrategy { limits : limits } )
162
162
163
163
inst , err := newInstance (defaultConfig (), defaultPeriodConfigs , "test" , limiter , loki_runtime .DefaultTenantConfigs (), noopWAL {}, NilMetrics , & OnceSwitch {}, nil , nil , nil , NewStreamRateCalculator (), nil , nil )
164
164
require .NoError (t , err )
@@ -245,7 +245,7 @@ func labelHashNoShard(l labels.Labels) uint64 {
245
245
func TestSyncPeriod (t * testing.T ) {
246
246
limits , err := validation .NewOverrides (defaultLimitsTestConfig (), nil )
247
247
require .NoError (t , err )
248
- limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ))
248
+ limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ), & TenantBasedStrategy { limits : limits } )
249
249
250
250
const (
251
251
syncPeriod = 1 * time .Minute
@@ -290,7 +290,7 @@ func setupTestStreams(t *testing.T) (*instance, time.Time, int) {
290
290
t .Helper ()
291
291
limits , err := validation .NewOverrides (defaultLimitsTestConfig (), nil )
292
292
require .NoError (t , err )
293
- limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ))
293
+ limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ), & TenantBasedStrategy { limits : limits } )
294
294
indexShards := 2
295
295
296
296
// just some random values
@@ -315,7 +315,7 @@ func setupTestStreams(t *testing.T) (*instance, time.Time, int) {
315
315
require .NoError (t , err )
316
316
chunkfmt , headfmt , err := instance .chunkFormatAt (minTs (& testStream ))
317
317
require .NoError (t , err )
318
- chunk := newStream (chunkfmt , headfmt , cfg , limiter , "fake" , 0 , nil , true , NewStreamRateCalculator (), NilMetrics , nil , nil ).NewChunk ()
318
+ chunk := newStream (chunkfmt , headfmt , cfg , limiter . rateLimitStrategy , "fake" , 0 , nil , true , NewStreamRateCalculator (), NilMetrics , nil , nil ).NewChunk ()
319
319
for _ , entry := range testStream .Entries {
320
320
dup , err := chunk .Append (& entry )
321
321
require .False (t , dup )
@@ -507,7 +507,7 @@ func makeRandomLabels() labels.Labels {
507
507
func Benchmark_PushInstance (b * testing.B ) {
508
508
limits , err := validation .NewOverrides (defaultLimitsTestConfig (), nil )
509
509
require .NoError (b , err )
510
- limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ))
510
+ limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ), & TenantBasedStrategy { limits : limits } )
511
511
512
512
i , _ := newInstance (& Config {IndexShards : 1 }, defaultPeriodConfigs , "test" , limiter , loki_runtime .DefaultTenantConfigs (), noopWAL {}, NilMetrics , & OnceSwitch {}, nil , nil , nil , NewStreamRateCalculator (), nil , nil )
513
513
ctx := context .Background ()
@@ -549,7 +549,7 @@ func Benchmark_instance_addNewTailer(b *testing.B) {
549
549
l .MaxLocalStreamsPerUser = 100000
550
550
limits , err := validation .NewOverrides (l , nil )
551
551
require .NoError (b , err )
552
- limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ))
552
+ limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ), & TenantBasedStrategy { limits : limits } )
553
553
554
554
ctx := context .Background ()
555
555
@@ -575,7 +575,7 @@ func Benchmark_instance_addNewTailer(b *testing.B) {
575
575
576
576
b .Run ("addTailersToNewStream" , func (b * testing.B ) {
577
577
for n := 0 ; n < b .N ; n ++ {
578
- inst .addTailersToNewStream (newStream (chunkfmt , headfmt , nil , limiter , "fake" , 0 , lbs , true , NewStreamRateCalculator (), NilMetrics , nil , nil ))
578
+ inst .addTailersToNewStream (newStream (chunkfmt , headfmt , nil , limiter . rateLimitStrategy , "fake" , 0 , lbs , true , NewStreamRateCalculator (), NilMetrics , nil , nil ))
579
579
}
580
580
})
581
581
}
@@ -1089,7 +1089,7 @@ func TestStreamShardingUsage(t *testing.T) {
1089
1089
limits , err := validation .NewOverrides (defaultLimitsTestConfig (), limitsDefinition )
1090
1090
require .NoError (t , err )
1091
1091
1092
- limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ))
1092
+ limiter := NewLimiter (limits , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ), & TenantBasedStrategy { limits : limits } )
1093
1093
1094
1094
defaultShardStreamsCfg := limiter .limits .ShardStreams ("fake" )
1095
1095
tenantShardStreamsCfg := limiter .limits .ShardStreams (customTenant1 )
@@ -1454,7 +1454,7 @@ func defaultInstance(t *testing.T) *instance {
1454
1454
& ingesterConfig ,
1455
1455
defaultPeriodConfigs ,
1456
1456
"fake" ,
1457
- NewLimiter (overrides , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 )),
1457
+ NewLimiter (overrides , NilMetrics , newIngesterRingLimiterStrategy (& ringCountMock {count : 1 }, 1 ), & TenantBasedStrategy { limits : overrides } ),
1458
1458
loki_runtime .DefaultTenantConfigs (),
1459
1459
noopWAL {},
1460
1460
NilMetrics ,
0 commit comments