Last active
October 30, 2019 11:49
-
-
Save mikhailov/a4cef2f26456894f5d8caf5a72000d73 to your computer and use it in GitHub Desktop.
Datadog APM instrumentation to have SQL Time for every event
This file contains 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
ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args| | |
event = ActiveSupport::Notifications::Event.new(*args) | |
span = Datadog.tracer.active_span | |
payload = event.payload | |
if span && payload.key?(:db_runtime) | |
db_runtime = payload[:db_runtime].to_f.round(3) | |
span.set_tag('database.sql_time', db_runtime) | |
end | |
end | |
# MIT License |
Author
mikhailov
commented
Oct 28, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment