Skip to content

Commit

Permalink
Merge pull request #220 from bugsnag/release-2.3.0
Browse files Browse the repository at this point in the history
## 2.3.0 (2024-03-05)

### Bug fixes

* Start showing inlined functions in stack trace
  [#208](#208)

* Handle complex structs in metadata
  [#215](#215)
  [Chris Duncan](https://github.com/veqryn)

* Stop trimming everything before "main.go" on main packages
  [#217](#217)
  [Chris Duncan](https://github.com/veqryn)
  • Loading branch information
DariaKunoichi committed Mar 5, 2024
2 parents 46a0b47 + d8b4f2e commit b245ac8
Show file tree
Hide file tree
Showing 22 changed files with 443 additions and 124 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 2.3.0 (2024-03-05)

### Bug fixes

* Start showing inlined functions in stack trace
[#208](https://github.com/bugsnag/bugsnag-go/pull/208)

* Handle complex structs in metadata
[#215](https://github.com/bugsnag/bugsnag-go/pull/215)
[Chris Duncan](https://github.com/veqryn)

* Stop trimming everything before "main.go" on main packages
[#217](https://github.com/bugsnag/bugsnag-go/pull/217)
[Chris Duncan](https://github.com/veqryn)

## 2.2.1 (2022-02-21)

### Bug fixes
Expand Down
39 changes: 21 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# Bugsnag error reporter for Go
[![Latest Version](http://img.shields.io/github/release/bugsnag/bugsnag-go.svg?style=flat-square)](https://github.com/bugsnag/bugsnag-go/releases)
[![Build Status](https://travis-ci.com/bugsnag/bugsnag-go.svg?branch=master)](https://travis-ci.com/bugsnag/bugsnag-go?branch=master)
[![Go Documentation](http://img.shields.io/badge/godoc-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/bugsnag/bugsnag-go)
<div align="center">
<a href="https://www.bugsnag.com/platforms/android">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://assets.smartbear.com/m/3dab7e6cf880aa2b/original/BugSnag-Repository-Header-Dark.svg">
<img alt="SmartBear BugSnag logo" src="https://assets.smartbear.com/m/3945e02cdc983893/original/BugSnag-Repository-Header-Light.svg">
</picture>
</a>
<h1>Error monitoring and reporting for Go</h1>
</div>

[![Documentation](https://img.shields.io/badge/documentation-latest-blue.svg)](https://docs.bugsnag.com/performance/go/)
[![Go Reference](https://pkg.go.dev/badge/github.com/bugsnag/bugsnag-go.svg)](https://pkg.go.dev/github.com/bugsnag/bugsnag-go)
[![Build status](https://github.com/bugsnag/bugsnag-go/actions/workflows/test-package.yml/badge.svg?branch=master)](https://buildkite.com/bugsnag/bugsnag-go)

Automatically detect crashes and report errors in your Go apps. Get alerts about errors and panics in real-time, including detailed error reports with diagnostic information. Understand and resolve issues as fast as possible.

Learn more about Bugsnag's [Go error monitoring and error reporting](https://www.bugsnag.com/platforms/go-lang-error-reporting/) solution.
Learn more about BugSnag's [Go error monitoring and error reporting](https://www.bugsnag.com/platforms/go-lang-error-reporting/) solution.

## Features

Expand All @@ -16,23 +25,17 @@ Learn more about Bugsnag's [Go error monitoring and error reporting](https://www

## Getting Started

1. [Create a Bugsnag account](https://bugsnag.com)
1. [Create a BugSnag account](https://bugsnag.com)
2. Complete the instructions in the integration guide for your framework:
* [Martini](https://docs.bugsnag.com/platforms/go/martini)
* [Negroni](https://docs.bugsnag.com/platforms/go/negroni)
* [net/http](https://docs.bugsnag.com/platforms/go/net-http)
* [Revel](https://docs.bugsnag.com/platforms/go/revel)
* [Other Go apps](https://docs.bugsnag.com/platforms/go/other)
* [Gin](https://docs.bugsnag.com/platforms/go/gin/)
* [Negroni](https://docs.bugsnag.com/platforms/go/negroni/)
* [net/http](https://docs.bugsnag.com/platforms/go/net-http/)
* [Revel](https://docs.bugsnag.com/platforms/go/revel/)
* [Other Go apps](https://docs.bugsnag.com/platforms/go/other/)
3. Relax!

## Support

* Read the configuration reference:
* [Martini](https://docs.bugsnag.com/platforms/go/martini/configuration-options/)
* [Negroni](https://docs.bugsnag.com/platforms/go/negroni/configuration-options/)
* [net/http](https://docs.bugsnag.com/platforms/go/net-http/configuration-options/)
* [Revel](https://docs.bugsnag.com/platforms/go/revel/configuration-options/)
* [Other Go apps](https://docs.bugsnag.com/platforms/go/other/configuration-options/)
* [Search open and closed issues](https://github.com/bugsnag/bugsnag-go/issues?utf8=✓&q=is%3Aissue) for similar problems
* [Report a bug or request a feature](https://github.com/bugsnag/bugsnag-go/issues/new)

Expand All @@ -43,4 +46,4 @@ All contributors are welcome! For information on how to build, test and release

## License

The Bugsnag exception reporter for Go is free software released under the MIT License. See [LICENSE.txt](LICENSE.txt) for details.
The BugSnag error reporter for Go is free software released under the MIT License. See [LICENSE.txt](LICENSE.txt) for details.
28 changes: 13 additions & 15 deletions doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Package bugsnag captures errors in real-time and reports them to Bugsnag (http://bugsnag.com).
Package bugsnag captures errors in real-time and reports them to BugSnag (http://bugsnag.com).
Using bugsnag-go is a three-step process.
Expand All @@ -17,35 +17,33 @@ when you call ListenAndServer:
http.ListenAndServe(":8080", bugsnag.Handler(nil))
If that's not possible, you can also wrap each
HTTP handler manually:
If that's not possible, you can also wrap each HTTP handler manually:
http.HandleFunc("/" bugsnag.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
...
})
3. To notify Bugsnag of an error that is not a panic, pass it to bugsnag.Notify. This will also
3. To notify BugSnag of an error that is not a panic, pass it to bugsnag.Notify. This will also
log the error message using the configured Logger.
if err != nil {
bugsnag.Notify(err)
}
For detailed integration instructions see https://bugsnag.com/docs/notifiers/go.
For detailed integration instructions see https://docs.bugsnag.com/platforms/go.
Configuration
# Configuration
The only required configuration is the Bugsnag API key which can be obtained by clicking "Settings"
on the top of https://bugsnag.com/ after signing up. We also recommend you set the ReleaseStage,
AppType, and AppVersion if these make sense for your deployment workflow.
The only required configuration is the BugSnag API key which can be obtained by clicking "Project
Settings" on the top of your BugSnag dashboard after signing up. We also recommend you set the
ReleaseStage, AppType, and AppVersion if these make sense for your deployment workflow.
RawData
# RawData
If you need to attach extra data to Bugsnag notifications you can do that using
the rawData mechanism. Most of the functions that send errors to Bugsnag allow
you to pass in any number of interface{} values as rawData. The rawData can
consist of the Severity, Context, User or MetaData types listed below, and
there is also builtin support for *http.Requests.
If you need to attach extra data to BugSnag events, you can do that using the rawData mechanism.
Most of the functions that send errors to BugSnag allow you to pass in any number of interface{}
values as rawData. The rawData can consist of the Severity, Context, User or MetaData types listed
below, and there is also builtin support for *http.Requests.
bugsnag.Notify(err, bugsnag.SeverityError)
Expand Down
15 changes: 8 additions & 7 deletions features/fixtures/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func multipleUnhandled() {
defer notifier.AutoNotify(ctx)
panic("oops")
}

//go:noinline
func unhandledCrash() {
// Invalid type assertion, will panic
Expand Down Expand Up @@ -259,17 +260,17 @@ func handledToUnhandled() {
}

type customErr struct {
msg string
cause error
msg string
cause error
callers []uintptr
}

func newCustomErr(msg string, cause error) error {
callers := make([]uintptr, 8)
runtime.Callers(2, callers)
return customErr {
msg: msg,
cause: cause,
return customErr{
msg: msg,
cause: cause,
callers: callers,
}
}
Expand Down Expand Up @@ -297,7 +298,7 @@ func nestedHandledError() {
if val, err := checkValue(i); err != nil {
fmt.Printf("err: %v, val: %d", err, val)
}
if val, err := checkValue(i-46); err != nil {
if val, err := checkValue(i - 46); err != nil {
fmt.Printf("err: %v, val: %d", err, val)
}

Expand All @@ -317,7 +318,7 @@ func login(token string) error {
func checkValue(i int) (int, error) {
if i < 0 {
return 0, newCustomErr("invalid token", nil)
} else if i % 2 == 0 {
} else if i%2 == 0 {
return i / 2, nil
} else if i < 9 {
return i * 3, nil
Expand Down
12 changes: 12 additions & 0 deletions features/fixtures/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ services:
- PARAMS_FILTERS
- SYNCHRONOUS
- SERVER_PORT
- BUGSNAG_SOURCE_ROOT
- BUGSNAG_PROJECT_PACKAGES
restart: "no"

autoconfigure:
Expand Down Expand Up @@ -72,6 +74,8 @@ services:
- AUTO_CAPTURE_SESSIONS
- SYNCHRONOUS
- SERVER_PORT
- BUGSNAG_SOURCE_ROOT
- BUGSNAG_PROJECT_PACKAGES
restart: "no"
command: go run main.go

Expand All @@ -97,6 +101,8 @@ services:
- AUTO_CAPTURE_SESSIONS
- SYNCHRONOUS
- SERVER_PORT
- BUGSNAG_SOURCE_ROOT
- BUGSNAG_PROJECT_PACKAGES
restart: "no"
command: go run main.go

Expand All @@ -121,6 +127,8 @@ services:
- AUTO_CAPTURE_SESSIONS
- SYNCHRONOUS
- SERVER_PORT
- BUGSNAG_SOURCE_ROOT
- BUGSNAG_PROJECT_PACKAGES
restart: "no"
command: go run main.go

Expand All @@ -146,6 +154,8 @@ services:
- AUTO_CAPTURE_SESSIONS
- SYNCHRONOUS
- SERVER_PORT
- BUGSNAG_SOURCE_ROOT
- BUGSNAG_PROJECT_PACKAGES
restart: "no"
command: go run main.go

Expand Down Expand Up @@ -173,5 +183,7 @@ services:
- SYNCHRONOUS
- SERVER_PORT
- USE_PROPERTIES_FILE_CONFIG
- BUGSNAG_SOURCE_ROOT
- BUGSNAG_PROJECT_PACKAGES
restart: "no"
command: ./test/run.sh
11 changes: 6 additions & 5 deletions features/handled.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Feature: Plain handled errors

Background:
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
Given I set environment variable "BUGSNAG_SOURCE_ROOT" to the app directory
And I configure the bugsnag endpoint
And I have built the service "app"
And I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"
Expand Down Expand Up @@ -36,7 +37,7 @@ Scenario: Sending an event using a callback to modify report contents
And the event "severityReason.type" equals "userCallbackSetSeverity"
And the event "context" equals "nonfatal.go:14"
And the "file" of stack frame 0 equals "main.go"
And stack frame 0 contains a local function spanning 241 to 247
And stack frame 0 contains a local function spanning 242 to 248
And the "file" of stack frame 1 equals ">insertion<"
And the "lineNumber" of stack frame 1 equals 0

Expand All @@ -49,7 +50,7 @@ Scenario: Marking an error as unhandled in a callback
And the event "severityReason.type" equals "userCallbackSetSeverity"
And the event "severityReason.unhandledOverridden" is true
And the "file" of stack frame 0 equals "main.go"
And stack frame 0 contains a local function spanning 253 to 256
And stack frame 0 contains a local function spanning 254 to 257

Scenario: Unwrapping the causes of a handled error
When I run the go service "app" with the test case "nested-error"
Expand All @@ -58,12 +59,12 @@ Scenario: Unwrapping the causes of a handled error
And the event "unhandled" is false
And the event "severity" equals "warning"
And the event "exceptions.0.message" equals "terminate process"
And the "lineNumber" of stack frame 0 equals 291
And the "lineNumber" of stack frame 0 equals 292
And the "file" of stack frame 0 equals "main.go"
And the "method" of stack frame 0 equals "nestedHandledError"
And the event "exceptions.1.message" equals "login failed"
And the event "exceptions.1.stacktrace.0.file" equals "main.go"
And the event "exceptions.1.stacktrace.0.lineNumber" equals 311
And the event "exceptions.1.stacktrace.0.lineNumber" equals 312
And the event "exceptions.2.message" equals "invalid token"
And the event "exceptions.2.stacktrace.0.file" equals "main.go"
And the event "exceptions.2.stacktrace.0.lineNumber" equals 319
And the event "exceptions.2.stacktrace.0.lineNumber" equals 320
1 change: 1 addition & 0 deletions features/net-http/handled.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Feature: Handled errors

Background:
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
Given I set environment variable "BUGSNAG_SOURCE_ROOT" to the app directory
And I configure the bugsnag endpoint
And I set environment variable "SERVER_PORT" to "4512"
And I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"
Expand Down
1 change: 1 addition & 0 deletions features/plain_features/panics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Feature: Panic handling

Background:
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
Given I set environment variable "BUGSNAG_SOURCE_ROOT" to the app directory
And I configure the bugsnag endpoint
And I have built the service "app"
And I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"
Expand Down
2 changes: 1 addition & 1 deletion v2/bugsnag.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

// Version defines the version of this Bugsnag notifier
const Version = "2.2.1"
const Version = "2.3.0"

var panicHandlerOnce sync.Once
var sessionTrackerOnce sync.Once
Expand Down
5 changes: 1 addition & 4 deletions v2/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,7 @@ func (config *Configuration) isProjectPackage(_pkg string) bool {
}

func (config *Configuration) stripProjectPackages(file string) string {
trimmedFile := file
if strings.HasPrefix(trimmedFile, config.SourceRoot) {
trimmedFile = strings.TrimPrefix(trimmedFile, config.SourceRoot)
}
trimmedFile := strings.TrimPrefix(file, config.SourceRoot)
for _, p := range config.ProjectPackages {
if len(p) > 2 && p[len(p)-2] == '/' && p[len(p)-1] == '*' {
p = p[:len(p)-1]
Expand Down
28 changes: 13 additions & 15 deletions v2/doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Package bugsnag captures errors in real-time and reports them to Bugsnag (http://bugsnag.com).
Package bugsnag captures errors in real-time and reports them to BugSnag (http://bugsnag.com).
Using bugsnag-go is a three-step process.
Expand All @@ -17,35 +17,33 @@ when you call ListenAndServer:
http.ListenAndServe(":8080", bugsnag.Handler(nil))
If that's not possible, you can also wrap each
HTTP handler manually:
If that's not possible, you can also wrap each HTTP handler manually:
http.HandleFunc("/" bugsnag.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
...
})
3. To notify Bugsnag of an error that is not a panic, pass it to bugsnag.Notify. This will also
3. To notify BugSnag of an error that is not a panic, pass it to bugsnag.Notify. This will also
log the error message using the configured Logger.
if err != nil {
bugsnag.Notify(err)
}
For detailed integration instructions see https://bugsnag.com/docs/notifiers/go.
For detailed integration instructions see https://docs.bugsnag.com/platforms/go.
Configuration
# Configuration
The only required configuration is the Bugsnag API key which can be obtained by clicking "Settings"
on the top of https://bugsnag.com/ after signing up. We also recommend you set the ReleaseStage,
AppType, and AppVersion if these make sense for your deployment workflow.
The only required configuration is the BugSnag API key which can be obtained by clicking "Project
Settings" on the top of your BugSnag dashboard after signing up. We also recommend you set the
ReleaseStage, AppType, and AppVersion if these make sense for your deployment workflow.
RawData
# RawData
If you need to attach extra data to Bugsnag notifications you can do that using
the rawData mechanism. Most of the functions that send errors to Bugsnag allow
you to pass in any number of interface{} values as rawData. The rawData can
consist of the Severity, Context, User or MetaData types listed below, and
there is also builtin support for *http.Requests.
If you need to attach extra data to BugSnag events, you can do that using the rawData mechanism.
Most of the functions that send errors to BugSnag allow you to pass in any number of interface{}
values as rawData. The rawData can consist of the Severity, Context, User or MetaData types listed
below, and there is also builtin support for *http.Requests.
bugsnag.Notify(err, bugsnag.SeverityError)
Expand Down
Loading

0 comments on commit b245ac8

Please sign in to comment.