Skip to content

[ActiveRecord] Add Attributes for Async Queries #1219

Open
@arielvalentin

Description

ActiveRecord 7.1 introduced async query methods1, which leverages concurrency primitives via Promise API to defer executing queries.

We would like to enrich ActiveRecord related spans to know whether or not they were executed from the async context.

Additional Notes

The sql.active_record notification payload includes a async attribute:
https://github.com/rails/rails/blob/616d3a7675c18ae2d38d3116de47e2e7308cfbd8/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb#L1135

We may be able to enrich the ActiveRecord span and amend it as a Shared DB attribute for the driver itself however we do not currently use notifications in this instrumentation.

Worst case scenario, we monkey patch existing async methods, concurrency primitives.

Footnotes

  1. https://github.com/rails/rails/pull/44446

Metadata

Assignees

Labels

featureNew feature or requestinstrumentationkeepEnsures stale-bot keeps this issue/PR open

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions