forked from newrelic/go-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
internal_errors_13_test.go
54 lines (48 loc) · 1.31 KB
/
internal_errors_13_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2020 New Relic Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
// +build go1.13
package newrelic
import (
"fmt"
"testing"
"github.com/newrelic/go-agent/internal"
)
func TestNoticedWrappedError(t *testing.T) {
gamma := func() error {
return Error{
Message: "socket error",
Class: "socketError",
Attributes: map[string]interface{}{
"zip": "zap",
},
}
}
beta := func() error { return fmt.Errorf("problem in beta: %w", gamma()) }
alpha := func() error { return fmt.Errorf("problem in alpha: %w", beta()) }
app := testApp(nil, nil, t)
txn := app.StartTransaction("hello", nil, nil)
err := txn.NoticeError(alpha())
if nil != err {
t.Error(err)
}
txn.End()
app.ExpectErrors(t, []internal.WantError{{
TxnName: "OtherTransaction/Go/hello",
Msg: "problem in alpha: problem in beta: socket error",
Klass: "socketError",
UserAttributes: map[string]interface{}{
"zip": "zap",
},
}})
app.ExpectErrorEvents(t, []internal.WantEvent{{
Intrinsics: map[string]interface{}{
"error.class": "socketError",
"error.message": "problem in alpha: problem in beta: socket error",
"transactionName": "OtherTransaction/Go/hello",
},
UserAttributes: map[string]interface{}{
"zip": "zap",
},
}})
app.ExpectMetrics(t, backgroundErrorMetrics)
}