pyroscope 0.5.0-aarch64-linux → 0.5.1-aarch64-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: 9f2b8ee68651f9d7709b127c5915683a4c094d1e37a30f3e181f731d15bbf20e
4
- data.tar.gz: c9ba5290e09e89e72f604095f4565f794e6070deffaf609f42384d5d97f05de0
3
+ metadata.gz: 27eb83d237bce880236842745e5becca860019eb31b9506a9a479ed380031e55
4
+ data.tar.gz: 53030eeaaee8c3a4cecd4c1749816e550ebd5586eef413c5048dfeae355a2545
5
5
  SHA512:
6
- metadata.gz: be594d26c4e1356f9466e1fa931adda338057fa9407584d67d4145d1124319d3d41c6f7f227a0ae41968b43886d6e790eb99f6a568b68e22502b56ac2ab7ea2e
7
- data.tar.gz: ef4d71adf95a06395e24663534616a8b81bca7cb65e13b8073d72272ad8838ff0dfca22c2501ed44763d02c1d90e5fd881a8d356f70e40bc5686b4f32d61b9ca
6
+ metadata.gz: fcec4724b851c26b9c8c64860831c2ec0c13f53295ce583c75a4ef30ca758ff1cf891da645aeaec3ad847e5f3f2abf019ab5ed3112b130548ede105d3901628a
7
+ data.tar.gz: 4ce97aba9900832af7bae0a6d158ee76606b9c3b972f21f4512388a324ce28d92659ab72f9d4169202771b1ceda015eea7b49fea43b8b9d72faf7c08e5d781a9
@@ -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: aarch64-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