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 +4 -4
- data/ext/pyroscope/pyroscope.c +0 -8
- data/lib/pyroscope/version.rb +1 -1
- data/lib/pyroscope.rb +19 -10
- data/test.rb +11 -71
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15d405da85cfd950ffe3b25c9ea6a3b5df68c57cfb52cd0b53f91cf26f22a955
|
4
|
+
data.tar.gz: 76422633bd992c1a1b148f66a9be25c6974bb47fba0d70e38e09c749fa389109
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67550275be573ffe4dac71dc62386dc917bed9cb0be052b155cd33d11d18107100e1323c0454d3dd55eaaa269c2c3a58b039fa48a54ba07170d755ac2f4d768c
|
7
|
+
data.tar.gz: a4d1a8a11ffc44762a7dcb30ea7d946960696e35e77936e56c67f520d94744161cde0255cdf6457482b6c419522341ba46051b569c36c9580f1dee0f89a48c58
|
data/ext/pyroscope/pyroscope.c
CHANGED
@@ -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
|
}
|
data/lib/pyroscope/version.rb
CHANGED
data/lib/pyroscope.rb
CHANGED
@@ -26,21 +26,30 @@ module Pyroscope
|
|
26
26
|
_change_name(new_name)
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
|
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
|
34
|
-
|
39
|
+
def tag(tags)
|
40
|
+
tags.each_pair do |key, val|
|
41
|
+
_set_tag(key, val)
|
42
|
+
end
|
35
43
|
end
|
36
44
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
45
|
+
def remove_tags(*keys)
|
46
|
+
keys.each do |key|
|
47
|
+
_set_tag(key, "")
|
48
|
+
end
|
49
|
+
end
|
42
50
|
|
43
|
-
|
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
|
28
|
-
|
29
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
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-
|
11
|
+
date: 2021-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|