-
Notifications
You must be signed in to change notification settings - Fork 15
feat(insights): add events support #56
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds Honeybadger Insights events support with asynchronous batching, retry logic, and throttling capabilities. Events are queued and sent in configurable batches with support for filtering/modification through BeforeEvent hooks.
Key changes:
- Event batching system with configurable batch size and timeout
- Retry logic with exponential backoff and throttling support
- Queue management with automatic dropping of oldest events when at capacity
- BeforeEvent callback system for event filtering and modification
- Zerolog adapter for sending logs as Insights events
Reviewed Changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated 7 comments.
Show a summary per file
File | Description |
---|---|
event.go | Defines event payload structure and creation logic |
events_worker.go | Implements asynchronous event batching and sending worker |
ring_buffer.go | Provides circular buffer for efficient event queuing |
client.go | Adds Event method and BeforeEvent handler support |
configuration.go | Adds events-related configuration options |
server.go | Updates HTTP client to support events endpoint and JSONL format |
honeybadger.go | Adds public Event and BeforeEvent functions |
null_backend.go | Adds Event method to null backend implementation |
zerolog/ | New zerolog adapter package for sending logs as events |
go.mod | Updates Go version and dependencies |
README.md | Documents new events functionality |
Makefile | Updates linting tools |
*_test.go | Comprehensive test coverage for events functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
case 403: | ||
return ErrUnauthorized | ||
default: | ||
bodyBytes, _ := ioutil.ReadAll(resp.Body) |
Copilot
AI
Oct 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ioutil
package is deprecated since Go 1.16. Use io.ReadAll
instead.
Copilot uses AI. Check for mistakes.
fmt.Println("First attempt", string(req1.Body)) | ||
req1.Response <- 500 | ||
|
||
req2 := <-control | ||
fmt.Println("Second attempt", string(req2.Body)) | ||
req2.Response <- 500 | ||
|
||
req3 := <-control | ||
fmt.Println("Third attempt", string(req3.Body)) |
Copilot
AI
Oct 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug print statements should be removed from test code or replaced with proper test logging using t.Logf().
fmt.Println("First attempt", string(req1.Body)) | |
req1.Response <- 500 | |
req2 := <-control | |
fmt.Println("Second attempt", string(req2.Body)) | |
req2.Response <- 500 | |
req3 := <-control | |
fmt.Println("Third attempt", string(req3.Body)) | |
t.Logf("First attempt %s", string(req1.Body)) | |
req1.Response <- 500 | |
req2 := <-control | |
t.Logf("Second attempt %s", string(req2.Body)) | |
req2.Response <- 500 | |
req3 := <-control | |
t.Logf("Third attempt %s", string(req3.Body)) |
Copilot uses AI. Check for mistakes.
fmt.Println("First attempt", string(req1.Body)) | ||
req1.Response <- 500 | ||
|
||
req2 := <-control | ||
fmt.Println("Second attempt", string(req2.Body)) | ||
req2.Response <- 500 | ||
|
||
req3 := <-control | ||
fmt.Println("Third attempt", string(req3.Body)) |
Copilot
AI
Oct 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug print statements should be removed from test code or replaced with proper test logging using t.Logf().
fmt.Println("First attempt", string(req1.Body)) | |
req1.Response <- 500 | |
req2 := <-control | |
fmt.Println("Second attempt", string(req2.Body)) | |
req2.Response <- 500 | |
req3 := <-control | |
fmt.Println("Third attempt", string(req3.Body)) | |
t.Logf("First attempt %s", string(req1.Body)) | |
req1.Response <- 500 | |
req2 := <-control | |
t.Logf("Second attempt %s", string(req2.Body)) | |
req2.Response <- 500 | |
req3 := <-control | |
t.Logf("Third attempt %s", string(req3.Body)) |
Copilot uses AI. Check for mistakes.
fmt.Println("First attempt", string(req1.Body)) | ||
req1.Response <- 500 | ||
|
||
req2 := <-control | ||
fmt.Println("Second attempt", string(req2.Body)) | ||
req2.Response <- 500 | ||
|
||
req3 := <-control | ||
fmt.Println("Third attempt", string(req3.Body)) |
Copilot
AI
Oct 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug print statements should be removed from test code or replaced with proper test logging using t.Logf().
fmt.Println("First attempt", string(req1.Body)) | |
req1.Response <- 500 | |
req2 := <-control | |
fmt.Println("Second attempt", string(req2.Body)) | |
req2.Response <- 500 | |
req3 := <-control | |
fmt.Println("Third attempt", string(req3.Body)) | |
t.Logf("First attempt %s", string(req1.Body)) | |
req1.Response <- 500 | |
req2 := <-control | |
t.Logf("Second attempt %s", string(req2.Body)) | |
req2.Response <- 500 | |
req3 := <-control | |
t.Logf("Third attempt %s", string(req3.Body)) |
Copilot uses AI. Check for mistakes.
maxQueueSize: cfg.EventsMaxQueueSize, | ||
maxRetries: cfg.EventsMaxRetries, | ||
throttleWait: cfg.EventsThrottleWait, | ||
logger: cfg.Logger, |
Copilot
AI
Oct 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number '+1' appears twice without explanation. Consider adding a comment explaining why the buffer size is batch size + 1.
logger: cfg.Logger, | |
logger: cfg.Logger, | |
// The ring buffer size is batchSize + 1 to distinguish full from empty states. |
Copilot uses AI. Check for mistakes.
if len(events) > 0 { | ||
w.batches = append(w.batches, &Batch{events: events, attempts: 0}) | ||
} | ||
w.queue = newRingBuffer(w.batchSize + 1) |
Copilot
AI
Oct 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number '+1' appears twice without explanation. Consider adding a comment explaining why the buffer size is batch size + 1.
Copilot uses AI. Check for mistakes.
if q.size == q.cap { | ||
return false | ||
} // full |
Copilot
AI
Oct 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The comment '// full' should be on the same line as the if statement or properly formatted as a block comment for better readability.
if q.size == q.cap { | |
return false | |
} // full | |
if q.size == q.cap { // full | |
return false | |
} |
Copilot uses AI. Check for mistakes.
Only run tests against the supported runtimes & add blurb about it in the README.
Status
WIP
Description
Adds Honeybadger Insights events support with batching, retry logic, and throttling. Events
are queued and sent asynchronously in configurable batches. Includes BeforeEvent hooks for
filtering/modifying events before sending.
Key features:
Related PRs
None
Todos