skylight 0.3.13 → 0.3.14
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/CHANGELOG.md +7 -0
- data/ext/extconf.rb +3 -2
- data/ext/libskylight.yml +3 -3
- data/ext/rust_support/ruby.h +93 -0
- data/ext/skylight.h +25 -32
- data/ext/skylight_native.c +33 -141
- data/ext/test/extconf.rb +18 -0
- data/ext/test/skylight_native_test.c +82 -0
- data/ext/test/skylight_test.h +20 -0
- data/lib/skylight/railtie.rb +3 -1
- data/lib/skylight/version.rb +1 -1
- metadata +20 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5620862e4260060cc2887d5fa2e902eeb96af51a
|
|
4
|
+
data.tar.gz: 8e664fcdf47316d921921b96286c8b336f6c0892
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0ad66490a91813115f262f0c1640a0a50839bd82f0a81fb32952cd03fede4a742ed220db5d14491b1fda95b0217a5ff3ec48e3ddff6d77a9f4674f4dbf45bae1
|
|
7
|
+
data.tar.gz: 122849003b5c4d135c8244d37e65ca1505a8cb421ff874c7d6e1af180e8fe122026155c734645ccf10a7527ad1182fe19cf64d9bab3ad2f0b13a1aa44b103c5b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## 0.3.14 (June 3, 2014)
|
|
2
|
+
|
|
3
|
+
* Do not build C extension if dependencies (libraries/headers) are
|
|
4
|
+
missing
|
|
5
|
+
* [RUST] Improve performance by not double copying memory when serializing
|
|
6
|
+
* Enable the Net::HTTP probe by default
|
|
7
|
+
|
|
1
8
|
## 0.3.13 (May 12, 2014)
|
|
2
9
|
|
|
3
10
|
* Load probes even when agent is disabled
|
data/ext/extconf.rb
CHANGED
|
@@ -104,7 +104,8 @@ end
|
|
|
104
104
|
|
|
105
105
|
have_header 'dlfcn.h'
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
find_header("rust_support/ruby.h", ".") or fail "could not find rust support header"
|
|
108
|
+
find_library("skylight", "factory", ".") or fail "could not find skylight library"
|
|
108
109
|
|
|
109
110
|
$CFLAGS << " -Werror"
|
|
110
111
|
if RbConfig::CONFIG["arch"] =~ /darwin(\d+)?/
|
|
@@ -116,4 +117,4 @@ end
|
|
|
116
117
|
|
|
117
118
|
CONFIG['warnflags'].gsub!('-Wdeclaration-after-statement', '')
|
|
118
119
|
|
|
119
|
-
create_makefile 'skylight_native', '.'
|
|
120
|
+
create_makefile 'skylight_native', '.' or fail "could not create makefile"
|
data/ext/libskylight.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
version: "
|
|
2
|
+
version: "dfa09f3"
|
|
3
3
|
checksums:
|
|
4
|
-
linux-x86_64: "
|
|
5
|
-
linux-x86: "
|
|
4
|
+
linux-x86_64: "be6c610564c66e2a098e7c22226ac879cc970bac252b2534a11b556197f2efca"
|
|
5
|
+
linux-x86: "2113e80b8afddf5f00c81590c8cbcfbb6ecaf9dbdec950eca06bb11ed1456351"
|
|
6
6
|
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#ifndef __RUST_H__
|
|
2
|
+
#define __RUST_H__
|
|
3
|
+
|
|
4
|
+
#include <stddef.h>
|
|
5
|
+
#include <stdint.h>
|
|
6
|
+
#include <stdbool.h>
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Rust types
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
typedef struct {
|
|
13
|
+
char* data;
|
|
14
|
+
long len;
|
|
15
|
+
} RustSlice;
|
|
16
|
+
|
|
17
|
+
typedef void* RustVec;
|
|
18
|
+
typedef void* RustString;
|
|
19
|
+
|
|
20
|
+
bool rust_string_as_slice(RustString, RustSlice*);
|
|
21
|
+
|
|
22
|
+
#define TO_S(VAL) \
|
|
23
|
+
RSTRING_PTR(rb_funcall(VAL, rb_intern("to_s"), 0))
|
|
24
|
+
|
|
25
|
+
#define CHECK_NUMERIC(VAL) \
|
|
26
|
+
do { \
|
|
27
|
+
if (TYPE(VAL) != T_BIGNUM && \
|
|
28
|
+
TYPE(VAL) != T_FIXNUM) { \
|
|
29
|
+
rb_raise(rb_eArgError, "expected " #VAL " to be numeric but was '%s' (%s [%i])", \
|
|
30
|
+
TO_S(VAL), rb_obj_classname(VAL), TYPE(VAL)); \
|
|
31
|
+
return Qnil; \
|
|
32
|
+
} \
|
|
33
|
+
} while(0) \
|
|
34
|
+
|
|
35
|
+
#define CHECK_TYPE(VAL, T) \
|
|
36
|
+
do { \
|
|
37
|
+
if (TYPE(VAL) != T) { \
|
|
38
|
+
rb_raise(rb_eArgError, "expected " #VAL " to be " #T " but was '%s' (%s [%i])", \
|
|
39
|
+
TO_S(VAL), rb_obj_classname(VAL), TYPE(VAL)); \
|
|
40
|
+
return Qnil; \
|
|
41
|
+
} \
|
|
42
|
+
} while(0) \
|
|
43
|
+
|
|
44
|
+
#define CHECK_FFI(success, message) \
|
|
45
|
+
({ \
|
|
46
|
+
if (!(success)) \
|
|
47
|
+
rb_raise(rb_eRuntimeError, message); \
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
#define SLICE2STR(slice) \
|
|
51
|
+
({ \
|
|
52
|
+
RustSlice s = (slice); \
|
|
53
|
+
VALUE str = rb_str_new(s.data, s.len); \
|
|
54
|
+
rb_enc_associate(str, rb_utf8_encoding()); \
|
|
55
|
+
str; \
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
#define STR2SLICE(string) \
|
|
59
|
+
({ \
|
|
60
|
+
RustSlice s; \
|
|
61
|
+
VALUE rb_str = (string); \
|
|
62
|
+
s.data = RSTRING_PTR(rb_str); \
|
|
63
|
+
s.len = RSTRING_LEN(rb_str); \
|
|
64
|
+
s; \
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
#define RUSTSTR2STR(string) \
|
|
68
|
+
({ \
|
|
69
|
+
RustString s = (string); \
|
|
70
|
+
RustSlice slice; \
|
|
71
|
+
CHECK_FFI(rust_string_as_slice(s, &slice), "Couldn't convert String to &str"); \
|
|
72
|
+
SLICE2STR(slice); \
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
#endif
|
|
76
|
+
|
|
77
|
+
#define My_Struct(name, Type, msg) \
|
|
78
|
+
Get_Struct(name, self, Type, msg); \
|
|
79
|
+
|
|
80
|
+
#define Transfer_My_Struct(name, Type, msg) \
|
|
81
|
+
My_Struct(name, Type, msg); \
|
|
82
|
+
DATA_PTR(self) = NULL; \
|
|
83
|
+
|
|
84
|
+
#define Transfer_Struct(name, obj, Type, msg) \
|
|
85
|
+
Get_Struct(name, obj, Type, msg); \
|
|
86
|
+
DATA_PTR(obj) = NULL; \
|
|
87
|
+
|
|
88
|
+
#define Get_Struct(name, obj, Type, msg) \
|
|
89
|
+
Type name; \
|
|
90
|
+
Data_Get_Struct(obj, Type, name); \
|
|
91
|
+
if (name == NULL) { \
|
|
92
|
+
rb_raise(rb_eRuntimeError, "%s", msg); \
|
|
93
|
+
}
|
data/ext/skylight.h
CHANGED
|
@@ -5,33 +5,27 @@
|
|
|
5
5
|
#include <stdint.h>
|
|
6
6
|
#include <stdbool.h>
|
|
7
7
|
|
|
8
|
+
#include <rust_support/ruby.h>
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
11
|
+
* TODO: This is copied from rust_support
|
|
10
12
|
*/
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
size_t fill; // in bytes; if zero, heapified
|
|
14
|
-
size_t alloc; // in bytes
|
|
15
|
-
uint8_t data[0];
|
|
16
|
-
} rust_str;
|
|
17
|
-
|
|
18
|
-
typedef struct {
|
|
19
|
-
char * data;
|
|
20
|
-
long len;
|
|
21
|
-
} RustSlice;
|
|
14
|
+
bool skylight_string_as_slice(RustString, RustSlice*);
|
|
22
15
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
#define SKYLIGHT_RUSTSTR2STR(string) \
|
|
17
|
+
({ \
|
|
18
|
+
RustString s = (string); \
|
|
19
|
+
RustSlice slice; \
|
|
20
|
+
CHECK_FFI(skylight_string_as_slice(s, &slice), "Couldn't convert String to &str"); \
|
|
21
|
+
SLICE2STR(slice); \
|
|
22
|
+
})
|
|
30
23
|
|
|
31
24
|
/**
|
|
32
25
|
* Externed Rust functions from libskylight
|
|
33
26
|
*/
|
|
34
27
|
|
|
28
|
+
typedef void * RustSerializer;
|
|
35
29
|
typedef void * RustHello;
|
|
36
30
|
typedef void * RustError;
|
|
37
31
|
typedef void * RustTrace;
|
|
@@ -46,8 +40,9 @@ bool skylight_hello_load(RustSlice, RustHello*);
|
|
|
46
40
|
bool skylight_hello_cmd_add(RustHello, RustSlice);
|
|
47
41
|
bool skylight_hello_get_version(RustHello, RustSlice*);
|
|
48
42
|
bool skylight_hello_cmd_length(RustHello, uint32_t*);
|
|
49
|
-
bool skylight_hello_get_cmd(RustHello,
|
|
50
|
-
bool
|
|
43
|
+
bool skylight_hello_get_cmd(RustHello, uint32_t, RustSlice*);
|
|
44
|
+
bool skylight_hello_get_serializer(RustHello, RustSerializer*);
|
|
45
|
+
bool skylight_hello_serialize(RustHello, RustSerializer, RustSlice);
|
|
51
46
|
bool skylight_high_res_time(uint64_t*);
|
|
52
47
|
|
|
53
48
|
// Rust skylight_trace prototypes
|
|
@@ -60,22 +55,18 @@ bool skylight_trace_get_name(RustTrace, RustSlice*);
|
|
|
60
55
|
bool skylight_trace_get_uuid(RustTrace, RustSlice*);
|
|
61
56
|
bool skylight_trace_start_span(RustTrace, uint64_t, RustSlice, uint32_t*);
|
|
62
57
|
bool skylight_trace_stop_span(RustTrace, uint32_t, uint64_t);
|
|
63
|
-
bool skylight_trace_serialize_into_new_buffer(RustTrace, RustString*);
|
|
64
58
|
bool skylight_trace_span_set_title(RustTrace, uint64_t, RustSlice);
|
|
65
59
|
bool skylight_trace_span_set_description(RustTrace, uint64_t, RustSlice);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
bool skylight_trace_add_annotation_int(RustTrace, uint32_t, uint32_t*, RustSlice*, int64_t);
|
|
69
|
-
bool skylight_trace_add_annotation_double(RustTrace, uint32_t, uint32_t*, RustSlice*, double);
|
|
70
|
-
bool skylight_trace_add_annotation_string(RustTrace, uint32_t, uint32_t*, RustSlice*, RustSlice);
|
|
71
|
-
bool skylight_trace_add_annotation_nested(RustTrace, uint32_t, uint32_t*, RustSlice*, uint32_t*);
|
|
60
|
+
bool skylight_trace_get_serializer(RustTrace, RustSerializer*);
|
|
61
|
+
bool skylight_trace_serialize(RustTrace, RustSerializer, RustSlice);
|
|
72
62
|
|
|
73
63
|
// Batch methods
|
|
74
|
-
bool skylight_batch_new(uint32_t,
|
|
64
|
+
bool skylight_batch_new(uint32_t, RustSlice*, RustBatch*);
|
|
75
65
|
bool skylight_batch_free(RustBatch);
|
|
76
66
|
bool skylight_batch_set_endpoint_count(RustBatch, RustSlice, uint64_t);
|
|
77
|
-
bool skylight_batch_move_in(RustBatch,
|
|
78
|
-
bool
|
|
67
|
+
bool skylight_batch_move_in(RustBatch, RustSlice);
|
|
68
|
+
bool skylight_batch_get_serializer(RustBatch, RustSerializer*);
|
|
69
|
+
bool skylight_batch_serialize(RustBatch, RustSerializer, RustSlice);
|
|
79
70
|
|
|
80
71
|
// Error methods
|
|
81
72
|
bool skylight_error_new(RustSlice, RustSlice, RustError*);
|
|
@@ -85,8 +76,10 @@ bool skylight_error_get_group(RustError, RustSlice*);
|
|
|
85
76
|
bool skylight_error_get_description(RustError, RustSlice*);
|
|
86
77
|
bool skylight_error_get_details(RustError, RustSlice*);
|
|
87
78
|
bool skylight_error_set_details(RustError, RustSlice);
|
|
88
|
-
bool
|
|
79
|
+
bool skylight_error_get_serializer(RustError, RustSerializer*);
|
|
80
|
+
bool skylight_error_serialize(RustError, RustSerializer, RustSlice);
|
|
89
81
|
|
|
90
|
-
|
|
82
|
+
bool skylight_serializer_get_serialized_size(RustSerializer, size_t*);
|
|
83
|
+
bool skylight_serializer_free(RustSerializer);
|
|
91
84
|
|
|
92
85
|
#endif
|
data/ext/skylight_native.c
CHANGED
|
@@ -9,104 +9,27 @@
|
|
|
9
9
|
* Ruby helpers
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
#define
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
#define My_Struct(name, Type, msg) \
|
|
35
|
-
Get_Struct(name, self, Type, msg); \
|
|
36
|
-
|
|
37
|
-
#define Transfer_My_Struct(name, Type, msg) \
|
|
38
|
-
My_Struct(name, Type, msg); \
|
|
39
|
-
DATA_PTR(self) = NULL; \
|
|
40
|
-
|
|
41
|
-
#define Transfer_Struct(name, obj, Type, msg) \
|
|
42
|
-
Get_Struct(name, obj, Type, msg); \
|
|
43
|
-
DATA_PTR(obj) = NULL; \
|
|
44
|
-
|
|
45
|
-
#define Get_Struct(name, obj, Type, msg) \
|
|
46
|
-
Type name; \
|
|
47
|
-
Data_Get_Struct(obj, Type, name); \
|
|
48
|
-
if (name == NULL) { \
|
|
49
|
-
rb_raise(rb_eRuntimeError, "%s", msg); \
|
|
50
|
-
} \
|
|
51
|
-
|
|
52
|
-
#define CHECK_FFI(success, message) \
|
|
53
|
-
({ \
|
|
54
|
-
if (!(success)) \
|
|
55
|
-
rb_raise(rb_eRuntimeError, message); \
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
#define VEC2STR(vector) \
|
|
59
|
-
({ \
|
|
60
|
-
RustVector v = (vector); \
|
|
61
|
-
VALUE ret = rb_str_new((char *)v->data, v->fill); \
|
|
62
|
-
ret; \
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
#define SLICE2STR(slice) \
|
|
66
|
-
({ \
|
|
67
|
-
RustSlice s = (slice); \
|
|
68
|
-
VALUE str = rb_str_new(s.data, s.len); \
|
|
69
|
-
rb_enc_associate(str, rb_utf8_encoding()); \
|
|
70
|
-
str; \
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
#define STR2SLICE(string) \
|
|
74
|
-
({ \
|
|
75
|
-
RustSlice s; \
|
|
76
|
-
VALUE rb_str = (string); \
|
|
77
|
-
s.data = RSTRING_PTR(rb_str); \
|
|
78
|
-
s.len = RSTRING_LEN(rb_str); \
|
|
79
|
-
s; \
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
#define UnwrapOption(T, val, transform) \
|
|
83
|
-
({ \
|
|
84
|
-
T * v = (val); \
|
|
85
|
-
VALUE ret; \
|
|
86
|
-
if (v == NULL) { \
|
|
87
|
-
ret = Qnil; \
|
|
88
|
-
} \
|
|
89
|
-
else { \
|
|
90
|
-
ret = transform(*v); \
|
|
91
|
-
} \
|
|
92
|
-
ret; \
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
#define IsNone(val) val.discrim == 0
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Convert Ruby String to a Rust String
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
|
-
RustString skylight_slice_to_owned(RustSlice);
|
|
102
|
-
RustString skylight_bytes_to_new_vec(uint8_t*, uint64_t);
|
|
103
|
-
|
|
104
|
-
#define STR2RUST(string) \
|
|
105
|
-
({ \
|
|
106
|
-
VALUE rb_str = (string); \
|
|
107
|
-
skylight_bytes_to_new_vec( \
|
|
108
|
-
(uint8_t*) RSTRING_PTR(rb_str), \
|
|
109
|
-
RSTRING_LEN(rb_str)); \
|
|
12
|
+
#define SERIALIZE(MSG) \
|
|
13
|
+
({ \
|
|
14
|
+
VALUE ret; \
|
|
15
|
+
size_t size; \
|
|
16
|
+
RustSerializer serializer; \
|
|
17
|
+
\
|
|
18
|
+
if (!MSG) { \
|
|
19
|
+
rb_raise(rb_eRuntimeError, "No "#MSG" message to serialize"); \
|
|
20
|
+
} \
|
|
21
|
+
else { \
|
|
22
|
+
CHECK_FFI(skylight_ ## MSG ## _get_serializer(MSG, &serializer), "could not get serializer for "#MSG); \
|
|
23
|
+
\
|
|
24
|
+
CHECK_FFI(skylight_serializer_get_serialized_size(serializer, &size), "could not get serialized size for "#MSG); \
|
|
25
|
+
ret = rb_str_new(NULL, size); \
|
|
26
|
+
\
|
|
27
|
+
CHECK_FFI(skylight_ ## MSG ## _serialize(MSG, serializer, STR2SLICE(ret)), "could not serialize "#MSG); \
|
|
28
|
+
skylight_serializer_free(serializer); \
|
|
29
|
+
} \
|
|
30
|
+
\
|
|
31
|
+
skylight_ ## MSG ## _free(MSG); \
|
|
32
|
+
ret; \
|
|
110
33
|
})
|
|
111
34
|
|
|
112
35
|
/**
|
|
@@ -189,7 +112,7 @@ static VALUE hello_add_cmd_part(VALUE self, VALUE rb_string) {
|
|
|
189
112
|
}
|
|
190
113
|
|
|
191
114
|
static VALUE hello_cmd_get(VALUE self, VALUE rb_off) {
|
|
192
|
-
|
|
115
|
+
uint32_t off;
|
|
193
116
|
RustSlice slice;
|
|
194
117
|
My_Struct(hello, RustHello, freedHello);
|
|
195
118
|
|
|
@@ -202,15 +125,8 @@ static VALUE hello_cmd_get(VALUE self, VALUE rb_off) {
|
|
|
202
125
|
}
|
|
203
126
|
|
|
204
127
|
static VALUE hello_serialize(VALUE self) {
|
|
205
|
-
RustString serialized;
|
|
206
128
|
Transfer_My_Struct(hello, RustHello, freedHello);
|
|
207
|
-
|
|
208
|
-
CHECK_FFI(skylight_hello_serialize_into_new_buffer(hello, &serialized), "Could not serialize Hello");
|
|
209
|
-
skylight_hello_free(hello);
|
|
210
|
-
|
|
211
|
-
VALUE string = VEC2STR(serialized);
|
|
212
|
-
skylight_free_buf(serialized);
|
|
213
|
-
return string;
|
|
129
|
+
return SERIALIZE(hello);
|
|
214
130
|
}
|
|
215
131
|
|
|
216
132
|
/**
|
|
@@ -281,15 +197,8 @@ static VALUE error_set_details(VALUE self, VALUE details) {
|
|
|
281
197
|
}
|
|
282
198
|
|
|
283
199
|
static VALUE error_serialize(VALUE self) {
|
|
284
|
-
RustString serialized;
|
|
285
200
|
Transfer_My_Struct(error, RustError, freedError);
|
|
286
|
-
|
|
287
|
-
CHECK_FFI(skylight_error_serialize_into_new_buffer(error, &serialized), "Could not serialize Error");
|
|
288
|
-
skylight_error_free(error);
|
|
289
|
-
|
|
290
|
-
VALUE string = VEC2STR(serialized);
|
|
291
|
-
skylight_free_buf(serialized);
|
|
292
|
-
return string;
|
|
201
|
+
return SERIALIZE(error);
|
|
293
202
|
}
|
|
294
203
|
|
|
295
204
|
/**
|
|
@@ -316,9 +225,7 @@ static VALUE trace_name_from_serialized(VALUE self, VALUE protobuf) {
|
|
|
316
225
|
|
|
317
226
|
CHECK_FFI(skylight_trace_name_from_serialized_into_new_buffer(STR2SLICE(protobuf), &trace_name), "Could not read name from serialized Trace");
|
|
318
227
|
|
|
319
|
-
|
|
320
|
-
skylight_free_buf(trace_name);
|
|
321
|
-
return ret;
|
|
228
|
+
return SKYLIGHT_RUSTSTR2STR(trace_name);
|
|
322
229
|
}
|
|
323
230
|
|
|
324
231
|
static VALUE trace_get_started_at(VALUE self) {
|
|
@@ -348,8 +255,6 @@ static VALUE trace_get_name(VALUE self) {
|
|
|
348
255
|
} else {
|
|
349
256
|
return Qnil;
|
|
350
257
|
}
|
|
351
|
-
|
|
352
|
-
//return UnwrapOption(RustSlice, skylight_trace_get_name(trace), SLICE2STR);
|
|
353
258
|
}
|
|
354
259
|
|
|
355
260
|
static VALUE trace_get_uuid(VALUE self) {
|
|
@@ -408,15 +313,7 @@ static VALUE trace_span_set_description(VALUE self, VALUE index, VALUE descripti
|
|
|
408
313
|
|
|
409
314
|
static VALUE trace_serialize(VALUE self) {
|
|
410
315
|
Transfer_My_Struct(trace, RustTrace, freedTrace);
|
|
411
|
-
|
|
412
|
-
RustString string;
|
|
413
|
-
|
|
414
|
-
CHECK_FFI(skylight_trace_serialize_into_new_buffer(trace, &string), "Could not serialize Trace");
|
|
415
|
-
skylight_trace_free(trace);
|
|
416
|
-
|
|
417
|
-
VALUE rb_string = VEC2STR(string);
|
|
418
|
-
skylight_free_buf(string);
|
|
419
|
-
return rb_string;
|
|
316
|
+
return SERIALIZE(trace);
|
|
420
317
|
}
|
|
421
318
|
|
|
422
319
|
/**
|
|
@@ -428,12 +325,15 @@ static const char* freedBatch = "You can't do anything with a Batch once it's be
|
|
|
428
325
|
VALUE batch_new(VALUE klass, VALUE rb_timestamp, VALUE rb_hostname) {
|
|
429
326
|
CHECK_NUMERIC(rb_timestamp);
|
|
430
327
|
|
|
431
|
-
|
|
328
|
+
RustSlice* hostname = NULL;
|
|
329
|
+
RustSlice tmp;
|
|
330
|
+
|
|
432
331
|
uint32_t timestamp = (uint32_t) NUM2ULONG(rb_timestamp);
|
|
433
332
|
|
|
434
333
|
if (rb_hostname != Qnil) {
|
|
435
334
|
CHECK_TYPE(rb_hostname, T_STRING);
|
|
436
|
-
|
|
335
|
+
tmp = STR2SLICE(rb_hostname);
|
|
336
|
+
hostname = &tmp;
|
|
437
337
|
}
|
|
438
338
|
|
|
439
339
|
RustBatch batch;
|
|
@@ -459,22 +359,14 @@ VALUE batch_move_in(VALUE self, VALUE rb_string) {
|
|
|
459
359
|
|
|
460
360
|
My_Struct(batch, RustBatch, freedBatch);
|
|
461
361
|
|
|
462
|
-
CHECK_FFI(skylight_batch_move_in(batch,
|
|
362
|
+
CHECK_FFI(skylight_batch_move_in(batch, STR2SLICE(rb_string)), "Could not add serialized Trace to Batch");
|
|
463
363
|
|
|
464
364
|
return Qnil;
|
|
465
365
|
}
|
|
466
366
|
|
|
467
367
|
VALUE batch_serialize(VALUE self) {
|
|
468
368
|
Transfer_My_Struct(batch, RustBatch, freedBatch);
|
|
469
|
-
|
|
470
|
-
RustString string;
|
|
471
|
-
|
|
472
|
-
CHECK_FFI(skylight_batch_serialize_into_new_buffer(batch, &string), "Could not serialize Batch");
|
|
473
|
-
skylight_batch_free(batch);
|
|
474
|
-
|
|
475
|
-
VALUE rb_string = VEC2STR(string);
|
|
476
|
-
skylight_free_buf(string);
|
|
477
|
-
return rb_string;
|
|
369
|
+
return SERIALIZE(batch);
|
|
478
370
|
}
|
|
479
371
|
|
|
480
372
|
void Init_skylight_native() {
|
data/ext/test/extconf.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'mkmf'
|
|
2
|
+
|
|
3
|
+
have_header 'dlfcn.h'
|
|
4
|
+
|
|
5
|
+
find_header("rust_support/ruby.h", "..") || abort("No rust_support")
|
|
6
|
+
find_library("skylight_test", "skylight_test_factory", ".") || abort("No skylight_test")
|
|
7
|
+
|
|
8
|
+
$CFLAGS << " -Werror"
|
|
9
|
+
if RbConfig::CONFIG["arch"] =~ /darwin(\d+)?/
|
|
10
|
+
$LDFLAGS << " -lpthread"
|
|
11
|
+
else
|
|
12
|
+
$LDFLAGS << " -Wl"
|
|
13
|
+
$LDFLAGS << " -lrt -ldl -lm -lpthread"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
CONFIG['warnflags'].gsub!('-Wdeclaration-after-statement', '')
|
|
17
|
+
|
|
18
|
+
create_makefile 'skylight_native_test', '.'
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#include <ruby.h>
|
|
2
|
+
#include "skylight_test.h"
|
|
3
|
+
|
|
4
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
|
5
|
+
#include <ruby/encoding.h>
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
VALUE rb_mSkylightTest;
|
|
9
|
+
VALUE rb_mNumeric;
|
|
10
|
+
VALUE rb_mStrings;
|
|
11
|
+
VALUE rb_mStructs;
|
|
12
|
+
VALUE rb_cPerson;
|
|
13
|
+
|
|
14
|
+
static VALUE numeric_multiply(VALUE klass, VALUE a, VALUE b) {
|
|
15
|
+
CHECK_NUMERIC(a);
|
|
16
|
+
CHECK_NUMERIC(b);
|
|
17
|
+
|
|
18
|
+
uint64_t ret;
|
|
19
|
+
|
|
20
|
+
CHECK_FFI(skylight_test_numeric_multiply(NUM2ULL(a), NUM2ULL(b), &ret), "could not multiply");
|
|
21
|
+
|
|
22
|
+
return ULL2NUM(ret);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static VALUE strings_multiple(VALUE klass, VALUE input) {
|
|
26
|
+
CHECK_TYPE(input, T_STRING);
|
|
27
|
+
|
|
28
|
+
RustString string;
|
|
29
|
+
|
|
30
|
+
CHECK_FFI(skylight_test_strings_reverse(STR2SLICE(input), &string), "could not reverse");
|
|
31
|
+
|
|
32
|
+
return RUSTSTR2STR(string);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static const char* freedPerson = "You can't do anything with a Person once it is freed";
|
|
36
|
+
|
|
37
|
+
static VALUE person_new(VALUE klass, VALUE name, VALUE age) {
|
|
38
|
+
CHECK_TYPE(name, T_STRING);
|
|
39
|
+
CHECK_NUMERIC(age);
|
|
40
|
+
|
|
41
|
+
RustPerson person;
|
|
42
|
+
|
|
43
|
+
CHECK_FFI(skylight_test_person_new(STR2SLICE(name), NUM2ULL(age), &person), "could not create new Person");
|
|
44
|
+
|
|
45
|
+
return Data_Wrap_Struct(rb_cPerson, NULL, skylight_test_person_free, person);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static VALUE person_get_name(VALUE self) {
|
|
49
|
+
My_Struct(person, RustPerson, freedPerson);
|
|
50
|
+
|
|
51
|
+
RustSlice name;
|
|
52
|
+
|
|
53
|
+
CHECK_FFI(skylight_test_person_get_name(person, &name), "could not get person name");
|
|
54
|
+
|
|
55
|
+
return SLICE2STR(name);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static VALUE person_get_age(VALUE self) {
|
|
59
|
+
My_Struct(person, RustPerson, freedPerson);
|
|
60
|
+
|
|
61
|
+
uint64_t age;
|
|
62
|
+
|
|
63
|
+
CHECK_FFI(skylight_test_person_get_age(person, &age), "could not get person age");
|
|
64
|
+
|
|
65
|
+
return ULL2NUM(age);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void Init_skylight_native_test() {
|
|
69
|
+
rb_mSkylightTest = rb_define_module("SkylightTest");
|
|
70
|
+
rb_mNumeric = rb_define_module_under(rb_mSkylightTest, "Numeric");
|
|
71
|
+
rb_mStrings = rb_define_module_under(rb_mSkylightTest, "Strings");
|
|
72
|
+
rb_mStructs = rb_define_module_under(rb_mSkylightTest, "Structs");
|
|
73
|
+
rb_cPerson = rb_define_class_under(rb_mStructs, "Person", rb_cObject);
|
|
74
|
+
|
|
75
|
+
rb_define_singleton_method(rb_mNumeric, "multiply", numeric_multiply, 2);
|
|
76
|
+
|
|
77
|
+
rb_define_singleton_method(rb_mStrings, "reverse", strings_multiple, 1);
|
|
78
|
+
|
|
79
|
+
rb_define_singleton_method(rb_cPerson, "new", person_new, 2);
|
|
80
|
+
rb_define_method(rb_cPerson, "name", person_get_name, 0);
|
|
81
|
+
rb_define_method(rb_cPerson, "age", person_get_age, 0);
|
|
82
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#ifndef __SKYLIGHT_TEST_H__
|
|
2
|
+
#define __SKYLIGHT_TEST_H__
|
|
3
|
+
|
|
4
|
+
#include <stddef.h>
|
|
5
|
+
#include <stdint.h>
|
|
6
|
+
#include <stdbool.h>
|
|
7
|
+
|
|
8
|
+
#include <rust_support/ruby.h>
|
|
9
|
+
|
|
10
|
+
typedef void * RustPerson;
|
|
11
|
+
|
|
12
|
+
bool skylight_test_numeric_multiply(uint64_t, uint64_t, uint64_t*);
|
|
13
|
+
bool skylight_test_strings_reverse(RustSlice, RustString*);
|
|
14
|
+
|
|
15
|
+
bool skylight_test_person_new(RustSlice, uint64_t, RustPerson*);
|
|
16
|
+
bool skylight_test_person_get_name(RustPerson, RustSlice*);
|
|
17
|
+
bool skylight_test_person_get_age(RustPerson, uint64_t*);
|
|
18
|
+
bool skylight_test_person_free(RustPerson);
|
|
19
|
+
|
|
20
|
+
#endif
|
data/lib/skylight/railtie.rb
CHANGED
|
@@ -13,7 +13,9 @@ module Skylight
|
|
|
13
13
|
config.skylight.config_path = "config/skylight.yml"
|
|
14
14
|
|
|
15
15
|
# The probes to load
|
|
16
|
-
|
|
16
|
+
# net_http is on by default
|
|
17
|
+
# Also available: excon
|
|
18
|
+
config.skylight.probes = ['net_http']
|
|
17
19
|
|
|
18
20
|
initializer 'skylight.configure' do |app|
|
|
19
21
|
# Load probes even when agent is inactive to catch probe related bugs sooner
|
data/lib/skylight/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: skylight
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tilde, Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-06-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- -
|
|
17
|
+
- - '>='
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: 3.0.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- -
|
|
24
|
+
- - '>='
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: 3.0.0
|
|
27
27
|
description:
|
|
@@ -33,14 +33,6 @@ extensions:
|
|
|
33
33
|
- ext/extconf.rb
|
|
34
34
|
extra_rdoc_files: []
|
|
35
35
|
files:
|
|
36
|
-
- CHANGELOG.md
|
|
37
|
-
- README.md
|
|
38
|
-
- bin/skylight
|
|
39
|
-
- ext/extconf.rb
|
|
40
|
-
- ext/libskylight.yml
|
|
41
|
-
- ext/skylight.h
|
|
42
|
-
- ext/skylight.map
|
|
43
|
-
- ext/skylight_native.c
|
|
44
36
|
- lib/skylight.rb
|
|
45
37
|
- lib/skylight/api.rb
|
|
46
38
|
- lib/skylight/cli.rb
|
|
@@ -151,6 +143,18 @@ files:
|
|
|
151
143
|
- lib/sql_lexer.rb
|
|
152
144
|
- lib/sql_lexer/lexer.rb
|
|
153
145
|
- lib/sql_lexer/version.rb
|
|
146
|
+
- ext/rust_support/ruby.h
|
|
147
|
+
- ext/skylight.h
|
|
148
|
+
- ext/test/skylight_test.h
|
|
149
|
+
- ext/skylight_native.c
|
|
150
|
+
- ext/test/skylight_native_test.c
|
|
151
|
+
- ext/skylight.map
|
|
152
|
+
- ext/extconf.rb
|
|
153
|
+
- ext/test/extconf.rb
|
|
154
|
+
- ext/libskylight.yml
|
|
155
|
+
- CHANGELOG.md
|
|
156
|
+
- README.md
|
|
157
|
+
- bin/skylight
|
|
154
158
|
homepage: http://www.skylight.io
|
|
155
159
|
licenses: []
|
|
156
160
|
metadata: {}
|
|
@@ -160,19 +164,19 @@ require_paths:
|
|
|
160
164
|
- lib
|
|
161
165
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
166
|
requirements:
|
|
163
|
-
- -
|
|
167
|
+
- - '>='
|
|
164
168
|
- !ruby/object:Gem::Version
|
|
165
169
|
version: 1.9.2
|
|
166
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
171
|
requirements:
|
|
168
|
-
- -
|
|
172
|
+
- - '>='
|
|
169
173
|
- !ruby/object:Gem::Version
|
|
170
174
|
version: '0'
|
|
171
175
|
requirements: []
|
|
172
176
|
rubyforge_project:
|
|
173
|
-
rubygems_version: 2.
|
|
177
|
+
rubygems_version: 2.0.3
|
|
174
178
|
signing_key:
|
|
175
179
|
specification_version: 4
|
|
176
|
-
summary: Skylight is a
|
|
180
|
+
summary: Skylight is a smart profiler for Rails apps
|
|
177
181
|
test_files: []
|
|
178
182
|
has_rdoc:
|