Skip to content

Include user context in a newly built Error#1644

Open
aleksandrs-ledovskis wants to merge 1 commit into
elastic:mainfrom
aleksandrs-ledovskis:fix/error-inherits-transaction-user
Open

Include user context in a newly built Error#1644
aleksandrs-ledovskis wants to merge 1 commit into
elastic:mainfrom
aleksandrs-ledovskis:fix/error-inherits-transaction-user

Conversation

@aleksandrs-ledovskis

@aleksandrs-ledovskis aleksandrs-ledovskis commented Jun 22, 2026

Copy link
Copy Markdown

What does this pull request do?

Captured errors now inherit the ElasticAPM::Context::User of the active transaction.

ErrorBuilder#add_current_transaction_fields already copies the transaction's labels and custom context onto each error, but silently omitted user - so errors reported during an authenticated request arrived with no user, even though the transaction (set via ElasticAPM.set_user) had one.

An explicitly-set error user takes precedence; otherwise the transaction's user is inherited. This aligns the Ruby agent with the Node.js' (1, 2), and Python's (1, 2) Elastic APM agents - all attaching the transaction's user to captured errors.

Why is it important?

Lacking a user's information the error metadata is less valuable. Cross-referencing with a specific set of circumstances is harder and more time consuming.

Checklist

  • I have signed the Contributor License Agreement.
  • My code follows the style guidelines of this project (See .rubocop.yml)
  • I have rebased my changes on top of the latest main branch
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Related issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant