https://github.com/tmm1/rbtrace
like strace, but for ruby code
https://github.com/tmm1/rbtrace
Keywords from Contributors
rubygem activejob activerecord mvc feature-flag rack data-validation feature-toggle ruby-gem feature
Last synced: about 6 hours ago
JSON representation
Repository metadata
like strace, but for ruby code
- Host: GitHub
- URL: https://github.com/tmm1/rbtrace
- Owner: tmm1
- License: mit
- Created: 2011-02-10T06:20:11.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2025-12-03T04:19:46.000Z (3 months ago)
- Last Synced: 2026-02-20T05:55:28.118Z (11 days ago)
- Language: Ruby
- Homepage:
- Size: 1.44 MB
- Stars: 1,723
- Watchers: 30
- Forks: 70
- Open Issues: 26
- Releases: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
README.md
rbtrace: like strace, but for ruby code
rbtrace shows you method calls happening inside another ruby process in real
time.
rbtrace works on ruby 1.8 through 2.2 (and beyond), running on linux or mac
osx.
rbtrace is designed to have minimal overhead, and should be safe to run
in production.
usage
% gem install rbtrace
% rbtrace --help
supported Rubies
rbtrace supports all stable versions of Ruby MRI, as of 23-01-2018 this is
Ruby version 2.2 and later.
tracer types
rbtrace has several different tracing modes.
firehose: show everything
% rbtrace -p <PID> --firehose
slow: show any method calls that take longer than <N> milliseconds
% rbtrace -p <PID> --slow=<N>
methods: trace calls to specific methods
% rbtrace -p <PID> --methods "Kernel#sleep" "Proc#call"
gc: trace garbage collections
% rbtrace -p <PID> --gc
memory: produce a basic memory report regarding process (including GC.stat and ObjectSpace stats)
% rbtrace -p <PID> --memory
backtraces: return backtraces for all active threads in a process
% rbtrace -p <PID> --backtraces
notes
--firehose is not reliable on osx.
--slow, --gc and --methods can be combined.
predefined tracers
rbtrace also includes a set of predefined tracers
for popular ruby libraries and functions.
trace calls to activerecord adapters and any i/o functions
% rbtrace -p <PID> -c activerecord io
detailed example
require rbtrace into a process
% cat server.rb
require 'rbtrace'
class String
def multiply_vowels(num)
@test = 123
gsub(/[aeiou]/){ |m| m*num }
end
end
while true
proc {
Dir.chdir("/tmp") do
Dir.pwd
Process.pid
'hello'.multiply_vowels(3)
sleep rand*0.5
end
}.call
end
run the process
% ruby server.rb &
[1] 87854
trace a function using the process's pid
% rbtrace -p 87854 -m sleep
*** attached to process 87854
Kernel#sleep <0.138615>
Kernel#sleep <0.147726>
Kernel#sleep <0.318728>
Kernel#sleep <0.338173>
Kernel#sleep <0.373004>
Kernel#sleep
*** detached from process 87854
trace everything
% rbtrace -p 87854 --firehose
*** attached to process 87938
Kernel#proc <0.000082>
Proc#call
Dir.chdir
Dir.pwd <0.000060>
Process.pid <0.000021>
String#multiply_vowels
String#gsub
String#* <0.000023>
String#* <0.000022>
String#gsub <0.000127>
String#multiply_vowels <0.000175>
Kernel#rand <0.000018>
Float#* <0.000022>
Kernel#sleep <0.344281>
Dir.chdir <0.344858>
Proc#call <0.344908>
*** detached from process 87938
trace specific functions
% rbtrace -p 87854 -m sleep Dir.chdir Dir.pwd Process.pid "String#gsub" "String#*"
*** attached to process 87854
Dir.chdir
Dir.pwd <0.000023>
Process.pid <0.000008>
String#gsub
String#* <0.000008>
String#* <0.000007>
String#gsub <0.000050>
Kernel#sleep <0.498809>
Dir.chdir <0.499025>
Dir.chdir
Dir.pwd <0.000024>
Process.pid <0.000008>
String#gsub
String#* <0.000008>
String#* <0.000007>
String#gsub <0.000050>
Kernel#sleep
*** detached from process 87854
trace all functions in a class/module
% rbtrace -p 87854 -m "Kernel#"
*** attached to process 87854
Kernel#proc <0.000062>
Kernel#rand <0.000010>
Kernel#sleep <0.218677>
Kernel#proc <0.000016>
Kernel#rand <0.000010>
Kernel#sleep <0.195914>
Kernel#proc <0.000016>
Kernel#rand <0.000009>
Kernel#sleep
*** detached from process 87854
get values of variables and other expressions
% rbtrace -p 87854 -m "String#gsub(self, @test)" "String#*(self, __source__)" "String#multiply_vowels(self, self.length, num)"
*** attached to process 87854
String#multiply_vowels(self="hello", self.length=5, num=3)
String#gsub(self="hello", @test=123)
String#*(self="e", __source__="server.rb:6") <0.000020>
String#*(self="o", __source__="server.rb:6") <0.000018>
String#gsub <0.000085>
String#multiply_vowels <0.000198>
String#multiply_vowels(self="hello", self.length=5, num=3)
String#gsub(self="hello", @test=123)
String#*(self="e", __source__="server.rb:6") <0.000020>
String#*(self="o", __source__="server.rb:6") <0.000020>
String#gsub <0.000102>
String#multiply_vowels <0.000218>
*** detached from process 87854
watch for method calls slower than 250ms
% rbtrace -p 87854 --slow=250
*** attached to process 87854
Kernel#sleep <0.459628>
Dir.chdir <0.459828>
Proc#call <0.459849>
Kernel#sleep <0.484666>
Dir.chdir <0.484804>
Proc#call <0.484818>
*** detached from process 87854
todo
- correct irb implementation so it establishes a dedicated channel
- add triggers to start tracing slow methods only inside another method
- add watch expressions to fire tracers only when an expression is true
- add special expressions for method args (arg0, arguments)
- optimize local variable lookup to avoid instance_eval
- investigate mach_msg on osx since msgget(2) has hard kernel limits
Owner metadata
- Name: Aman Karmani
- Login: tmm1
- Email:
- Kind: user
- Description: building Cursor @anysphere. formerly @github, creator of the merge button. founder @fancybits contributor to golang and ffmpeg.
- Website:
- Location: California
- Twitter: tmm1
- Company:
- Icon url: https://avatars.githubusercontent.com/u/2567?u=2d06deeb46222b8e0f6218598f806ecad70367a4&v=4
- Repositories: 438
- Last ynced at: 2025-09-29T16:40:46.179Z
- Profile URL: https://github.com/tmm1
GitHub Events
Total
- Pull request event: 5
- Fork event: 3
- Issues event: 3
- Watch event: 12
- Issue comment event: 4
- Push event: 2
- Pull request review event: 2
- Pull request review comment event: 3
Last Year
- Pull request event: 5
- Fork event: 2
- Issues event: 3
- Watch event: 9
- Issue comment event: 4
- Push event: 2
- Pull request review event: 2
- Pull request review comment event: 3
Committers metadata
Last synced: 1 day ago
Total Commits: 306
Total Committers: 32
Avg Commits per committer: 9.563
Development Distribution Score (DDS): 0.203
Commits in past year: 4
Committers in past year: 3
Avg Commits per committer in past year: 1.333
Development Distribution Score (DDS) in past year: 0.5
| Name | Commits | |
|---|---|---|
| Aman Gupta | a****n@t****t | 244 |
| Sam | s****n@g****m | 16 |
| Jean Boussier | j****r@g****m | 7 |
| Aaron Quint | a****n@q****m | 5 |
| Daniel Waterworth | me@d****m | 4 |
| Lin Jen-Shin | g****t@g****g | 3 |
| OsamaSayegh | a****0@g****m | 2 |
| Attila Horváth | a****h@f****m | 1 |
| Camilo Lopez | c****o@s****m | 1 |
| Charlie Somerville | c****e@c****m | 1 |
| Colin Shea | c****a@e****m | 1 |
| Steve Dierker | s****r@f****m | 1 |
| brunofranco | b****o@r****m | 1 |
| Adam Daniels | a****m@m****a | 1 |
| Adam Roben | a****m@r****g | 1 |
| Brandon Keepers | b****s@g****m | 1 |
| Brendan Weibrecht | b****n@w****u | 1 |
| Chris Alberti | c****o@d****g | 1 |
| Danny Fallon | d****y@i****o | 1 |
| Gabriel Gironda | g****a@g****m | 1 |
| George Claghorn | g****e@b****m | 1 |
| Guilherme Campos | g****a@g****m | 1 |
| Jens Maier | j****s@e****e | 1 |
| Jon Forums | j****s@g****m | 1 |
| Marko Anastasov | m****o@r****m | 1 |
| Rick Hull | r****l@g****m | 1 |
| Ted Nyman | t****d@t****o | 1 |
| Vivien Barousse | v****n@s****m | 1 |
| abicky | t****i@g****m | 1 |
| joshua stein | j****s@j****g | 1 |
| and 2 more... | ||
Committer domains:
- outlook.jp: 1
- kiwicustom.com: 1
- jcs.org: 1
- songkick.com: 1
- ted.io: 1
- renderedtext.com: 1
- elberet.de: 1
- basecamp.com: 1
- intercom.io: 1
- discourse.org: 1
- weibrecht.net.au: 1
- github.com: 1
- roben.org: 1
- mediadrive.ca: 1
- runtime-revolution.com: 1
- flavoursys.com: 1
- evogi.com: 1
- charliesomerville.com: 1
- shopify.com: 1
- fusioneer.com: 1
- godfat.org: 1
- danielwaterworth.com: 1
- quirkey.com: 1
- tmm1.net: 1
Issue and Pull Request metadata
Last synced: 29 days ago
Total issues: 53
Total pull requests: 53
Average time to close issues: 6 months
Average time to close pull requests: 3 months
Total issue authors: 49
Total pull request authors: 36
Average comments per issue: 3.15
Average comments per pull request: 1.15
Merged pull request: 42
Bot issues: 0
Bot pull requests: 0
Past year issues: 3
Past year pull requests: 6
Past year average time to close issues: about 2 hours
Past year average time to close pull requests: 38 minutes
Past year issue authors: 3
Past year pull request authors: 3
Past year average comments per issue: 0.33
Past year average comments per pull request: 0.17
Past year merged pull request: 2
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- ghost (2)
- aquach (2)
- paddor (2)
- sardaukar (2)
- nogweii (1)
- evanworley (1)
- jetztgradnet (1)
- dwo (1)
- georgeclaghorn (1)
- guilherme (1)
- bensheldon (1)
- wjdhamilton (1)
- dgobaud (1)
- wlipa (1)
- yourtallness (1)
Top Pull Request Authors
- casperisfine (6)
- danielwaterworth (4)
- quirkey (3)
- flavorjones (3)
- SamSaffron (3)
- haukot (2)
- nullchristo (2)
- tmm1 (2)
- abicky (1)
- gabrielg (1)
- dannyfallon (1)
- bkeepers (1)
- haileys (1)
- adam12 (1)
- markoa (1)
Top Issue Labels
Top Pull Request Labels
Package metadata
- Total packages: 13
-
Total downloads:
- rubygems: 138,270,019 total
- Total docker downloads: 886,911,900
- Total dependent packages: 12 (may contain duplicates)
- Total dependent repositories: 3,019 (may contain duplicates)
- Total versions: 138
- Total maintainers: 2
gem.coop: rbtrace
rbtrace shows you method calls happening inside another ruby process in real time.
- Homepage: http://github.com/tmm1/rbtrace
- Documentation: http://www.rubydoc.info/gems/rbtrace/
- Licenses: MIT
- Latest release: 0.5.3 (published 3 months ago)
- Last Synced: 2026-03-03T11:31:53.160Z (about 6 hours ago)
- Versions: 50
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 69,150,029 Total
- Docker Downloads: 443,455,950
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.136%
- Downloads: 0.409%
- Maintainers (2)
rubygems.org: rbtrace
rbtrace shows you method calls happening inside another ruby process in real time.
- Homepage: http://github.com/tmm1/rbtrace
- Documentation: http://www.rubydoc.info/gems/rbtrace/
- Licenses: MIT
- Latest release: 0.5.3 (published 3 months ago)
- Last Synced: 2026-03-02T09:03:07.079Z (1 day ago)
- Versions: 50
- Dependent Packages: 12
- Dependent Repositories: 3,019
- Downloads: 69,119,990 Total
- Docker Downloads: 443,455,950
-
Rankings:
- Docker downloads count: 0.317%
- Downloads: 0.42%
- Dependent repos count: 0.571%
- Average: 1.231%
- Stargazers count: 1.239%
- Dependent packages count: 1.536%
- Forks count: 3.304%
- Maintainers (2)
proxy.golang.org: github.com/tmm1/rbtrace
- Homepage:
- Documentation: https://pkg.go.dev/github.com/tmm1/rbtrace#section-documentation
- Licenses: mit
- Latest release: v0.5.3 (published 3 months ago)
- Last Synced: 2026-02-27T10:02:44.846Z (4 days ago)
- Versions: 28
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent packages count: 5.442%
- Average: 5.624%
- Dependent repos count: 5.807%
ubuntu-23.10: ruby-rbtrace
- Homepage: https://github.com/tmm1/rbtrace
- Licenses:
- Latest release: 0.4.14-1build2 (published 18 days ago)
- Last Synced: 2026-02-13T18:31:14.339Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-10: ruby-rbtrace
- Homepage: http://github.com/tmm1/rbtrace
- Documentation: https://packages.debian.org/buster/ruby-rbtrace
- Licenses:
- Latest release: 0.4.10-1 (published 20 days ago)
- Last Synced: 2026-02-13T04:25:04.445Z (19 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-23.04: ruby-rbtrace
- Homepage: https://github.com/tmm1/rbtrace
- Licenses:
- Latest release: 0.4.14-1build2 (published 20 days ago)
- Last Synced: 2026-02-11T06:48:07.635Z (20 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-11: ruby-rbtrace
- Homepage: http://github.com/tmm1/rbtrace
- Documentation: https://packages.debian.org/bullseye/ruby-rbtrace
- Licenses:
- Latest release: 0.4.11-3 (published 21 days ago)
- Last Synced: 2026-02-13T08:24:14.301Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
ubuntu-20.04: ruby-rbtrace
- Homepage: http://github.com/tmm1/rbtrace
- Licenses:
- Latest release: 0.4.11-3build1 (published 18 days ago)
- Last Synced: 2026-02-13T07:21:29.704Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-12: ruby-rbtrace
- Homepage: https://github.com/tmm1/rbtrace
- Documentation: https://packages.debian.org/bookworm/ruby-rbtrace
- Licenses:
- Latest release: 0.4.14-1 (published 19 days ago)
- Last Synced: 2026-02-12T23:39:17.767Z (19 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
debian-13: ruby-rbtrace
- Homepage: https://github.com/tmm1/rbtrace
- Documentation: https://packages.debian.org/trixie/ruby-rbtrace
- Licenses:
- Latest release: 0.5.1-1.1 (published 19 days ago)
- Last Synced: 2026-02-13T13:18:59.113Z (18 days ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
Dependencies
- rake ~> 10.0 development
- ffi >= 1.0.6
- msgpack >= 0.4.3
- optimist >= 3.0.0
- actions/checkout v3 composite
- ruby/setup-ruby v1 composite
Score: 31.680674595405826