Skip to content

Commit

Permalink
Instrument async queries
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisbernard committed Dec 13, 2024
1 parent e425209 commit 9183d73
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/rorvswild/plugin/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ def finish(name, id, payload)
RorVsWild::Section.stop
end

# Async queries
def publish_event(event)
section = Section.new
section.total_ms = event.payload[:lock_wait]
section.gc_time_ms = event.gc_time
section.commands << normalize_sql_query(event.payload[:sql])
section.kind = "sql"
RorVsWild.agent.add_section(section)
end

SQL_STRING_REGEX = /'((?:''|\\'|[^'])*)'/
SQL_NUMERIC_REGEX = /(?<!\w)\d+(\.\d+)?(?!\w)/
SQL_PARAMETER_REGEX = /\$\d+/
Expand Down

0 comments on commit 9183d73

Please sign in to comment.