pyroscope 0.5.0-x86_64-linux → 0.5.1-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b692aa36e6a159bec5b036ac9b55ec84270191f5bfaf187aa47a1d1f3a0de653
4
- data.tar.gz: c7a365213abab197873d98a74bdf076cb93c5ef3c8471dc39e176c173f43082c
3
+ metadata.gz: 770b8400d47b3331a471387bf2c077b4b9a9ed1d4db3e281c0d3401664c9b7c1
4
+ data.tar.gz: 6050743311d3157d2d46b572d0d00e6d3bee21a2e820dad2a005c1ea04eceaf6
5
5
  SHA512:
6
- metadata.gz: 8b078b81690d727f8f3f602324e1020ea673b0979f56bf60e62e54d4dd718beea20b08074016f8dfdd7968dfdef168d6f2a5a3b8c18d21664d80ab1c09414b36
7
- data.tar.gz: 4a94af4c840e8aed35d97caab5d3eecc1e2a596f5f787fb84373965f7c88ca5cd57c3be93bd6c0fd77473005b24e1626dd50bfdf9ceb3b42ebfcebece8aeba46
6
+ metadata.gz: 532e11c66b558576bb1c3b0403b26acb5ace0561b94d318e055e715a11d540a7abced34d46849d0d6fc9db0c3ab265f8940b0121306bd6659d9386aa0926cf78
7
+ data.tar.gz: 99ac8f8b93e61f50cd86cc474c32f261ff266549de792046beeecbf4d4bfb7d7558af642ec1312a499dd9b38a22ef04d86e35d14c5dbabadb4f199ce9effa423
@@ -1,3 +1,3 @@
1
1
  module Pyroscope
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.5.1'.freeze
3
3
  end
data/lib/pyroscope.rb CHANGED
@@ -22,7 +22,32 @@ module Pyroscope
22
22
  attach_function :thread_id, [], :uint64
23
23
  end
24
24
 
25
- Config = Struct.new(:application_name, :app_name, :server_address, :auth_token, :log_level, :sample_rate, :detect_subprocesses, :oncpu, :report_pid, :report_thread_id, :tags, :compression, :report_encoding) do
25
+ if defined?(::Rails::Engine)
26
+ class Engine < ::Rails::Engine
27
+ config.after_initialize do
28
+ next unless ::Pyroscope.current_config && ::Pyroscope.current_config.autoinstrument_rails
29
+
30
+ ::Pyroscope.initialize_rails_hooks
31
+ end
32
+ end
33
+ end
34
+
35
+ Config = Struct.new(
36
+ :application_name,
37
+ :app_name,
38
+ :server_address,
39
+ :auth_token,
40
+ :log_level,
41
+ :sample_rate,
42
+ :detect_subprocesses,
43
+ :oncpu,
44
+ :report_pid,
45
+ :report_thread_id,
46
+ :tags,
47
+ :compression,
48
+ :report_encoding,
49
+ :autoinstrument_rails,
50
+ ) do
26
51
  def initialize(*)
27
52
  super
28
53
  # defaults:
@@ -38,10 +63,15 @@ module Pyroscope
38
63
  self.tags = {}
39
64
  self.compression = 'gzip'
40
65
  self.report_encoding = 'pprof'
66
+ self.autoinstrument_rails = true
41
67
  end
42
68
  end
43
69
 
44
70
  class << self
71
+ def current_config
72
+ @config
73
+ end
74
+
45
75
  def configure
46
76
  @config = Config.new
47
77
 
@@ -64,11 +94,8 @@ module Pyroscope
64
94
  @log_level = 50
65
95
  end
66
96
 
67
- # Initialize Logging
68
97
  Rust.initialize_logging(@log_level)
69
98
 
70
-
71
- # initialize Pyroscope Agent
72
99
  Rust.initialize_agent(
73
100
  # these are defaults in case user-provided values are nil:
74
101
  @config.app_name || @config.application_name || "",
@@ -85,6 +112,17 @@ module Pyroscope
85
112
  )
86
113
  end
87
114
 
115
+ def initialize_rails_hooks
116
+ block = lambda do |ctrl, action|
117
+ Pyroscope.tag_wrapper({
118
+ "action" => "#{ctrl.controller_name}/#{ctrl.action_name}"
119
+ }, &action)
120
+ end
121
+
122
+ ActionController::API.__send__(:around_action, block) if defined? ActionController::API
123
+ ActionController::Base.__send__(:around_action, block) if defined? ActionController::Base
124
+ end
125
+
88
126
  def tag_wrapper(tags)
89
127
  tid = thread_id
90
128
  _add_tags(tid, tags)
@@ -103,32 +141,34 @@ module Pyroscope
103
141
  warn("deprecated. Use `Pyroscope.tag_wrapper` instead.")
104
142
  end
105
143
 
106
- # convert tags object to string
107
- def tags_to_string(tags)
108
- tags.map { |k, v| "#{k}=#{v}" }.join(',')
109
- end
110
-
111
- # get thread id
112
144
  def thread_id
113
145
  return Utils.thread_id
114
146
  end
115
147
 
116
- # add tags
117
148
  def _add_tags(thread_id, tags)
118
149
  tags.each do |tag_name, tag_value|
119
150
  Rust.add_thread_tag(thread_id, tag_name.to_s, tag_value.to_s)
120
151
  end
121
152
  end
122
153
 
123
- # remove tags
124
154
  def _remove_tags(thread_id, tags)
125
155
  tags.each do |tag_name, tag_value|
126
156
  Rust.remove_thread_tag(thread_id, tag_name.to_s, tag_value.to_s)
127
157
  end
128
158
  end
129
159
 
130
- def shutdown
160
+ def stop
131
161
  Rust.drop_agent
132
162
  end
163
+
164
+ def shutdown
165
+ stop
166
+ end
167
+
168
+ private
169
+
170
+ def tags_to_string(tags)
171
+ tags.map { |k, v| "#{k}=#{v}" }.join(',')
172
+ end
133
173
  end
134
174
  end
data/lib/rbspy/rbspy.so CHANGED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pyroscope
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Pyroscope Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-06 00:00:00.000000000 Z
11
+ date: 2022-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi