pyroscope 0.0.23 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d225c19f37a67a395be38c34385f64890b39a2a62b4e0d2e2fb33ee6ea339bd
4
- data.tar.gz: 16c2204608dd53eab9252c90188347524e90c7fa854dd0a51686129127193777
3
+ metadata.gz: 15d405da85cfd950ffe3b25c9ea6a3b5df68c57cfb52cd0b53f91cf26f22a955
4
+ data.tar.gz: 76422633bd992c1a1b148f66a9be25c6974bb47fba0d70e38e09c749fa389109
5
5
  SHA512:
6
- metadata.gz: 182168268e38e12e25101c30b508c550daa50c3b3406ba8f9409fbdd268b06f584ae28bd92dd73067e288029f962075bff7e4e7fe8446767ab047c70798ea7d4
7
- data.tar.gz: daccec7b3a6c262ac4a0d03fd6459907fa4b450c7e0598180d58c4983d9c2148260a04198b7c7da25c962cdc5209e5c9af49748331915d1a3a9e23e89b7b8bed
6
+ metadata.gz: 67550275be573ffe4dac71dc62386dc917bed9cb0be052b155cd33d11d18107100e1323c0454d3dd55eaaa269c2c3a58b039fa48a54ba07170d755ac2f4d768c
7
+ data.tar.gz: a4d1a8a11ffc44762a7dcb30ea7d946960696e35e77936e56c67f520d94744161cde0255cdf6457482b6c419522341ba46051b569c36c9580f1dee0f89a48c58
@@ -11,7 +11,6 @@ int Stop();
11
11
  int ChangeName(char*);
12
12
  int SetTag(char*, char*);
13
13
  int TestLogger();
14
- int SetLoggerLevel(int);
15
14
  char* BuildSummary();
16
15
 
17
16
  static VALUE
@@ -68,12 +67,6 @@ pyroscope_test_logger(VALUE self) {
68
67
  return INT2FIX(res);
69
68
  }
70
69
 
71
- static VALUE
72
- pyroscope_set_logger_level(VALUE self, VALUE level) {
73
- int res = SetLoggerLevel(FIX2INT(level));
74
- return INT2FIX(res);
75
- }
76
-
77
70
  static VALUE
