Module: Pyroscope
- Defined in:
- lib/pyroscope.rb,
lib/pyroscope/version.rb
Defined Under Namespace
Modules: Rust Classes: Config, Engine
Constant Summary collapse
- VERSION =
x-release-please-version
'1.1.0'.freeze
Class Method Summary collapse
- ._add_tags(tags) ⇒ Object
- ._remove_tags(tags) ⇒ Object
- .configure {|@config| ... } ⇒ Object
- .current_config ⇒ Object
- .initialize_rails_hooks ⇒ Object
- .remove_tags(*tags) ⇒ Object
- .shutdown ⇒ Object
- .stop ⇒ Object
- .tag(tags) ⇒ Object
- .tag_wrapper(tags) ⇒ Object
Class Method Details
._add_tags(tags) ⇒ Object
142 143 144 145 146 |
# File 'lib/pyroscope.rb', line 142 def () .each do |tag_name, tag_value| Rust.add_thread_tag(tag_name.to_s, tag_value.to_s) end end |
._remove_tags(tags) ⇒ Object
148 149 150 151 152 |
# File 'lib/pyroscope.rb', line 148 def () .each do |tag_name, tag_value| Rust.remove_thread_tag(tag_name.to_s, tag_value.to_s) end end |
.configure {|@config| ... } ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/pyroscope.rb', line 72 def configure @config = Config.new # Pass config to the block yield @config # Determine Logging level (kinda like an enum). case @config.log_level when 'trace' @log_level = 10 when 'debug' @log_level = 20 when 'info' @log_level = 30 when 'warn' @log_level = 40 when 'error' @log_level = 50 else @log_level = 50 end Rust.initialize_logging(@log_level) Rust.initialize_agent( # these are defaults in case user-provided values are nil: @config.app_name || @config.application_name || "", @config.server_address || "", @config.basic_auth_username || "", @config.basic_auth_password || "", @config.sample_rate || 100, @config.oncpu || false, @config.report_pid || false, @config.report_thread_id || false, runtime_name, runtime_version, (@config. || {}), @config.tenant_id || "", http_headers_to_json(@config.http_headers || {}) ) end |
.current_config ⇒ Object
68 69 70 |
# File 'lib/pyroscope.rb', line 68 def current_config @config end |
.initialize_rails_hooks ⇒ Object
114 115 116 117 118 119 120 121 122 123 |
# File 'lib/pyroscope.rb', line 114 def initialize_rails_hooks block = lambda do |ctrl, action| Pyroscope.tag_wrapper({ "action" => "#{ctrl.controller_name}/#{ctrl.action_name}" }, &action) end ActionController::API.__send__(:around_action, block) if defined? ActionController::API ActionController::Base.__send__(:around_action, block) if defined? ActionController::Base end |
.remove_tags(*tags) ⇒ Object
138 139 140 |
# File 'lib/pyroscope.rb', line 138 def (*) warn("deprecated. Use `Pyroscope.tag_wrapper` instead.") end |
.shutdown ⇒ Object
158 159 160 |
# File 'lib/pyroscope.rb', line 158 def shutdown stop end |
.stop ⇒ Object
154 155 156 |
# File 'lib/pyroscope.rb', line 154 def stop Rust.drop_agent end |
.tag(tags) ⇒ Object
134 135 136 |
# File 'lib/pyroscope.rb', line 134 def tag() warn("deprecated. Use `Pyroscope.tag_wrapper` instead.") end |
.tag_wrapper(tags) ⇒ Object
125 126 127 128 129 130 131 132 |
# File 'lib/pyroscope.rb', line 125 def tag_wrapper() () begin yield ensure () end end |