Skip to content

Commit

Permalink
Add Ruby 3.3 marking_time and sweeping_time GC metrics (#5)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrey Novikov <[email protected]>
  • Loading branch information
aroop and Envek authored Jan 4, 2024
1 parent 73ba2ca commit 7f518ca
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## [Unreleased]

- Added support for ruby 3.3 metrics

## [0.1.0] - 2021-02-24

- Initial release
5 changes: 5 additions & 0 deletions lib/yabeda/gc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ module GC

gauge :time, tags: [], comment: "The total time spent in garbage collections" if RUBY_VERSION >= "3.1"

if RUBY_VERSION >= "3.3"
gauge :marking_time, tags: [], comment: "Time spent in the marking phase"
gauge :sweeping_time, tags: [], comment: "Time spent in the sweeping phase"
end

collect do
stats = ::GC.stat

Expand Down
9 changes: 9 additions & 0 deletions spec/yabeda/gc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,13 @@
expect { subject }.to update_yabeda_gauge(Yabeda.gc.time).with(be_a(Integer))
end
end

if RUBY_VERSION >= "3.3"
it "tracks Ruby 3.3 time metrics for GC" do
expect { subject }.to(
update_yabeda_gauge(Yabeda.gc.marking_time).with(be_a(Integer))
.and(update_yabeda_gauge(Yabeda.gc.sweeping_time).with(be_a(Integer)))
)
end
end
end

0 comments on commit 7f518ca

Please sign in to comment.