78
71
  pyroscope_build_summary(VALUE self) {
79
72
  char *c_summary = BuildSummary();
@@ -90,6 +83,5 @@ Init_pyroscope_c() {
90
83
  rb_define_module_function(rb_Pyroscope, "_change_name", pyroscope_change_name, 1);
91
84
  rb_define_module_function(rb_Pyroscope, "_set_tag", pyroscope_set_tag, 2);
92
85
  rb_define_module_function(rb_Pyroscope, "_test_logger", pyroscope_test_logger, 0);
93
- rb_define_module_function(rb_Pyroscope, "_set_logger_level", pyroscope_set_logger_level, 1);
94
86
  rb_define_module_function(rb_Pyroscope, "_build_summary", pyroscope_build_summary, 0);
95
87
  }
@@ -1,3 +1,3 @@
1
1
  module Pyroscope
2
- VERSION = "0.0.23".freeze
2
+ VERSION = "0.1.0".freeze
3
3
  end
data/lib/pyroscope.rb CHANGED
@@ -26,21 +26,30 @@ module Pyroscope
26
26
  _change_name(new_name)
27
27
  end
28
28
 
29
- def set_tag(key, val)
30
- _set_tag(key, val)
29
+ def tag_wrapper(tags)
30
+ tag(tags)
31
+
32
+ begin
33
+ yield
34
+ ensure
35
+ remove_tags(*tags.keys)
36
+ end
31
37
  end
32
38
 
33
- def test_logger()
34
- _test_logger
39
+ def tag(tags)
40
+ tags.each_pair do |key, val|
41
+ _set_tag(key, val)
42
+ end
35
43
  end
36
44
 
37
- VALID_LOG_LEVELS = %i[none error info debug]
38
-
39
- def set_logger_level(level)
40
- i = VALID_LOG_LEVELS.index(level)
41
- raise "Unknown log level (#{level.inspect}), valid values are #{VALID_LOG_LEVELS.inspect}" unless i
45
+ def remove_tags(*keys)
46
+ keys.each do |key|
47
+ _set_tag(key, "")
48
+ end
49
+ end
42
50
 
43
- _set_logger_level(i - 1)
51
+ def test_logger
52
+ _test_logger
44
53
  end
45
54
 
46
55
  def build_summary
data/test.rb CHANGED
@@ -5,18 +5,8 @@ puts "prestart #{Process.pid}"
5
5
  Pyroscope.configure do |config|
6
6
  config.app_name = "test.ruby.app{}"
7
7
  config.server_address = "http://localhost:4040/"
8
- config.log_level = "debug"
9
8
  end
10
9
 
11
- puts "start"
12
-
13
- puts "Pyroscope.test_logger 1"
14
- Pyroscope.test_logger
15
- Pyroscope.set_logger_level(:debug)
16
- puts "Pyroscope.test_logger 2"
17
- Pyroscope.test_logger
18
-
19
-
20
10
  def work(n)
21
11
  i = 0
22
12
  while i < n
@@ -24,69 +14,19 @@ def work(n)
24
14
  end
25
15
  end
26
16
 
27
- def job_0
28
- work(rand()*1_000_000)
29
- end
30
-
31
- def job_1
32
- work(rand()*2_000_000)
33
- end
34
-
35
- def sleep_job
36
- sleep(rand()*10)
37
- end
38
-
39
- def main_loop(b)
40
- puts "Starting main loop from: #{Process.pid}"
41
- Pyroscope.set_tag("pid", Process.pid.to_s) if b
42
- while true
43
- r = rand
44
- # if r > 0.9
45
- # Pyroscope.set_logger_level(:test)
46
- # end
47
- if r < 0.1
48
- sleep_job
49
- elsif r < 0.5
50
- puts(" * test.ruby.app{job=0} #{Process.pid}")
51
- Pyroscope.set_tag("job", "0") if b
52
- job_0
53
- Pyroscope.set_tag("job", "") if b
54
- else
55
- puts(" * test.ruby.app{job=1} #{Process.pid}")
56
- Pyroscope.set_tag("job", "1") if b
57
- job_1
58
- Pyroscope.set_tag("job", "") if b
59
- end
17
+ def fast_function
18
+ Pyroscope.tag_wrapper({ "function" => "fast"}) do
19
+ work(20_000)
60
20
  end
61
21
  end
62
22
 
63
- fork do
64
- puts "build_summary:"
65
- puts Pyroscope.build_summary
66
- # Pyroscope.configure do |config|
67
- # config.app_name = "test.ruby.app2{}"
68
- # config.server_address = "http://localhost:4040/"
69
- # end
70
-
71
- puts "Hello from fork pid: #{Process.pid}"
72
- sleep 15
73
- main_loop(false)
23
+ def slow_function
24
+ Pyroscope.tag({ "function" => "slow"})
25
+ work(80_000)
26
+ Pyroscope.remove_tags("function")
74
27
  end
75
28
 
76
- # sleep 5
77
- # if ARGV.first == "subprocess"
78
- # main_loop(true)
79
- # else
80
- # ssh_pid = Kernel.spawn("ruby", "test.rb", "subprocess")
81
- # puts "spawned #{ssh_pid}"
82
-
83
- # sleep(30)
84
- # puts "killing #{ssh_pid}"
85
- # Process.kill("TERM", ssh_pid)
86
-
87
-
88
- # end
89
-
90
- sleep 15
91
- puts "The parent process just skips over it: #{Process.pid}"
92
- main_loop(true)
29
+ while true
30
+ fast_function
31
+ slow_function
32
+ end
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.0.23
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pyroscope Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-02 00:00:00.000000000 Z
11
+ date: 2021-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler