diff --git a/go.mod b/go.mod index 39147527..c7498ed6 100644 --- a/go.mod +++ b/go.mod @@ -8,8 +8,8 @@ require ( github.com/gin-gonic/gin v1.9.1 github.com/google/uuid v1.3.0 github.com/splitio/gincache v1.0.1 - github.com/splitio/go-split-commons/v5 v5.0.1-0.20231004184048-81902536fc1f - github.com/splitio/go-toolkit/v5 v5.3.2-0.20230920032539-d08915cf020a + github.com/splitio/go-split-commons/v5 v5.0.1-0.20231107204809-f5ccd6663702 + github.com/splitio/go-toolkit/v5 v5.3.2-0.20231106173125-49e72b9823dc github.com/stretchr/testify v1.8.4 go.etcd.io/bbolt v1.3.6 ) @@ -28,7 +28,6 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.14.0 // indirect github.com/goccy/go-json v0.10.2 // indirect - github.com/google/go-cmp v0.5.6 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/leodido/go-urn v1.2.4 // indirect @@ -43,9 +42,10 @@ require ( github.com/ugorji/go/codec v1.2.11 // indirect golang.org/x/arch v0.3.0 // indirect golang.org/x/crypto v0.9.0 // indirect + golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/net v0.10.0 // indirect golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.8.0 // indirect + golang.org/x/sys v0.13.0 // indirect golang.org/x/text v0.9.0 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index c2bebaeb..91e3a21b 100644 --- a/go.sum +++ b/go.sum @@ -48,8 +48,8 @@ github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -90,10 +90,10 @@ github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUA github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/splitio/gincache v1.0.1 h1:dLYdANY/BqH4KcUMCe/LluLyV5WtuE/LEdQWRE06IXU= github.com/splitio/gincache v1.0.1/go.mod h1:CcgJDSM9Af75kyBH0724v55URVwMBuSj5x1eCWIOECY= -github.com/splitio/go-split-commons/v5 v5.0.1-0.20231004184048-81902536fc1f h1:g3rsXA0cdMx2uz3MrTEz2tiittf+HDXpHooyYnuYg6w= -github.com/splitio/go-split-commons/v5 v5.0.1-0.20231004184048-81902536fc1f/go.mod h1:ksVZQYLs+3ZuzU81vEvf1aCjk24pdrVWjUXNq6Qcayo= -github.com/splitio/go-toolkit/v5 v5.3.2-0.20230920032539-d08915cf020a h1:2wjh5hSGlFRuh6Lbmodr0VRqtry2m9pEBNmwiLsY+ss= -github.com/splitio/go-toolkit/v5 v5.3.2-0.20230920032539-d08915cf020a/go.mod h1:xYhUvV1gga9/1029Wbp5pjnR6Cy8nvBpjw99wAbsMko= +github.com/splitio/go-split-commons/v5 v5.0.1-0.20231107204809-f5ccd6663702 h1:cwtkbzpL53TtVmWyE4o+JuT8KuDImvuZXscdKBR28/0= +github.com/splitio/go-split-commons/v5 v5.0.1-0.20231107204809-f5ccd6663702/go.mod h1:PSkBLDXQW7NAhZ7JO1va7QJyTeDvpE7MEDnTdn5evRM= +github.com/splitio/go-toolkit/v5 v5.3.2-0.20231106173125-49e72b9823dc h1:14jdJE/rBEYfs1CO8kOQrj/8azszRFU4yw5FQIGpoJg= +github.com/splitio/go-toolkit/v5 v5.3.2-0.20231106173125-49e72b9823dc/go.mod h1:xYhUvV1gga9/1029Wbp5pjnR6Cy8nvBpjw99wAbsMko= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= @@ -124,6 +124,8 @@ golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= @@ -136,15 +138,14 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= diff --git a/splitio/commitversion.go b/splitio/commitversion.go index 0d9c8362..3f4f64b9 100644 --- a/splitio/commitversion.go +++ b/splitio/commitversion.go @@ -5,4 +5,4 @@ This file is created automatically, please do not edit */ // CommitVersion is the version of the last commit previous to release -const CommitVersion = "4867a2d" +const CommitVersion = "ef035eb" diff --git a/splitio/producer/storage/telemetry.go b/splitio/producer/storage/telemetry.go index b3ba6494..27d9bbdb 100644 --- a/splitio/producer/storage/telemetry.go +++ b/splitio/producer/storage/telemetry.go @@ -177,11 +177,15 @@ func setLatency(result MultiMethodLatencies, metadata *dtos.Metadata, method str if _, ok := result[*metadata]; !ok { result[*metadata] = dtos.MethodLatencies{ - Treatment: make([]int64, telemetry.LatencyBucketCount), - Treatments: make([]int64, telemetry.LatencyBucketCount), - TreatmentWithConfig: make([]int64, telemetry.LatencyBucketCount), - TreatmentsWithConfig: make([]int64, telemetry.LatencyBucketCount), - Track: make([]int64, telemetry.LatencyBucketCount), + Treatment: make([]int64, telemetry.LatencyBucketCount), + Treatments: make([]int64, telemetry.LatencyBucketCount), + TreatmentWithConfig: make([]int64, telemetry.LatencyBucketCount), + TreatmentsWithConfig: make([]int64, telemetry.LatencyBucketCount), + TreatmentsByFlagSet: make([]int64, telemetry.LatencyBucketCount), + TreatmentsByFlagSets: make([]int64, telemetry.LatencyBucketCount), + TreatmentsWithConfigByFlagSet: make([]int64, telemetry.LatencyBucketCount), + TreatmentsWithConfigByFlagSets: make([]int64, telemetry.LatencyBucketCount), + Track: make([]int64, telemetry.LatencyBucketCount), } } @@ -194,6 +198,14 @@ func setLatency(result MultiMethodLatencies, metadata *dtos.Metadata, method str result[*metadata].TreatmentWithConfig[bucket] = count case telemetry.TreatmentsWithConfig: result[*metadata].TreatmentsWithConfig[bucket] = count + case telemetry.TreatmentsByFlagSet: + result[*metadata].TreatmentsByFlagSet[bucket] = count + case telemetry.TreatmentsByFlagSets: + result[*metadata].TreatmentsByFlagSets[bucket] = count + case telemetry.TreatmentsWithConfigByFlagSet: + result[*metadata].TreatmentsWithConfigByFlagSet[bucket] = count + case telemetry.TreatmentsWithConfigByFlagSets: + result[*metadata].TreatmentsWithConfigByFlagSets[bucket] = count case telemetry.Track: result[*metadata].Track[bucket] = count default: @@ -232,6 +244,14 @@ func setException(result MultiMethodExceptions, metadata *dtos.Metadata, method curr.TreatmentWithConfig = count case telemetry.TreatmentsWithConfig: curr.TreatmentsWithConfig = count + case telemetry.TreatmentsByFlagSet: + curr.TreatmentsByFlagSet = count + case telemetry.TreatmentsByFlagSets: + curr.TreatmentsByFlagSets = count + case telemetry.TreatmentsWithConfigByFlagSet: + curr.TreatmentsWithConfigByFlagSet = count + case telemetry.TreatmentsWithConfigByFlagSets: + curr.TreatmentsWithConfigByFlagSets = count case telemetry.Track: curr.Track = count default: diff --git a/splitio/producer/storage/telemetry_test.go b/splitio/producer/storage/telemetry_test.go index b93a12ab..c077384a 100644 --- a/splitio/producer/storage/telemetry_test.go +++ b/splitio/producer/storage/telemetry_test.go @@ -59,6 +59,20 @@ func TestRedisTelemetryExceptions(t *testing.T) { producer1.RecordException(telemetry.Treatment) producer1.RecordException(telemetry.Treatments) producer1.RecordException(telemetry.Treatments) + producer1.RecordException(telemetry.TreatmentsByFlagSet) + producer1.RecordException(telemetry.TreatmentsByFlagSet) + producer1.RecordException(telemetry.TreatmentsByFlagSet) + producer1.RecordException(telemetry.TreatmentsByFlagSet) + producer1.RecordException(telemetry.TreatmentsByFlagSets) + producer1.RecordException(telemetry.TreatmentsByFlagSets) + producer1.RecordException(telemetry.TreatmentsWithConfigByFlagSet) + producer1.RecordException(telemetry.TreatmentsWithConfigByFlagSet) + producer1.RecordException(telemetry.TreatmentsWithConfigByFlagSet) + producer1.RecordException(telemetry.TreatmentsWithConfigByFlagSets) + producer1.RecordException(telemetry.TreatmentsWithConfigByFlagSets) + producer1.RecordException(telemetry.TreatmentsWithConfigByFlagSets) + producer1.RecordException(telemetry.TreatmentsWithConfigByFlagSets) + producer1.RecordException(telemetry.TreatmentsWithConfigByFlagSets) producer1.RecordException(telemetry.TreatmentWithConfig) producer1.RecordException(telemetry.TreatmentWithConfig) producer1.RecordException(telemetry.TreatmentWithConfig) @@ -81,6 +95,16 @@ func TestRedisTelemetryExceptions(t *testing.T) { producer2.RecordException(telemetry.Treatments) producer2.RecordException(telemetry.Treatments) producer2.RecordException(telemetry.Treatments) + producer2.RecordException(telemetry.TreatmentsByFlagSet) + producer2.RecordException(telemetry.TreatmentsByFlagSet) + producer2.RecordException(telemetry.TreatmentsByFlagSet) + producer2.RecordException(telemetry.TreatmentsByFlagSets) + producer2.RecordException(telemetry.TreatmentsWithConfigByFlagSet) + producer2.RecordException(telemetry.TreatmentsWithConfigByFlagSet) + producer2.RecordException(telemetry.TreatmentsWithConfigByFlagSets) + producer2.RecordException(telemetry.TreatmentsWithConfigByFlagSets) + producer2.RecordException(telemetry.TreatmentsWithConfigByFlagSets) + producer2.RecordException(telemetry.TreatmentWithConfig) producer2.RecordException(telemetry.TreatmentWithConfig) producer2.RecordException(telemetry.TreatmentWithConfig) @@ -120,6 +144,22 @@ func TestRedisTelemetryExceptions(t *testing.T) { t.Error("exception count for track in metadata1 should be 5. Was: ", excsForM1.Track) } + if excsForM1.TreatmentsByFlagSet != 4 { + t.Error("exception count for treatmentsByFlagSet in metadata1 should be 4. Was: ", excsForM1.TreatmentsByFlagSet) + } + + if excsForM1.TreatmentsByFlagSets != 2 { + t.Error("exception count for treatmentsByFlagSets in metadata1 should be 2. Was: ", excsForM1.TreatmentsByFlagSets) + } + + if excsForM1.TreatmentsWithConfigByFlagSet != 3 { + t.Error("exception count for treatmentsWithConfigByFlagSet in metadata1 should be 3. Was: ", excsForM1.TreatmentsWithConfigByFlagSet) + } + + if excsForM1.TreatmentsWithConfigByFlagSets != 5 { + t.Error("exception count for treatmentsWithConfigByFlagSets in metadata1 should be 5. Was: ", excsForM1.TreatmentsWithConfigByFlagSets) + } + excsForM2, ok := exceptions[metadata2] if !ok { t.Error("exceptions for metadata2 should be present") @@ -145,6 +185,22 @@ func TestRedisTelemetryExceptions(t *testing.T) { t.Error("exception count for track in metadata1 should be 1. Was: ", excsForM2.Track) } + if excsForM2.TreatmentsByFlagSet != 3 { + t.Error("exception count for treatmentsByFlagSet in metadata2 should be 3. Was: ", excsForM2.TreatmentsByFlagSet) + } + + if excsForM2.TreatmentsByFlagSets != 1 { + t.Error("exception count for treatmentsByFlagSets in metadata2 should be 1. Was: ", excsForM2.TreatmentsByFlagSets) + } + + if excsForM2.TreatmentsWithConfigByFlagSet != 2 { + t.Error("exception count for treatmentsWithConfigByFlagSet in metadata2 should be 2. Was: ", excsForM2.TreatmentsWithConfigByFlagSet) + } + + if excsForM2.TreatmentsWithConfigByFlagSets != 3 { + t.Error("exception count for treatmentsWithConfigByFlagSets in metadata2 should be 3. Was: ", excsForM2.TreatmentsWithConfigByFlagSets) + } + exceptions = consumer.PopExceptions() if len(exceptions) > 0 { t.Error("no more exceptions should have been fetched from redis. Got:", exceptions) @@ -172,12 +228,24 @@ func TestRedisTelemetryLatencies(t *testing.T) { producer1.RecordLatency(telemetry.Treatments, 2*time.Second) producer1.RecordLatency(telemetry.TreatmentWithConfig, 3*time.Second) producer1.RecordLatency(telemetry.TreatmentsWithConfig, 4*time.Second) + producer1.RecordLatency(telemetry.TreatmentsByFlagSet, 2*time.Second) + producer1.RecordLatency(telemetry.TreatmentsByFlagSets, 4*time.Second) + producer1.RecordLatency(telemetry.TreatmentsWithConfigByFlagSet, 3*time.Second) + producer1.RecordLatency(telemetry.TreatmentsWithConfigByFlagSet, 6*time.Second) + producer1.RecordLatency(telemetry.TreatmentsWithConfigByFlagSets, 5*time.Second) producer1.RecordLatency(telemetry.Track, 5*time.Second) producer2.RecordLatency(telemetry.Treatment, 5*time.Second) producer2.RecordLatency(telemetry.Treatments, 4*time.Second) producer2.RecordLatency(telemetry.TreatmentWithConfig, 3*time.Second) producer2.RecordLatency(telemetry.TreatmentsWithConfig, 2*time.Second) + producer2.RecordLatency(telemetry.TreatmentsByFlagSet, 4*time.Second) + producer2.RecordLatency(telemetry.TreatmentsByFlagSet, 1*time.Second) + producer2.RecordLatency(telemetry.TreatmentsByFlagSets, 2*time.Second) + producer2.RecordLatency(telemetry.TreatmentsWithConfigByFlagSet, 5*time.Second) + producer2.RecordLatency(telemetry.TreatmentsWithConfigByFlagSets, 1*time.Second) + producer2.RecordLatency(telemetry.TreatmentsWithConfigByFlagSets, 2*time.Second) + producer2.RecordLatency(telemetry.TreatmentsWithConfigByFlagSets, 3*time.Second) producer2.RecordLatency(telemetry.Track, 1*time.Second) consumer := NewRedisTelemetryCosumerclient(client, logger) @@ -224,6 +292,38 @@ func TestRedisTelemetryLatencies(t *testing.T) { t.Error("latency count for .TreatmentsWithConfig should be 1. Is: ", l1TreatmentsWithConfig) } + l1TreatmentsByFlagSet := int64(0) + for _, count := range latsForM1.TreatmentsByFlagSet { + l1TreatmentsByFlagSet += count + } + if l1TreatmentsByFlagSet != int64(1) { + t.Error("latency count for .TreatmentsByFlagSet should be 1. Is: ", l1TreatmentsByFlagSet) + } + + l1TreatmentsByFlagSets := int64(0) + for _, count := range latsForM1.TreatmentsByFlagSets { + l1TreatmentsByFlagSets += count + } + if l1TreatmentsByFlagSets != int64(1) { + t.Error("latency count for .TreatmentsByFlagSet should be 1. Is: ", l1TreatmentsByFlagSets) + } + + l1TreatmentsWithConfigByFlagSet := int64(0) + for _, count := range latsForM1.TreatmentsWithConfigByFlagSet { + l1TreatmentsWithConfigByFlagSet += count + } + if l1TreatmentsWithConfigByFlagSet != int64(2) { + t.Error("latency count for .TreatmentsWithConfigByFlagSet should be 2. Is: ", l1TreatmentsWithConfigByFlagSet) + } + + l1TreatmentsWithConfigByFlagSets := int64(0) + for _, count := range latsForM1.TreatmentsWithConfigByFlagSets { + l1TreatmentsWithConfigByFlagSets += count + } + if l1TreatmentsWithConfigByFlagSets != int64(1) { + t.Error("latency count for .TreatmentsWithConfigByFlagSets should be 1. Is: ", l1TreatmentsWithConfigByFlagSets) + } + l1Track := int64(0) for _, count := range latsForM1.Track { l1Track += count @@ -269,6 +369,38 @@ func TestRedisTelemetryLatencies(t *testing.T) { t.Error("latency count for .TreatmentsWithConfig should be 1. Is: ", l2TreatmentsWithConfig) } + l2TreatmentsByFlagSet := int64(0) + for _, count := range latsForM2.TreatmentsByFlagSet { + l2TreatmentsByFlagSet += count + } + if l2TreatmentsByFlagSet != int64(2) { + t.Error("latency count for .TreatmentsByFlagSet should be 1. Is: ", l2TreatmentsByFlagSet) + } + + l2TreatmentsByFlagSets := int64(0) + for _, count := range latsForM2.TreatmentsByFlagSets { + l2TreatmentsByFlagSets += count + } + if l2TreatmentsByFlagSets != int64(1) { + t.Error("latency count for .TreatmentsByFlagSet should be 1. Is: ", l2TreatmentsByFlagSets) + } + + l2TreatmentsWithConfigByFlagSet := int64(0) + for _, count := range latsForM2.TreatmentsWithConfigByFlagSet { + l2TreatmentsWithConfigByFlagSet += count + } + if l2TreatmentsWithConfigByFlagSet != int64(1) { + t.Error("latency count for .TreatmentsWithConfigByFlagSet should be 1. Is: ", l2TreatmentsWithConfigByFlagSet) + } + + l2TreatmentsWithConfigByFlagSets := int64(0) + for _, count := range latsForM2.TreatmentsWithConfigByFlagSets { + l2TreatmentsWithConfigByFlagSets += count + } + if l2TreatmentsWithConfigByFlagSets != int64(3) { + t.Error("latency count for .TreatmentsWithConfigByFlagSets should be 3. Is: ", l2TreatmentsWithConfigByFlagSets) + } + l2Track := int64(0) for _, count := range latsForM2.Track { l2Track += count diff --git a/splitio/producer/worker/telemetry_test.go b/splitio/producer/worker/telemetry_test.go index 55d15ee4..72e4198d 100644 --- a/splitio/producer/worker/telemetry_test.go +++ b/splitio/producer/worker/telemetry_test.go @@ -27,14 +27,14 @@ func TestTelemetryMultiWorker(t *testing.T) { store := storageMocks.RedisTelemetryConsumerMultiMock{ PopLatenciesCall: func() storage.MultiMethodLatencies { return map[dtos.Metadata]dtos.MethodLatencies{ - metadata1: dtos.MethodLatencies{Treatment: makeBucket(1, 1)}, - metadata2: dtos.MethodLatencies{Treatment: makeBucket(2, 1)}, + metadata1: dtos.MethodLatencies{Treatment: makeBucket(1, 1), TreatmentsByFlagSet: makeBucket(1, 2), TreatmentsWithConfigByFlagSet: makeBucket(1, 3)}, + metadata2: dtos.MethodLatencies{Treatment: makeBucket(2, 1), TreatmentsByFlagSets: makeBucket(1, 3), TreatmentsWithConfigByFlagSets: makeBucket(1, 1)}, } }, PopExceptionsCall: func() storage.MultiMethodExceptions { return map[dtos.Metadata]dtos.MethodExceptions{ - metadata1: dtos.MethodExceptions{Treatment: 1}, - metadata2: dtos.MethodExceptions{Treatment: 2}, + metadata1: dtos.MethodExceptions{Treatment: 1, TreatmentsByFlagSet: 9, TreatmentsWithConfigByFlagSet: 12}, + metadata2: dtos.MethodExceptions{Treatment: 2, TreatmentsByFlagSets: 5, TreatmentsWithConfigByFlagSets: 13}, } }, PopConfigsCall: func() storage.MultiConfigs { @@ -64,16 +64,40 @@ func TestTelemetryMultiWorker(t *testing.T) { if l := stats.MethodLatencies.Treatment[1]; l != 1 { t.Error("invalid latency", l) } + if l := stats.MethodLatencies.TreatmentsByFlagSet[1]; l != 2 { + t.Error("invalid latency", l) + } + if l := stats.MethodLatencies.TreatmentsWithConfigByFlagSet[1]; l != 3 { + t.Error("invalid latency", l) + } if stats.MethodExceptions.Treatment != 1 { t.Error("invalid exception count") } + if stats.MethodExceptions.TreatmentsByFlagSet != 9 { + t.Error("invalid exception count") + } + if stats.MethodExceptions.TreatmentsWithConfigByFlagSet != 12 { + t.Error("invalid exception count") + } } else if metadata == metadata2 { if l := stats.MethodLatencies.Treatment[2]; l != 1 { t.Error("invalid latency", l) } + if l := stats.MethodLatencies.TreatmentsByFlagSets[1]; l != 3 { + t.Error("invalid latency", l) + } + if l := stats.MethodLatencies.TreatmentsWithConfigByFlagSets[1]; l != 1 { + t.Error("invalid latency", l) + } if stats.MethodExceptions.Treatment != 2 { t.Error("invalid exception count") } + if stats.MethodExceptions.TreatmentsByFlagSets != 5 { + t.Error("invalid exception count") + } + if stats.MethodExceptions.TreatmentsWithConfigByFlagSets != 13 { + t.Error("invalid exception count") + } } return nil }, diff --git a/splitio/proxy/storage/splits.go b/splitio/proxy/storage/splits.go index 5bf2d8d7..8af82321 100644 --- a/splitio/proxy/storage/splits.go +++ b/splitio/proxy/storage/splits.go @@ -40,6 +40,13 @@ type ProxySplitStorageImpl struct { mtx sync.Mutex } +// GetNamesByFlagSets implements storage.SplitStorage +func (*ProxySplitStorageImpl) GetNamesByFlagSets(sets []string) map[string][]string { + // NOTE: This method is NOT used by the proxy. + // we need to revisit our interfaces so that we're not obliged to do this smeely empty impls. + return nil +} + // NewProxySplitStorage instantiates a new proxy storage that wraps an in-memory snapshot of the last known, // flag configuration, a changes summaries containing recipes to update SDKs with different CNs, and a persistent storage // for snapshot purposes