Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add extra goos support #1646

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"net"
"os"
"reflect"
"syscall"
"time"

"go.elastic.co/apm/v2/model"
Expand Down Expand Up @@ -596,13 +595,6 @@ func init() {
details.SetAttr("syscall", syscallErr.Syscall)
details.Cause = append(details.Cause, syscallErr.Err)
}))
RegisterTypeErrorDetailer(reflect.TypeOf(syscall.Errno(0)), ErrorDetailerFunc(func(err error, details *ErrorDetails) {
errno := err.(syscall.Errno)
details.Code.String = errnoName(errno)
if details.Code.String == "" {
details.Code.Number = float64(errno)
}
}))
}

func errTemporary(err error) bool {
Expand Down
33 changes: 12 additions & 21 deletions error_go120_test.go → error_syscall.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,21 @@
// specific language governing permissions and limitations
// under the License.

//go:build go1.20
// +build go1.20
//go:build unix || windows

package apm_test
package apm // import "go.elastic.co/apm/v2"

import (
"context"
"errors"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.elastic.co/apm/v2"
"go.elastic.co/apm/v2/apmtest"
"reflect"
"syscall"
)

func TestErrorCauseUnwrapJoined(t *testing.T) {
err := errors.Join(errors.New("cause1"), errors.New("cause2"))
_, _, errors := apmtest.WithTransaction(func(ctx context.Context) {
apm.CaptureError(ctx, err).Send()
})
require.Len(t, errors, 1)
require.Len(t, errors[0].Exception.Cause, 2)
assert.Equal(t, "cause1", errors[0].Exception.Cause[0].Message)
assert.Equal(t, "cause2", errors[0].Exception.Cause[1].Message)
func init() {
RegisterTypeErrorDetailer(reflect.TypeOf(syscall.Errno(0)), ErrorDetailerFunc(func(err error, details *ErrorDetails) {
errno := err.(syscall.Errno)
details.Code.String = errnoName(errno)
if details.Code.String == "" {
details.Code.Number = float64(errno)
}
}))
}
12 changes: 12 additions & 0 deletions error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package apm_test

import (
"context"
goerrors "errors"
"fmt"
"net"
"os"
Expand Down Expand Up @@ -52,6 +53,17 @@ func TestErrorID(t *testing.T) {
assert.Equal(t, model.TraceID(errorID), errors[0].ID)
}

func TestErrorCauseUnwrapJoined(t *testing.T) {
err := goerrors.Join(errors.New("cause1"), errors.New("cause2"))
_, _, errors := apmtest.WithTransaction(func(ctx context.Context) {
apm.CaptureError(ctx, err).Send()
})
require.Len(t, errors, 1)
require.Len(t, errors[0].Exception.Cause, 2)
assert.Equal(t, "cause1", errors[0].Exception.Cause[0].Message)
assert.Equal(t, "cause2", errors[0].Exception.Cause[1].Message)
}

func TestErrorsStackTrace(t *testing.T) {
modelError := sendError(t, &errorsStackTracer{
"zing", newErrorsStackTrace(0, 2),
Expand Down
3 changes: 1 addition & 2 deletions error_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
// specific language governing permissions and limitations
// under the License.

//go:build !windows
// +build !windows
//go:build unix

package apm // import "go.elastic.co/apm/v2"

Expand Down
2 changes: 2 additions & 0 deletions error_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// specific language governing permissions and limitations
// under the License.

//go:build windows

package apm // import "go.elastic.co/apm/v2"

import (
Expand Down
Loading