pyroscope 0.1.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- Pyroscope.configure do |config|
4
- config.app_name = "test.ruby.app"
5
- config.server_address = "http://pyroscope:4040/"
6
- config.tags = {
7
- :region => "us-east-1",
8
- :hostname => ENV["hostname"]
9
- }
10
- end
11
-
12
- def work(n)
13
- i = 0
14
- while i < n
15
- i += 1
16
- end
17
- end
18
-
19
- def fast_function
20
- work(20000)
21
- end
22
-
23
- def slow_function
24
- work(80000)
25
- end
26
-
27
- Pyroscope.tag({ "region" => "us-east-1" })
28
-
29
- while true
30
- fast_function
31
- slow_function
32
- end