Skip to content

Commit

Permalink
[SDKS-7625] Add feature flag name in ready warning log
Browse files Browse the repository at this point in the history
  • Loading branch information
nmayorsplit committed Nov 21, 2023
1 parent 034bc58 commit 457e396
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions splitio/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"runtime/debug"
"strings"
"time"

"github.com/splitio/go-client/v6/splitio/conf"
Expand Down Expand Up @@ -57,7 +58,8 @@ func (c *SplitClient) getEvaluationResult(matchingKey string, bucketingKey *stri
if c.isReady() {
return c.evaluator.EvaluateFeature(matchingKey, bucketingKey, featureFlag, attributes)
}
c.logger.Warning(operation + ": the SDK is not ready, results may be incorrect. Make sure to wait for SDK readiness before using this method")

c.logger.Warning(fmt.Sprintf("%s: the SDK is not ready, results may be incorrect for feature flag %s. Make sure to wait for SDK readiness before using this method", operation, featureFlag))
c.initTelemetry.RecordNonReadyUsage()
return &evaluator.Result{
Treatment: evaluator.Control,
Expand All @@ -71,7 +73,8 @@ func (c *SplitClient) getEvaluationsResult(matchingKey string, bucketingKey *str
if c.isReady() {
return c.evaluator.EvaluateFeatures(matchingKey, bucketingKey, featureFlags, attributes)
}
c.logger.Warning(operation + ": the SDK is not ready, results may be incorrect. Make sure to wait for SDK readiness before using this method")
featureFlagsToPrint := strings.Join(featureFlags, ",")
c.logger.Warning(fmt.Sprintf("%s: the SDK is not ready, results may be incorrect for feature flag %s. Make sure to wait for SDK readiness before using this method", operation, featureFlagsToPrint))
c.initTelemetry.RecordNonReadyUsage()
result := evaluator.Results{
EvaluationTime: 0,
Expand Down
11 changes: 6 additions & 5 deletions splitio/client/input_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,27 +554,28 @@ func TestNotReadyYet(t *testing.T) {
factoryNotReady.status.Store(sdkStatusInitializing)

expectedMessage := "{operation}: the SDK is not ready, results may be incorrect. Make sure to wait for SDK readiness before using this method"
expectedMessage1 := "{operation}: the SDK is not ready, results may be incorrect for feature flag feature. Make sure to wait for SDK readiness before using this method"
expectedMessage2 := "{operation}: the SDK is not ready, results may be incorrect for feature flag feature,feature_2. Make sure to wait for SDK readiness before using this method"

clientNotReady.Treatment("test", "feature", nil)
if !mW.Matches(strings.Replace(expectedMessage, "{operation}", "Treatment", 1)) {
if !mW.Matches(strings.Replace(expectedMessage1, "{operation}", "Treatment", 1)) {
t.Error("Wrong message")
}

clientNotReady.Treatments("test", []string{"feature", "feature_2"}, nil)
if !mW.Matches(strings.Replace(expectedMessage, "{operation}", "Treatments", 1)) {
if !mW.Matches(strings.Replace(expectedMessage2, "{operation}", "Treatments", 1)) {
t.Error("Wrong message")
}

clientNotReady.TreatmentWithConfig("test", "feature", nil)
if !mW.Matches(strings.Replace(expectedMessage, "{operation}", "TreatmentWithConfig", 1)) {
if !mW.Matches(strings.Replace(expectedMessage1, "{operation}", "TreatmentWithConfig", 1)) {
t.Error("Wrong message")
}

clientNotReady.TreatmentsWithConfig("test", []string{"feature", "feature_2"}, nil)
if !mW.Matches(strings.Replace(expectedMessage, "{operation}", "TreatmentsWithConfig", 1)) {
if !mW.Matches(strings.Replace(expectedMessage2, "{operation}", "TreatmentsWithConfig", 1)) {
t.Error("Wrong message")
}

expected := "Track: the SDK is not ready, results may be incorrect. Make sure to wait for SDK readiness before using this method"
expectedTrack(clientNotReady.Track("key", "traffic", "eventType", nil, nil), expected, t)

Expand Down

0 comments on commit 457e396

Please sign in to comment.