Skip to content
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

[WIP] Add ActiveRecord SQL caller stack #1483

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

sandboxws
Copy link

@sandboxws sandboxws commented Apr 24, 2021

Description

Adds an additional query_caller_stack tag to ActiveRecord spans. The new tag includes the Rails' caller stack that triggered the SQL execution. Including the query caller stack as part of the span significantly improves the ability to trace down slow queries reported by DataDog to the part of the code from which it originated and ultimately fixing the query.

TODO

  • Add specs
  • Add screenshots

@sandboxws sandboxws requested a review from a team April 24, 2021 00:56
@sandboxws sandboxws changed the title Add ActiveRecord SQL caller stack [WIP] Add ActiveRecord SQL caller stack Apr 24, 2021
@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2021

Codecov Report

Merging #1483 (86cba91) into master (c82e5b3) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1483      +/-   ##
==========================================
- Coverage   98.22%   98.22%   -0.01%     
==========================================
  Files         860      860              
  Lines       41271    41278       +7     
==========================================
+ Hits        40538    40544       +6     
- Misses        733      734       +1     
Impacted Files Coverage Δ
lib/ddtrace/contrib/active_record/events/sql.rb 97.56% <100.00%> (+0.12%) ⬆️
lib/ddtrace/contrib/active_record/ext.rb 100.00% <100.00%> (ø)
lib/ddtrace/contrib/active_record/utils.rb 90.90% <100.00%> (+0.90%) ⬆️
spec/ddtrace/contrib/sinatra/activerecord_spec.rb 78.12% <100.00%> (+0.34%) ⬆️
...b/action_pack/action_controller/instrumentation.rb 94.28% <0.00%> (-1.43%) ⬇️
spec/ddtrace/configuration/components_spec.rb 99.80% <0.00%> (-0.01%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c82e5b3...86cba91. Read the comment docs.

@delner delner added community Was opened by a community member feature Involves a product feature integrations Involves tracing integrations labels Apr 29, 2021
@delner
Copy link
Contributor

delner commented Apr 29, 2021

Thanks for the pull request @sandboxws. Can you show us a screenshot of this in action? What does the tag look like?

@sandboxws
Copy link
Author

@delner of course! Will a screenshot of the Ruby hash output suffice or do you prefer a screenshot from an actual DataDog trace from a live product ( i.e. from a DataDog dashboard )?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Was opened by a community member feature Involves a product feature integrations Involves tracing integrations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants