Skip to content

Commit 07f878f

Browse files
bug: [fix performance test not working with multiple packages] (FF-3110) (#68)
* bug: [remove applicationlogger package; flatten into 1] (FF-3110) * upgrade github actions * Possibly fix paths * run test 5 times * simplify github * switch order
1 parent 9b09e96 commit 07f878f

File tree

14 files changed

+102
-145
lines changed

14 files changed

+102
-145
lines changed

.github/workflows/memory-profile-compare.yml

Lines changed: 32 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,41 @@ jobs:
66
compare-memory-profiles:
77
runs-on: ubuntu-latest
88
steps:
9-
- name: Checkout main branch
10-
uses: actions/checkout@v2
9+
- name: Checkout code
10+
uses: actions/checkout@v3
1111
with:
12-
ref: 'main'
13-
14-
- name: Set up Go (main branch)
15-
uses: actions/setup-go@v2
16-
with:
17-
go-version: '1.19'
18-
19-
- name: Generate memory profile for main branch
20-
run: make profile-memory OUTFILE_SUFFIX=.main
21-
22-
- name: Save main branch memory profile
23-
uses: actions/upload-artifact@v2
24-
with:
25-
name: memprofile-main
26-
path: |
27-
memprofile.main.out
28-
memprofile.main.text
29-
30-
- name: Checkout feature branch
31-
uses: actions/checkout@v2
32-
with:
33-
ref: ${{ github.head_ref }}
34-
35-
- name: Set up Go (feature branch)
36-
uses: actions/setup-go@v2
37-
with:
38-
go-version: '1.19'
39-
40-
- name: Generate memory profile for feature branch
41-
run: make profile-memory OUTFILE_SUFFIX=.feat
42-
43-
- name: Save feat branch memory profile
44-
uses: actions/upload-artifact@v2
45-
with:
46-
name: memprofile-feat
47-
path: |
48-
memprofile.feat.out
49-
memprofile.feat.text
12+
fetch-depth: 0
5013

51-
- name: Download main branch memory profile
52-
uses: actions/download-artifact@v2
14+
- name: Set up Go
15+
uses: actions/setup-go@v4
5316
with:
54-
name: memprofile-main
55-
path: .
56-
57-
- name: Display structure of downloaded files
58-
run: ls -R
59-
17+
go-version: '1.21'
18+
19+
- name: Generate memory profiles
20+
run: |
21+
git checkout ${{ github.head_ref }}
22+
make profile-memory OUTFILE_SUFFIX=.feat || { echo "Failed to generate feature profile"; ls -l; cat Makefile; exit 1; }
23+
git checkout main
24+
make profile-memory OUTFILE_SUFFIX=.main || { echo "Failed to generate main profile"; ls -l; cat Makefile; exit 1; }
25+
6026
- name: Compare memory profiles
61-
run: make profile-memory-compare BASE_FILE=memprofile.main.out FEAT_FILE=memprofile.feat.out > memory-profile-comparison.text
62-
63-
- name: Show memory profile comparison
64-
run: cat memory-profile-comparison.text
27+
run: |
28+
ls -l
29+
if [ ! -f memprofile.main.out ] || [ ! -f memprofile.feat.out ]; then
30+
echo "Error: One or both memory profile files are missing."
31+
exit 1
32+
fi
33+
make profile-memory-compare BASE_FILE=memprofile.main.out FEAT_FILE=memprofile.feat.out > memory-profile-comparison.text || { echo "Failed to compare profiles"; cat Makefile; exit 1; }
34+
echo "Memory Profile Comparison:"
35+
cat memory-profile-comparison.text
6536
66-
- name: Upload comparison result
67-
uses: actions/upload-artifact@v2
37+
- name: Upload artifacts
38+
uses: actions/upload-artifact@v3
6839
with:
69-
name: memory-profile-comparison
70-
path: memory-profile-comparison.text
40+
name: memory-profiles
41+
path: |
42+
memprofile.main.out
43+
memprofile.main.text
44+
memprofile.feat.out
45+
memprofile.feat.text
46+
memory-profile-comparison.text

Makefile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@ lint:
2929

3030
## profile-memory - Run test and generate memory profile
3131
profile-memory: test-data
32-
@cd eppoclient && \
33-
{ \
34-
echo "Using OUTFILE_SUFFIX: $$OUTFILE_SUFFIX"; \
35-
go test -run Test_e2e -memprofile ../memprofile$$OUTFILE_SUFFIX.out ./...; \
36-
go tool pprof -text -nodecount=50 ../memprofile$$OUTFILE_SUFFIX.out > ../memprofile$$OUTFILE_SUFFIX.text; \
37-
}
32+
@echo "Using OUTFILE_SUFFIX: $(OUTFILE_SUFFIX)"
33+
go test -v ./... -run=Test_e2e -count=5 -memprofile=memprofile$(OUTFILE_SUFFIX).out
34+
go tool pprof -text memprofile$(OUTFILE_SUFFIX).out > memprofile$(OUTFILE_SUFFIX).text
3835

3936
## profile-memory-compare - Compare two memory profiles
4037
## example: make profile-memory-compare BASE_FILE=memprofile1.out FEAT_FILE=memprofile2.out

doc.go

Lines changed: 0 additions & 1 deletion
This file was deleted.

eppoclient/applicationlogger/scrubbing_logger.go renamed to eppoclient/applicationlogger.go

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,64 @@
1-
package applicationlogger
1+
package eppoclient
22

33
import (
44
"regexp"
5+
6+
"go.uber.org/zap"
57
)
68

9+
type ApplicationLogger interface {
10+
Debug(args ...interface{})
11+
Info(args ...interface{})
12+
Infof(template string, args ...interface{})
13+
Warn(args ...interface{})
14+
Warnf(template string, args ...interface{})
15+
Error(args ...interface{})
16+
Errorf(template string, args ...interface{})
17+
}
18+
19+
// ZapLogger The default logger for the Eppo SDK
20+
type ZapLogger struct {
21+
logger *zap.Logger
22+
}
23+
24+
func NewZapLogger(logger *zap.Logger) *ZapLogger {
25+
return &ZapLogger{logger: logger}
26+
}
27+
28+
func (z *ZapLogger) Debug(args ...interface{}) {
29+
z.logger.Sugar().Debug(args...)
30+
}
31+
32+
func (z *ZapLogger) Info(args ...interface{}) {
33+
z.logger.Sugar().Info(args...)
34+
}
35+
36+
func (z *ZapLogger) Infof(template string, args ...interface{}) {
37+
z.logger.Sugar().Infof(template, args...)
38+
}
39+
40+
func (z *ZapLogger) Warn(args ...interface{}) {
41+
z.logger.Sugar().Warn(args...)
42+
}
43+
44+
func (z *ZapLogger) Warnf(template string, args ...interface{}) {
45+
z.logger.Sugar().Warnf(template, args...)
46+
}
47+
48+
func (z *ZapLogger) Error(args ...interface{}) {
49+
z.logger.Sugar().Error(args...)
50+
}
51+
52+
func (z *ZapLogger) Errorf(template string, args ...interface{}) {
53+
z.logger.Sugar().Errorf(template, args...)
54+
}
55+
56+
// ScrubbingLogger is an ApplicationLogger that scrubs sensitive information from logs
757
type ScrubbingLogger struct {
8-
innerLogger Logger
58+
innerLogger ApplicationLogger
959
}
1060

11-
func NewScrubbingLogger(innerLogger Logger) *ScrubbingLogger {
61+
func NewScrubbingLogger(innerLogger ApplicationLogger) *ScrubbingLogger {
1262
return &ScrubbingLogger{innerLogger: innerLogger}
1363
}
1464

eppoclient/applicationlogger/interface.go

Lines changed: 0 additions & 11 deletions
This file was deleted.

eppoclient/applicationlogger/zap_logger.go

Lines changed: 0 additions & 42 deletions
This file was deleted.

eppoclient/client.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package eppoclient
33
import (
44
"fmt"
55
"time"
6-
7-
"github.com/Eppo-exp/golang-sdk/v5/eppoclient/applicationlogger"
86
)
97

108
type Attributes map[string]interface{}
@@ -16,15 +14,15 @@ type EppoClient struct {
1614
configRequestor *configurationRequestor
1715
poller *poller
1816
logger IAssignmentLogger
19-
applicationLogger applicationlogger.Logger
17+
applicationLogger ApplicationLogger
2018
}
2119

2220
func newEppoClient(
2321
configurationStore *configurationStore,
2422
configRequestor *configurationRequestor,
2523
poller *poller,
2624
assignmentLogger IAssignmentLogger,
27-
applicationLogger applicationlogger.Logger,
25+
applicationLogger ApplicationLogger,
2826
) *EppoClient {
2927
return &EppoClient{
3028
configurationStore: configurationStore,

eppoclient/client_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ import (
66
"github.com/stretchr/testify/assert"
77
"github.com/stretchr/testify/mock"
88
"go.uber.org/zap"
9-
10-
"github.com/Eppo-exp/golang-sdk/v5/eppoclient/applicationlogger"
119
)
1210

1311
var (
1412
zapLogger, _ = zap.NewDevelopment()
15-
applicationLogger = applicationlogger.NewZapLogger(zapLogger)
13+
applicationLogger = NewZapLogger(zapLogger)
1614
)
1715

1816
func Test_AssignBlankExperiment(t *testing.T) {

eppoclient/config.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"time"
66

7-
"github.com/Eppo-exp/golang-sdk/v5/eppoclient/applicationlogger"
87
"go.uber.org/zap"
98
)
109

@@ -16,7 +15,7 @@ type Config struct {
1615
SdkKey string
1716
AssignmentLogger IAssignmentLogger
1817
PollerInterval time.Duration
19-
ApplicationLogger applicationlogger.Logger
18+
ApplicationLogger ApplicationLogger
2019
}
2120

2221
func (cfg *Config) validate() error {
@@ -37,7 +36,7 @@ func (cfg *Config) validate() error {
3736
if err != nil {
3837
return fmt.Errorf("failed to create default logger: %v", err)
3938
}
40-
cfg.ApplicationLogger = applicationlogger.NewZapLogger(defaultLogger)
39+
cfg.ApplicationLogger = NewZapLogger(defaultLogger)
4140
}
4241

4342
return nil

eppoclient/configurationrequestor.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package eppoclient
22

33
import (
44
"encoding/json"
5-
6-
"github.com/Eppo-exp/golang-sdk/v5/eppoclient/applicationlogger"
75
)
86

97
const CONFIG_ENDPOINT = "/flag-config/v1/config"
@@ -12,10 +10,10 @@ const BANDIT_ENDPOINT = "/flag-config/v1/bandits"
1210
type configurationRequestor struct {
1311
httpClient httpClient
1412
configStore *configurationStore
15-
applicationLogger applicationlogger.Logger
13+
applicationLogger ApplicationLogger
1614
}
1715

18-
func newConfigurationRequestor(httpClient httpClient, configStore *configurationStore, applicationLogger applicationlogger.Logger) *configurationRequestor {
16+
func newConfigurationRequestor(httpClient httpClient, configStore *configurationStore, applicationLogger ApplicationLogger) *configurationRequestor {
1917
return &configurationRequestor{
2018
httpClient: httpClient,
2119
configStore: configStore,

0 commit comments

Comments
 (0)