{"id":13878280,"url":"https://github.com/rubyatscale/singed","last_synced_at":"2025-06-19T11:06:54.058Z","repository":{"id":65619573,"uuid":"430897839","full_name":"rubyatscale/singed","owner":"rubyatscale","description":"Get a flamegraph anywhere in your code base. Powered by stackprof, rbspy, and speedscope","archived":false,"fork":false,"pushed_at":"2025-05-21T00:25:25.000Z","size":81,"stargazers_count":412,"open_issues_count":12,"forks_count":11,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-06-11T15:14:31.773Z","etag":null,"topics":["flamegraphs","rails","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubyatscale.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-11-22T23:34:46.000Z","updated_at":"2025-05-21T00:24:03.000Z","dependencies_parsed_at":"2025-05-21T00:37:42.130Z","dependency_job_id":null,"html_url":"https://github.com/rubyatscale/singed","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/rubyatscale/singed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyatscale%2Fsinged","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyatscale%2Fsinged/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyatscale%2Fsinged/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyatscale%2Fsinged/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubyatscale","download_url":"https://codeload.github.com/rubyatscale/singed/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyatscale%2Fsinged/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260739049,"owners_count":23055073,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flamegraphs","rails","ruby"],"created_at":"2024-08-06T08:01:44.997Z","updated_at":"2025-06-19T11:06:49.046Z","avatar_url":"https://github.com/rubyatscale.png","language":"Ruby","readme":"# Singed\n\nSinged makes it easy to get a flamegraph anywhere in your code base. It wraps profiling your code with [stackprof](https://github.com/tmm1/stackprof) or [rbspy](https://github.com/rbspy/rbspy), and then launching [speedscope](https://github.com/jlfwong/speedscope) to view it.\n\n## Installation\n\nAdd to `Gemfile`:\n\n```ruby\ngem \"singed\"\n```\n\nThen run `bundle install`\n\nThen run `npm install -g speedscope`\n\n## Usage\n\nSimplest is calling with a block:\n\n```ruby\nflamegraph {\n  # your code here\n}\n```\n\nFlamegraphs are saved for later review to `Singed.output_directory`, which is `tmp/speedscope` on Rails. You can adjust this like:\n\n```ruby\nSinged.output_directory = \"tmp/slowness-exploration\"\n```\n\n### Blockage\nIf you are calling it in a loop, or with different variations, you can include a label on the filename:\n\n```ruby\nflamegraph(\"rspec\") {\n  # your code here\n}\n```\n\nYou can also skip opening speedscope automatically:\n\n```ruby\nflamegraph(open: false) {\n  # your code here\n}\n```\n\n### RSpec\n\nIf you are using RSpec, you can use the `flamegraph` metadata to capture it for you.\n\n```ruby\n# make sure this is required at somepoint, like in a spec/support file!\nrequire 'singed/rspec' \n\nRSpec.describe YourClass do\n  it \"is slow :(\", flamegraph: true do\n    # your code here\n  end\nend\n```\n\n### Controllers\n\nIf you want to capture a flamegraph of a controller action, you can call it like:\n\n```ruby\nclass EmployeesController \u003c ApplicationController\n  flamegraph :show\n\n  def show\n    # your code here\n  end\nend\n```\n\nThis won't catch the entire request though, just once it's been routed to controller and a response has been served (ie no middleware).\n\n### Rack/Rails requests\n\nTo capture the whole request, there is a middleware which checks for the  `X-Singed` header to be 'true'. With curl, you can do this like:\n\n```shell\ncurl -H 'X-Singed: true' https://localhost:3000\n```\n\nPROTIP: use Chrome Developer Tools to record network activity, and copy requests as a curl command. Add `-H 'X-Singed: true'` to it, and you get flamegraphs!\n\nThis can also be enabled to always run by setting `SINGED_MIDDLEWARE_ALWAYS_CAPTURE=1`  in the environment.\n\n### Command Line\n\nThere is a `singed` command line you can use that will record a flamegraph from the entirety of a command run:\n\n```shell\n$ bundle binstub singed # if you want to be able to call it like bin/singed\n$ bundle exec singed -- bin/rails runner 'Model.all.to_a'\n```\n\nThe flamegraph is opened afterwards.\n\n\n## Limitations\n\nWhen using the auto-opening feature, it's assumed that you are have a browser available on the same host you are profiling code.\n\nThe `open` is expected to be available.\n\n## Alternatives\n\n- using [rbspy](https://rbspy.github.io/) directly\n- using [stackprof](https://github.com/tmm1/stackprof) (a dependency of singed) directly\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyatscale%2Fsinged","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyatscale%2Fsinged","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyatscale%2Fsinged/lists"}