Skip to content

Commit b245ac8

Browse files
Merge pull request #220 from bugsnag/release-2.3.0
## 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)
2 parents 46a0b47 + d8b4f2e commit b245ac8

File tree

22 files changed

+443
-124
lines changed

22 files changed

+443
-124
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## 2.3.0 (2024-03-05)
4+
5+
### Bug fixes
6+
7+
* Start showing inlined functions in stack trace
8+
[#208](https://github.com/bugsnag/bugsnag-go/pull/208)
9+
10+
* Handle complex structs in metadata
11+
[#215](https://github.com/bugsnag/bugsnag-go/pull/215)
12+
[Chris Duncan](https://github.com/veqryn)
13+
14+
* Stop trimming everything before "main.go" on main packages
15+
[#217](https://github.com/bugsnag/bugsnag-go/pull/217)
16+
[Chris Duncan](https://github.com/veqryn)
17+
318
## 2.2.1 (2022-02-21)
419

520
### Bug fixes

README.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
# Bugsnag error reporter for Go
2-
[![Latest Version](http://img.shields.io/github/release/bugsnag/bugsnag-go.svg?style=flat-square)](https://github.com/bugsnag/bugsnag-go/releases)
3-
[![Build Status](https://travis-ci.com/bugsnag/bugsnag-go.svg?branch=master)](https://travis-ci.com/bugsnag/bugsnag-go?branch=master)
4-
[![Go Documentation](http://img.shields.io/badge/godoc-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/bugsnag/bugsnag-go)
1+
<div align="center">
2+
<a href="https://www.bugsnag.com/platforms/android">
3+
<picture>
4+
<source media="(prefers-color-scheme: dark)" srcset="https://assets.smartbear.com/m/3dab7e6cf880aa2b/original/BugSnag-Repository-Header-Dark.svg">
5+
<img alt="SmartBear BugSnag logo" src="https://assets.smartbear.com/m/3945e02cdc983893/original/BugSnag-Repository-Header-Light.svg">
6+
</picture>
7+
</a>
8+
<h1>Error monitoring and reporting for Go</h1>
9+
</div>
10+
11+
[![Documentation](https://img.shields.io/badge/documentation-latest-blue.svg)](https://docs.bugsnag.com/performance/go/)
12+
[![Go Reference](https://pkg.go.dev/badge/github.com/bugsnag/bugsnag-go.svg)](https://pkg.go.dev/github.com/bugsnag/bugsnag-go)
13+
[![Build status](https://github.com/bugsnag/bugsnag-go/actions/workflows/test-package.yml/badge.svg?branch=master)](https://buildkite.com/bugsnag/bugsnag-go)
514

615
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.
716

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

1019
## Features
1120

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

1726
## Getting Started
1827

19-
1. [Create a Bugsnag account](https://bugsnag.com)
28+
1. [Create a BugSnag account](https://bugsnag.com)
2029
2. Complete the instructions in the integration guide for your framework:
21-
* [Martini](https://docs.bugsnag.com/platforms/go/martini)
22-
* [Negroni](https://docs.bugsnag.com/platforms/go/negroni)
23-
* [net/http](https://docs.bugsnag.com/platforms/go/net-http)
24-
* [Revel](https://docs.bugsnag.com/platforms/go/revel)
25-
* [Other Go apps](https://docs.bugsnag.com/platforms/go/other)
30+
* [Gin](https://docs.bugsnag.com/platforms/go/gin/)
31+
* [Negroni](https://docs.bugsnag.com/platforms/go/negroni/)
32+
* [net/http](https://docs.bugsnag.com/platforms/go/net-http/)
33+
* [Revel](https://docs.bugsnag.com/platforms/go/revel/)
34+
* [Other Go apps](https://docs.bugsnag.com/platforms/go/other/)
2635
3. Relax!
2736

2837
## Support
2938

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

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

4447
## License
4548

46-
The Bugsnag exception reporter for Go is free software released under the MIT License. See [LICENSE.txt](LICENSE.txt) for details.
49+
The BugSnag error reporter for Go is free software released under the MIT License. See [LICENSE.txt](LICENSE.txt) for details.

doc.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Package bugsnag captures errors in real-time and reports them to Bugsnag (http://bugsnag.com).
2+
Package bugsnag captures errors in real-time and reports them to BugSnag (http://bugsnag.com).
33
44
Using bugsnag-go is a three-step process.
55
@@ -17,35 +17,33 @@ when you call ListenAndServer:
1717
1818
http.ListenAndServe(":8080", bugsnag.Handler(nil))
1919
20-
If that's not possible, you can also wrap each
21-
HTTP handler manually:
20+
If that's not possible, you can also wrap each HTTP handler manually:
2221
2322
http.HandleFunc("/" bugsnag.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
2423
...
2524
})
2625
27-
3. To notify Bugsnag of an error that is not a panic, pass it to bugsnag.Notify. This will also
26+
3. To notify BugSnag of an error that is not a panic, pass it to bugsnag.Notify. This will also
2827
log the error message using the configured Logger.
2928
3029
if err != nil {
3130
bugsnag.Notify(err)
3231
}
3332
34-
For detailed integration instructions see https://bugsnag.com/docs/notifiers/go.
33+
For detailed integration instructions see https://docs.bugsnag.com/platforms/go.
3534
36-
Configuration
35+
# Configuration
3736
38-
The only required configuration is the Bugsnag API key which can be obtained by clicking "Settings"
39-
on the top of https://bugsnag.com/ after signing up. We also recommend you set the ReleaseStage,
40-
AppType, and AppVersion if these make sense for your deployment workflow.
37+
The only required configuration is the BugSnag API key which can be obtained by clicking "Project
38+
Settings" on the top of your BugSnag dashboard after signing up. We also recommend you set the
39+
ReleaseStage, AppType, and AppVersion if these make sense for your deployment workflow.
4140
42-
RawData
41+
# RawData
4342
44-
If you need to attach extra data to Bugsnag notifications you can do that using
45-
the rawData mechanism. Most of the functions that send errors to Bugsnag allow
46-
you to pass in any number of interface{} values as rawData. The rawData can
47-
consist of the Severity, Context, User or MetaData types listed below, and
48-
there is also builtin support for *http.Requests.
43+
If you need to attach extra data to BugSnag events, you can do that using the rawData mechanism.
44+
Most of the functions that send errors to BugSnag allow you to pass in any number of interface{}
45+
values as rawData. The rawData can consist of the Severity, Context, User or MetaData types listed
46+
below, and there is also builtin support for *http.Requests.
4947
5048
bugsnag.Notify(err, bugsnag.SeverityError)
5149

features/fixtures/app/main.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func multipleUnhandled() {
130130
defer notifier.AutoNotify(ctx)
131131
panic("oops")
132132
}
133+
133134
//go:noinline
134135
func unhandledCrash() {
135136
// Invalid type assertion, will panic
@@ -259,17 +260,17 @@ func handledToUnhandled() {
259260
}
260261

261262
type customErr struct {
262-
msg string
263-
cause error
263+
msg string
264+
cause error
264265
callers []uintptr
265266
}
266267

267268
func newCustomErr(msg string, cause error) error {
268269
callers := make([]uintptr, 8)
269270
runtime.Callers(2, callers)
270-
return customErr {
271-
msg: msg,
272-
cause: cause,
271+
return customErr{
272+
msg: msg,
273+
cause: cause,
273274
callers: callers,
274275
}
275276
}
@@ -297,7 +298,7 @@ func nestedHandledError() {
297298
if val, err := checkValue(i); err != nil {
298299
fmt.Printf("err: %v, val: %d", err, val)
299300
}
300-
if val, err := checkValue(i-46); err != nil {
301+
if val, err := checkValue(i - 46); err != nil {
301302
fmt.Printf("err: %v, val: %d", err, val)
302303
}
303304

@@ -317,7 +318,7 @@ func login(token string) error {
317318
func checkValue(i int) (int, error) {
318319
if i < 0 {
319320
return 0, newCustomErr("invalid token", nil)
320-
} else if i % 2 == 0 {
321+
} else if i%2 == 0 {
321322
return i / 2, nil
322323
} else if i < 9 {
323324
return i * 3, nil

features/fixtures/docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ services:
1919
- PARAMS_FILTERS
2020
- SYNCHRONOUS
2121
- SERVER_PORT
22+
- BUGSNAG_SOURCE_ROOT
23+
- BUGSNAG_PROJECT_PACKAGES
2224
restart: "no"
2325

2426
autoconfigure:
@@ -72,6 +74,8 @@ services:
7274
- AUTO_CAPTURE_SESSIONS
7375
- SYNCHRONOUS
7476
- SERVER_PORT
77+
- BUGSNAG_SOURCE_ROOT
78+
- BUGSNAG_PROJECT_PACKAGES
7579
restart: "no"
7680
command: go run main.go
7781

@@ -97,6 +101,8 @@ services:
97101
- AUTO_CAPTURE_SESSIONS
98102
- SYNCHRONOUS
99103
- SERVER_PORT
104+
- BUGSNAG_SOURCE_ROOT
105+
- BUGSNAG_PROJECT_PACKAGES
100106
restart: "no"
101107
command: go run main.go
102108

@@ -121,6 +127,8 @@ services:
121127
- AUTO_CAPTURE_SESSIONS
122128
- SYNCHRONOUS
123129
- SERVER_PORT
130+
- BUGSNAG_SOURCE_ROOT
131+
- BUGSNAG_PROJECT_PACKAGES
124132
restart: "no"
125133
command: go run main.go
126134

@@ -146,6 +154,8 @@ services:
146154
- AUTO_CAPTURE_SESSIONS
147155
- SYNCHRONOUS
148156
- SERVER_PORT
157+
- BUGSNAG_SOURCE_ROOT
158+
- BUGSNAG_PROJECT_PACKAGES
149159
restart: "no"
150160
command: go run main.go
151161

@@ -173,5 +183,7 @@ services:
173183
- SYNCHRONOUS
174184
- SERVER_PORT
175185
- USE_PROPERTIES_FILE_CONFIG
186+
- BUGSNAG_SOURCE_ROOT
187+
- BUGSNAG_PROJECT_PACKAGES
176188
restart: "no"
177189
command: ./test/run.sh

features/handled.feature

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Feature: Plain handled errors
22

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

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

5455
Scenario: Unwrapping the causes of a handled error
5556
When I run the go service "app" with the test case "nested-error"
@@ -58,12 +59,12 @@ Scenario: Unwrapping the causes of a handled error
5859
And the event "unhandled" is false
5960
And the event "severity" equals "warning"
6061
And the event "exceptions.0.message" equals "terminate process"
61-
And the "lineNumber" of stack frame 0 equals 291
62+
And the "lineNumber" of stack frame 0 equals 292
6263
And the "file" of stack frame 0 equals "main.go"
6364
And the "method" of stack frame 0 equals "nestedHandledError"
6465
And the event "exceptions.1.message" equals "login failed"
6566
And the event "exceptions.1.stacktrace.0.file" equals "main.go"
66-
And the event "exceptions.1.stacktrace.0.lineNumber" equals 311
67+
And the event "exceptions.1.stacktrace.0.lineNumber" equals 312
6768
And the event "exceptions.2.message" equals "invalid token"
6869
And the event "exceptions.2.stacktrace.0.file" equals "main.go"
69-
And the event "exceptions.2.stacktrace.0.lineNumber" equals 319
70+
And the event "exceptions.2.stacktrace.0.lineNumber" equals 320

features/net-http/handled.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Feature: Handled errors
22

33
Background:
44
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
5+
Given I set environment variable "BUGSNAG_SOURCE_ROOT" to the app directory
56
And I configure the bugsnag endpoint
67
And I set environment variable "SERVER_PORT" to "4512"
78
And I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"

features/plain_features/panics.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Feature: Panic handling
22

33
Background:
44
Given I set environment variable "API_KEY" to "a35a2a72bd230ac0aa0f52715bbdc6aa"
5+
Given I set environment variable "BUGSNAG_SOURCE_ROOT" to the app directory
56
And I configure the bugsnag endpoint
67
And I have built the service "app"
78
And I set environment variable "AUTO_CAPTURE_SESSIONS" to "false"

v2/bugsnag.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
)
2222

2323
// Version defines the version of this Bugsnag notifier
24-
const Version = "2.2.1"
24+
const Version = "2.3.0"
2525

2626
var panicHandlerOnce sync.Once
2727
var sessionTrackerOnce sync.Once

v2/configuration.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,7 @@ func (config *Configuration) isProjectPackage(_pkg string) bool {
232232
}
233233

234234
func (config *Configuration) stripProjectPackages(file string) string {
235-
trimmedFile := file
236-
if strings.HasPrefix(trimmedFile, config.SourceRoot) {
237-
trimmedFile = strings.TrimPrefix(trimmedFile, config.SourceRoot)
238-
}
235+
trimmedFile := strings.TrimPrefix(file, config.SourceRoot)
239236
for _, p := range config.ProjectPackages {
240237
if len(p) > 2 && p[len(p)-2] == '/' && p[len(p)-1] == '*' {
241238
p = p[:len(p)-1]

0 commit comments

Comments
 (0)