Module: Pyroscope
- Defined in:
- lib/pyroscope.rb,
lib/pyroscope/version.rb
Defined Under Namespace
Modules: Rust
Classes: Config, Engine
Constant Summary
collapse
- VERSION =
'1.0.9'.freeze
Class Method Summary
collapse
Class Method Details
140
141
142
143
144
|
# File 'lib/pyroscope.rb', line 140
def _add_tags(tags)
tags.each do |tag_name, tag_value|
Rust.add_thread_tag(tag_name.to_s, tag_value.to_s)
end
end
|
146
147
148
149
150
|
# File 'lib/pyroscope.rb', line 146
def _remove_tags(tags)
tags.each do |tag_name, tag_value|
Rust.remove_thread_tag(tag_name.to_s, tag_value.to_s)
end
end
|
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
|
# File 'lib/pyroscope.rb', line 72
def configure
@config = Config.new
yield @config
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(
@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,
tags_to_string(@config.tags || {}),
@config.tenant_id || "",
(@config. || {})
)
end
|
.current_config ⇒ Object
68
69
70
|
# File 'lib/pyroscope.rb', line 68
def current_config
@config
end
|
.initialize_rails_hooks ⇒ Object
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/pyroscope.rb', line 112
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
|
136
137
138
|
# File 'lib/pyroscope.rb', line 136
def remove_tags(*tags)
warn("deprecated. Use `Pyroscope.tag_wrapper` instead.")
end
|
.shutdown ⇒ Object
156
157
158
|
# File 'lib/pyroscope.rb', line 156
def shutdown
stop
end
|
.stop ⇒ Object
152
153
154
|
# File 'lib/pyroscope.rb', line 152
def stop
Rust.drop_agent
end
|
.tag(tags) ⇒ Object
132
133
134
|
# File 'lib/pyroscope.rb', line 132
def tag(tags)
warn("deprecated. Use `Pyroscope.tag_wrapper` instead.")
end
|
.tag_wrapper(tags) ⇒ Object
123
124
125
126
127
128
129
130
|
# File 'lib/pyroscope.rb', line 123
def tag_wrapper(tags)
_add_tags(tags)
begin
yield
ensure
_remove_tags(tags)
end
end
|