Skip to content

Commit 620c658

Browse files
authored
Merge pull request #69 from resurfaceio/dev
Updated comments for custom fields and added 1ms floor to interval re…
2 parents 4865622 + 0b4e0ca commit 620c658

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

BaseLogger_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,6 @@ func TestSubmitsToDeniedUrl(t *testing.T) {
188188
assert.True(t, logger.Enabled())
189189
logger.ndjsonHandler("{}")
190190
time.Sleep(5 * time.Second) // Added because with async worker the test was checking for fail/success values before worker could actually try sending the request.
191-
fmt.Print("\n***************")
192-
fmt.Print(logger.submitFailures)
193-
fmt.Print(" | ")
194-
fmt.Print(logger.submitSuccesses)
195-
fmt.Print("***************\n")
196191
assert.Equal(t, int64(1), logger.submitFailures)
197192
assert.Equal(t, int64(0), logger.submitSuccesses)
198193
}

HttpLogger_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func TestSetsNowAndInterval(t *testing.T) {
109109
SendHttpMessage(logger, helper.MockResponse(), helper.MockRequestWithJson(), 0, 0, nil)
110110

111111
assert.Contains(t, logger.queue[0], "[\"now", "SendHttpMessage did not append 'now' to message on null entry")
112-
assert.NotContains(t, logger.queue[0], "[\"interval", "SendHttpMessage appended 'interval' to message on null entry")
112+
assert.Contains(t, logger.queue[0], "[\"interval\",\"1", "SendHttpMessage did not appended 'floor interval' to message on null entry")
113113

114114
logger, _ = NewHttpLogger(opt)
115115

HttpMessage.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func buildHttpMessage(req *http.Request, resp *http.Response) [][]string {
8181
}
8282

8383
// SendHttpMessage(l *HttpLogger, resp *http.Response, req *http.Request, now int64, interval int64) Uses logger l to send a log of the given resp and req to the loggers url
84-
// here, now refers to the time at which the request was received and interval corresponds to the time between request and response
84+
// here, now refers to the time at which the request was received and interval corresponds to the time between request and response. customFields are used to pass custom information fields through the logger to Resurface.
8585
func SendHttpMessage(logger *HttpLogger, resp *http.Response, req *http.Request, now int64, interval int64, customFields map[string]string) {
8686

8787
if !logger.Enabled() {
@@ -118,6 +118,8 @@ func SendHttpMessage(logger *HttpLogger, resp *http.Response, req *http.Request,
118118
// append interval noting the time between request and response
119119
if interval != 0 {
120120
message = append(message, []string{"interval", strconv.FormatInt(interval, 10)})
121+
} else {
122+
message = append(message, []string{"interval", strconv.FormatInt(1, 10)})
121123
}
122124

123125
logger.submitIfPassing(message, customFields)

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ go 1.15
55
require (
66
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
77
github.com/joho/godotenv v1.3.0
8+
github.com/resurfaceio/logger-go/v2 v2.0.1 // indirect
89
github.com/stretchr/testify v1.7.0
910
)

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
66
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
77
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
88
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
9+
github.com/resurfaceio/logger-go v1.2.0 h1:X3wzy4w6AfQLCrXjf9Oz9s8cenn6e1ezeJHTRHe91dQ=
10+
github.com/resurfaceio/logger-go/v2 v2.0.1 h1:kimxnuzhLYBH/ATN0+WYcSwAKCz4vSrdpqncFGdITfk=
11+
github.com/resurfaceio/logger-go/v2 v2.0.1/go.mod h1:M4gj7jev+IedyMEtwIDq7lP5bRylr9TbHj9KHRkBch4=
912
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1013
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
1114
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=

0 commit comments

Comments
 (0)