Add Lograge structured logging and Honeybadger deploy notifications#1558
Open
maebeale wants to merge 2 commits into
Open
Add Lograge structured logging and Honeybadger deploy notifications#1558maebeale wants to merge 2 commits into
maebeale wants to merge 2 commits into
Conversation
Document Honeybadger, OpenTelemetry/Honeycomb, and audit logging in the key gems table for agent reference. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Production needs queryable request logs and visibility into when deploys happen so errors can be correlated to releases. Lograge emits one JSON line per request (guarded to non-local envs), a Vector reference config forwards those lines to Honeybadger Insights, and a GitHub Actions workflow pings Honeybadger's deploy API on every push to main. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds structured request logging and deploy markers so production behavior can be queried and correlated with releases in Honeybadger (Insights + deploy notifications).
Changes:
- Add
logrageand a Rails initializer to emit JSON per-request logs (non-local envs), enriching logs with request/user metadata. - Add a reference Vector config to tail Rails logs and forward parsed events to Honeybadger Insights.
- Add a GitHub Actions workflow to notify Honeybadger of deploys on pushes to
main, and document the observability stack inAGENTS.md.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| Gemfile | Adds the lograge dependency. |
| Gemfile.lock | Locks lograge and its transitive dependencies. |
| config/initializers/lograge.rb | Enables Lograge JSON request logging and adds custom fields. |
| config/vector/vector.yaml | Reference Vector pipeline for shipping Lograge output to Honeybadger Insights. |
| .github/workflows/honeybadger-deploy.yml | Notifies Honeybadger Deploys API on pushes to main. |
| AGENTS.md | Documents Honeybadger + OpenTelemetry + Lograge in the stack overview. |
Comment on lines
+10
to
+28
| config.lograge.custom_options = lambda do |event| | ||
| exceptions = %w[controller action format id] | ||
| params = event.payload[:params]&.except(*exceptions) || {} | ||
|
|
||
| { | ||
| request_id: event.payload[:headers]&.fetch("action_dispatch.request_id", nil), | ||
| user_id: event.payload[:user_id], | ||
| remote_ip: event.payload[:remote_ip], | ||
| params: params, | ||
| time: Time.current.iso8601(3) | ||
| }.compact | ||
| end | ||
|
|
||
| config.lograge.custom_payload do |controller| | ||
| { | ||
| user_id: controller.current_user&.id, | ||
| remote_ip: controller.request.remote_ip | ||
| } | ||
| end |
Comment on lines
+3
to
+4
| config.lograge.enabled = true | ||
| config.lograge.formatter = Lograge::Formatters::Json.new |
Comment on lines
+14
to
+19
| source: | | ||
| payload, err = parse_json(string!(.message)) | ||
| if err == null { | ||
| .payload = payload | ||
| del(.message) | ||
| } |
Comment on lines
+27
to
+29
| headers: | ||
| X-API-Key: "PROJECT_API_KEY" | ||
| encoding: |
Comment on lines
+12
to
+19
| env: | ||
| HONEYBADGER_API_KEY: ${{ secrets.HONEYBADGER_API_KEY }} | ||
| run: | | ||
| curl --silent --show-error --fail \ | ||
| -X POST https://api.honeybadger.io/v1/deploys \ | ||
| -H "X-API-Key: $HONEYBADGER_API_KEY" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d "{\"deploy\":{\"environment\":\"production\",\"revision\":\"${{ github.sha }}\",\"repository\":\"${{ github.repository }}\",\"local_username\":\"${{ github.actor }}\"}}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the goal of this PR and why is this important?
How did you approach the change?
logragegem and aconfig/initializers/lograge.rbinitializer that emits one JSON line per request, guarded to non-local environments (unless Rails.env.local?).request_id,user_id,remote_ip, filteredparams, and an ISO8601 timestamp; health-check requests to/upare ignored.config/vector/vector.yamlas a reference Vector config (not loaded by Rails) that tails the app log and forwards parsed JSON to the Honeybadger Insights events endpoint..github/workflows/honeybadger-deploy.ymlto notify Honeybadger's deploy API on every push tomain.AGENTS.mdto document Lograge under structured logging.Anything else to add?
HONEYBADGER_API_KEYbeing configured on the server / in repo secrets respectively.🤖 Generated with Claude Code