pyroscope 0.1.0 → 0.3.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.
@@ -1,87 +0,0 @@
1
- #include <stdlib.h>
2
- #include <ruby.h>
3
-
4
- static VALUE rb_Pyroscope;
5
-
6
- #include <stdio.h>
7
- #include <string.h>
8
-
9
- int Start(char*, char*, char*, char*, int, int, char*);
10
- int Stop();
11
- int ChangeName(char*);
12
- int SetTag(char*, char*);
13
- int TestLogger();
14
- char* BuildSummary();
15
-
16
- static VALUE
17
- pyroscope_start(VALUE self, VALUE appName, VALUE serverAddress, VALUE authToken, VALUE sampleRate, VALUE withSubprocesses, VALUE logLevel) {
18
- VALUE r_appName = StringValue(appName);
19
- char *c_appName = RSTRING_PTR(r_appName);
20
-
21
- int c_sampleRate = FIX2INT(sampleRate);
22
- int c_withSubprocesses = FIX2INT(withSubprocesses);
23
-
24
- VALUE r_serverAddress = StringValue(serverAddress);
25
- char *c_serverAddress = RSTRING_PTR(r_serverAddress);
26
-
27
- VALUE r_authToken = StringValue(authToken);
28
- char *c_authToken = RSTRING_PTR(r_authToken);
29
-
30
- VALUE r_logLevel = StringValue(logLevel);
31
- char *c_logLevel = RSTRING_PTR(r_logLevel);
32
-
33
- int res = Start(c_appName, "rbspy", c_serverAddress, c_authToken, c_sampleRate, c_withSubprocesses, c_logLevel);
34
-
35
- return INT2FIX(res);
36
- }
37
-
38
- static VALUE
39
- pyroscope_stop(VALUE self) {
40
- int res = Stop();
41
- return INT2FIX(res);
42
- }
43
-
44
- static VALUE
45
- pyroscope_change_name(VALUE self, VALUE appName) {
46
- VALUE r_appName = StringValue(appName);
47
- char *c_appName = RSTRING_PTR(r_appName);
48
-
49
- int res = ChangeName(c_appName);
50
- return INT2FIX(res);
51
- }
52
-
53
- static VALUE
54
- pyroscope_set_tag(VALUE self, VALUE key, VALUE val) {
55
- VALUE r_key = StringValue(key);
56
- char *c_key = RSTRING_PTR(r_key);
57
- VALUE r_val = StringValue(val);
58
- char *c_val = RSTRING_PTR(r_val);
59
-
60
- int res = SetTag(c_key, c_val);
61
- return INT2FIX(res);
62
- }
63
-
64
- static VALUE
65
- pyroscope_test_logger(VALUE self) {
66
- int res = TestLogger();
67
- return INT2FIX(res);
68
- }
69
-
70
- static VALUE
71
- pyroscope_build_summary(VALUE self) {
72
- char *c_summary = BuildSummary();
73
- VALUE r_summary = rb_str_new_cstr(c_summary);
74
- free(c_summary);
75
- return r_summary;
76
- }
77
-
78
- void
79
- Init_pyroscope_c() {
80
- rb_Pyroscope = rb_define_module("Pyroscope");
81
- rb_define_module_function(rb_Pyroscope, "_start", pyroscope_start, 6);
82
- rb_define_module_function(rb_Pyroscope, "_stop", pyroscope_stop, 0);
83
- rb_define_module_function(rb_Pyroscope, "_change_name", pyroscope_change_name, 1);
84
- rb_define_module_function(rb_Pyroscope, "_set_tag", pyroscope_set_tag, 2);
85
- rb_define_module_function(rb_Pyroscope, "_test_logger", pyroscope_test_logger, 0);
86
- rb_define_module_function(rb_Pyroscope, "_build_summary", pyroscope_build_summary, 0);
87
- }
data/test.rb DELETED
@@ -1,32 +0,0 @@
1
- require 'pyroscope'
2
-
3
- puts "prestart #{Process.pid}"
4
-
5
- Pyroscope.configure do |config|
6
- config.app_name = "test.ruby.app{}"
7
- config.server_address = "http://localhost:4040/"
8
- end
9
-
10
- def work(n)
11
- i = 0
12
- while i < n
13
- i += 1
14
- end
15
- end
16
-
17
- def fast_function
18
- Pyroscope.tag_wrapper({ "function" => "fast"}) do
19
- work(20_000)
20
- end
21
- end
22
-
23
- def slow_function
24
- Pyroscope.tag({ "function" => "slow"})
25
- work(80_000)
26
- Pyroscope.remove_tags("function")
27
- end
28
-
29
- while true
30
- fast_function
31
- slow_function
32
- end