Skip to content

Add Lograge structured logging and Honeybadger deploy notifications#1558

Open
maebeale wants to merge 2 commits into
mainfrom
maebeale/add-honeybadger
Open

Add Lograge structured logging and Honeybadger deploy notifications#1558
maebeale wants to merge 2 commits into
mainfrom
maebeale/add-honeybadger

Conversation

@maebeale
Copy link
Copy Markdown
Collaborator

@maebeale maebeale commented Jun 5, 2026

What is the goal of this PR and why is this important?

  • Production currently lacks queryable request logs and any signal for when a deploy happened, making it hard to correlate errors (now captured via Honeybadger) to a specific release.
  • This adds structured logging and deploy markers so request behavior and release boundaries are both visible in Honeybadger Insights.

How did you approach the change?

  • Added the lograge gem and a config/initializers/lograge.rb initializer that emits one JSON line per request, guarded to non-local environments (unless Rails.env.local?).
  • Enriched each log line with request_id, user_id, remote_ip, filtered params, and an ISO8601 timestamp; health-check requests to /up are ignored.
  • Added config/vector/vector.yaml as a reference Vector config (not loaded by Rails) that tails the app log and forwards parsed JSON to the Honeybadger Insights events endpoint.
  • Added .github/workflows/honeybadger-deploy.yml to notify Honeybadger's deploy API on every push to main.
  • Updated AGENTS.md to document Lograge under structured logging.

Anything else to add?

  • The Vector config and the deploy workflow rely on HONEYBADGER_API_KEY being configured on the server / in repo secrets respectively.
  • No UI changes.

🤖 Generated with Claude Code

maebeale and others added 2 commits March 2, 2026 07:11
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>
Copilot AI review requested due to automatic review settings June 5, 2026 13:41
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 structured request logging and deploy markers so production behavior can be queried and correlated with releases in Honeybadger (Insights + deploy notifications).

Changes:

  • Add lograge and 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 in AGENTS.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 thread config/vector/vector.yaml
Comment on lines +14 to +19
source: |
payload, err = parse_json(string!(.message))
if err == null {
.payload = payload
del(.message)
}
Comment thread config/vector/vector.yaml
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 }}\"}}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants