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

allow flamegraph gathering #9423

Merged
merged 4 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions sorbet/rbi/shims/flamegraph.rbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# typed: strong
# frozen_string_literal: true

class Flamegraph
sig { params(path: String).void }
def generate(path); end
end
3 changes: 3 additions & 0 deletions updater/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ gem "sentry-opentelemetry", "~> 5.16"
gem "sentry-ruby", "~> 5.16"
gem "terminal-table", "~> 3.0.2"

gem "flamegraph", "~> 0.9.5"
gem "stackprof", "~> 0.2.16"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this is already in common, since we have the functionality in the dry-run script:

spec.add_development_dependency "stackprof", "~> 0.2.16"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you recommend I remove it here and switch that line in common to be spec.add_dependency?


group :test do
common_gemspec = File.expand_path("../common/dependabot-common.gemspec", __dir__)

Expand Down
2 changes: 2 additions & 0 deletions updater/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ GEM
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
rake
flamegraph (0.9.5)
gitlab (4.19.0)
httparty (~> 0.20)
terminal-table (>= 1.5.1)
Expand Down Expand Up @@ -387,6 +388,7 @@ DEPENDENCIES
dependabot-silent!
dependabot-swift!
dependabot-terraform!
flamegraph (~> 0.9.5)
gpgme (~> 2.0)
http (~> 5.1)
octokit (= 6.1.1)
Expand Down
14 changes: 13 additions & 1 deletion updater/bin/update_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
require "dependabot/update_files_command"
require "debug" if ENV["DEBUG"]

flamegraph = ENV.fetch("FLAMEGRAPH", nil)
if flamegraph
require "stackprof"
require "flamegraph"
end

class UpdaterKilledError < StandardError; end

trap("TERM") do
Expand All @@ -30,7 +36,13 @@ class UpdaterKilledError < StandardError; end
end

begin
Dependabot::UpdateFilesCommand.new.run
if flamegraph
Flamegraph.generate("/tmp/dependabot-flamegraph.html") do
Dependabot::UpdateFilesCommand.new.run
end
else
Dependabot::UpdateFilesCommand.new.run
end
rescue Dependabot::RunFailure
exit 1
end