Skip to content

Commit

Permalink
cleanup for nrzap fix and fixed attribute test
Browse files Browse the repository at this point in the history
  • Loading branch information
iamemilio committed Jun 7, 2024
1 parent 00956b6 commit be4bc8c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 36 deletions.
14 changes: 0 additions & 14 deletions v3/integrations/logcontext-v2/nrzap/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,3 @@ require (
github.com/newrelic/go-agent/v3 v3.32.0
go.uber.org/zap v1.24.0
)

require (
github.com/golang/protobuf v1.5.3 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.56.3 // indirect
google.golang.org/protobuf v1.30.0 // indirect
)

replace github.com/newrelic/go-agent/v3 => ../../..
25 changes: 3 additions & 22 deletions v3/newrelic/expect_implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"reflect"
"time"

"github.com/newrelic/go-agent/v3/internal"
Expand Down Expand Up @@ -250,29 +251,9 @@ func expectLogEvent(v internal.Validator, actual logEvent, want internal.WantLog
return
}

if actual.attributes != nil && want.Attributes != nil {
for k, val := range want.Attributes {
actualVal, actualOk := actual.attributes[k]
if !actualOk {
v.Error(fmt.Sprintf("expected log attribute for key %v is missing", k))
return
}

// Check if both values are maps, and if so, compare them recursively
if expectedMap, ok := val.(map[string]interface{}); ok {
if actualMap, ok := actualVal.(map[string]interface{}); ok {
if !expectLogEventAttributesMaps(expectedMap, actualMap) {
v.Error(fmt.Sprintf("unexpected log attribute for key %v: got %v, want %v", k, actualMap, expectedMap))
return
}
} else {
v.Error(fmt.Sprintf("actual value for key %v is not a map", k))
return
}
}
}
if !reflect.DeepEqual(actual.attributes, want.Attributes) {
v.Error(fmt.Sprintf("wanted the following attributes: %+v\nactual attributes are: %+v", want.Attributes, actual.attributes))
}

}

// Helper function that compares two maps for equality. This is used to compare the attribute fields of log events expected vs received
Expand Down

0 comments on commit be4bc8c

Please sign in to comment.