@@ -686,19 +686,23 @@ func (t *Test) Compare(harvest *newrelic.Harvest) {
686
686
if nil != t .metricsExist {
687
687
for _ , name := range strings .Split (strings .TrimSpace (string (t .subEnvVars (t .metricsExist ))), "\n " ) {
688
688
name = strings .TrimSpace (name )
689
- actual := strings .Replace (name , "__FILE__" , t .Path , - 1 )
690
- if ! harvest .Metrics .Has (actual ) {
691
- t .Fail (fmt .Errorf ("metric does not exist: %s\n \n actual metric table: %s" , actual , harvest .Metrics .DebugJSON ()))
689
+ expected := strings .Replace (name , "__FILE__" , t .Path , - 1 )
690
+ if ! harvest .Metrics .Has (expected ) {
691
+ actualPretty := bytes.Buffer {}
692
+ json .Indent (& actualPretty , []byte (harvest .Metrics .DebugJSON ()), "" , " " )
693
+ t .Fail (fmt .Errorf ("metric does not exist: %s\n \n actual metric table: %s" , expected , actualPretty .String ()))
692
694
}
693
695
}
694
696
}
695
697
696
698
if nil != t .metricsDontExist {
697
699
for _ , name := range strings .Split (strings .TrimSpace (string (t .subEnvVars (t .metricsDontExist ))), "\n " ) {
698
700
name = strings .TrimSpace (name )
699
- actual := strings .Replace (name , "__FILE__" , t .Path , - 1 )
700
- if harvest .Metrics .Has (actual ) {
701
- t .Fail (fmt .Errorf ("unexpected metric in harvest: %s\n \n actual metric table: %s" , actual , harvest .Metrics .DebugJSON ()))
701
+ expected := strings .Replace (name , "__FILE__" , t .Path , - 1 )
702
+ if harvest .Metrics .Has (expected ) {
703
+ actualPretty := bytes.Buffer {}
704
+ json .Indent (& actualPretty , []byte (harvest .Metrics .DebugJSON ()), "" , " " )
705
+ t .Fail (fmt .Errorf ("unexpected metric in harvest: %s\n \n actual metric table: %s" , expected , actualPretty .String ()))
702
706
}
703
707
}
704
708
}
0 commit comments