Skip to content

Commit

Permalink
Merge pull request #69 from resurfaceio/dev
Browse files Browse the repository at this point in the history
Updated comments for custom fields and added 1ms floor to interval re…
  • Loading branch information
kolin-newby authored Dec 8, 2021
2 parents 4865622 + 0b4e0ca commit 620c658
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
5 changes: 0 additions & 5 deletions BaseLogger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,6 @@ func TestSubmitsToDeniedUrl(t *testing.T) {
assert.True(t, logger.Enabled())
logger.ndjsonHandler("{}")
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.
fmt.Print("\n***************")
fmt.Print(logger.submitFailures)
fmt.Print(" | ")
fmt.Print(logger.submitSuccesses)
fmt.Print("***************\n")
assert.Equal(t, int64(1), logger.submitFailures)
assert.Equal(t, int64(0), logger.submitSuccesses)
}
Expand Down
2 changes: 1 addition & 1 deletion HttpLogger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func TestSetsNowAndInterval(t *testing.T) {
SendHttpMessage(logger, helper.MockResponse(), helper.MockRequestWithJson(), 0, 0, nil)

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

logger, _ = NewHttpLogger(opt)

Expand Down
4 changes: 3 additions & 1 deletion HttpMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func buildHttpMessage(req *http.Request, resp *http.Response) [][]string {
}

// 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
// here, now refers to the time at which the request was received and interval corresponds to the time between request and response
// 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.
func SendHttpMessage(logger *HttpLogger, resp *http.Response, req *http.Request, now int64, interval int64, customFields map[string]string) {

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

logger.submitIfPassing(message, customFields)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ go 1.15
require (
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
github.com/joho/godotenv v1.3.0
github.com/resurfaceio/logger-go/v2 v2.0.1 // indirect
github.com/stretchr/testify v1.7.0
)
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/resurfaceio/logger-go v1.2.0 h1:X3wzy4w6AfQLCrXjf9Oz9s8cenn6e1ezeJHTRHe91dQ=
github.com/resurfaceio/logger-go/v2 v2.0.1 h1:kimxnuzhLYBH/ATN0+WYcSwAKCz4vSrdpqncFGdITfk=
github.com/resurfaceio/logger-go/v2 v2.0.1/go.mod h1:M4gj7jev+IedyMEtwIDq7lP5bRylr9TbHj9KHRkBch4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down

0 comments on commit 620c658

Please sign in to comment.