skylight 0.3.21 → 0.4.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +0 -4
  3. data/ext/extconf.rb +92 -47
  4. data/ext/libskylight.yml +4 -4
  5. data/ext/skylight_native.c +248 -286
  6. data/lib/skylight.rb +19 -114
  7. data/lib/skylight/api.rb +1 -1
  8. data/lib/skylight/config.rb +176 -146
  9. data/lib/skylight/data/cacert.pem +717 -719
  10. data/lib/skylight/formatters/http.rb +1 -1
  11. data/lib/skylight/instrumenter.rb +28 -35
  12. data/lib/skylight/native.rb +58 -72
  13. data/lib/skylight/normalizers.rb +0 -1
  14. data/lib/skylight/normalizers/active_record/sql.rb +0 -4
  15. data/lib/skylight/probes/excon/middleware.rb +3 -1
  16. data/lib/skylight/probes/net_http.rb +3 -1
  17. data/lib/skylight/subscriber.rb +0 -4
  18. data/lib/skylight/trace.rb +189 -0
  19. data/lib/skylight/util.rb +10 -12
  20. data/lib/skylight/util/hostname.rb +17 -0
  21. data/lib/skylight/util/http.rb +33 -36
  22. data/lib/skylight/util/logging.rb +20 -1
  23. data/lib/skylight/util/multi_io.rb +21 -0
  24. data/lib/skylight/util/native_ext_fetcher.rb +83 -69
  25. data/lib/skylight/util/platform.rb +67 -0
  26. data/lib/skylight/util/ssl.rb +50 -0
  27. data/lib/skylight/version.rb +1 -1
  28. metadata +9 -34
  29. data/ext/rust_support/ruby.h +0 -93
  30. data/ext/skylight.h +0 -85
  31. data/ext/skylight.map +0 -4
  32. data/ext/test/extconf.rb +0 -18
  33. data/ext/test/skylight_native_test.c +0 -82
  34. data/ext/test/skylight_test.h +0 -20
  35. data/lib/skylight/formatters.rb +0 -6
  36. data/lib/skylight/messages.rb +0 -21
  37. data/lib/skylight/messages/error.rb +0 -15
  38. data/lib/skylight/messages/hello.rb +0 -13
  39. data/lib/skylight/messages/trace.rb +0 -179
  40. data/lib/skylight/messages/trace_envelope.rb +0 -19
  41. data/lib/skylight/metrics.rb +0 -9
  42. data/lib/skylight/metrics/ewma.rb +0 -69
  43. data/lib/skylight/metrics/meter.rb +0 -58
  44. data/lib/skylight/metrics/process_cpu_gauge.rb +0 -65
  45. data/lib/skylight/metrics/process_mem_gauge.rb +0 -34
  46. data/lib/skylight/util/conversions.rb +0 -9
  47. data/lib/skylight/util/queue.rb +0 -96
  48. data/lib/skylight/util/task.rb +0 -172
  49. data/lib/skylight/util/uniform_sample.rb +0 -63
  50. data/lib/skylight/worker.rb +0 -19
  51. data/lib/skylight/worker/builder.rb +0 -73
  52. data/lib/skylight/worker/collector.rb +0 -274
  53. data/lib/skylight/worker/connection.rb +0 -87
  54. data/lib/skylight/worker/connection_set.rb +0 -56
  55. data/lib/skylight/worker/embedded.rb +0 -24
  56. data/lib/skylight/worker/metrics_reporter.rb +0 -104
  57. data/lib/skylight/worker/server.rb +0 -336
  58. data/lib/skylight/worker/standalone.rb +0 -421
@@ -0,0 +1,50 @@
1
+ require 'openssl'
2
+
3
+ module Skylight
4
+ module Util
5
+ class SSL
6
+ DEFAULT_CA_FILE = File.expand_path('../../data/cacert.pem', __FILE__)
7
+
8
+ def self.detect_ca_cert_file!
9
+ @ca_cert_file = false
10
+ if defined?(OpenSSL::X509::DEFAULT_CERT_FILE)
11
+ f = OpenSSL::X509::DEFAULT_CERT_FILE
12
+
13
+ if f && File.exist?(f)
14
+ @ca_cert_file = f
15
+ end
16
+ end
17
+ end
18
+
19
+ def self.detect_ca_cert_dir!
20
+ @ca_cert_dir = false
21
+ if defined?(OpenSSL::X509::DEFAULT_CERT_DIR)
22
+ d = OpenSSL::X509::DEFAULT_CERT_DIR
23
+
24
+ if d && File.exist?(d)
25
+ @ca_cert_dir = d
26
+ end
27
+ end
28
+ end
29
+
30
+ detect_ca_cert_file!
31
+ detect_ca_cert_dir!
32
+
33
+ def self.ca_cert_file?
34
+ !!@ca_cert_file
35
+ end
36
+
37
+ def self.ca_cert_dir?
38
+ !!@ca_cert_dir
39
+ end
40
+
41
+ def self.ca_cert_file_or_default
42
+ @ca_cert_file || DEFAULT_CA_FILE
43
+ end
44
+
45
+ def self.ca_cert_dir
46
+ @ca_cert_dir
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,4 +1,4 @@
1
1
  module Skylight
2
- VERSION = '0.3.21'
2
+ VERSION = '0.4.0-alpha1'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skylight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.21
4
+ version: 0.4.0.alpha1
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-10-08 00:00:00.000000000 Z
11
+ date: 2014-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -41,34 +41,17 @@ files:
41
41
  - bin/skylight
42
42
  - ext/extconf.rb
43
43
  - ext/libskylight.yml
44
- - ext/rust_support/ruby.h
45
- - ext/skylight.h
46
- - ext/skylight.map
47
44
  - ext/skylight_native.c
48
- - ext/test/extconf.rb
49
- - ext/test/skylight_native_test.c
50
- - ext/test/skylight_test.h
51
45
  - lib/skylight.rb
52
46
  - lib/skylight/api.rb
53
47
  - lib/skylight/cli.rb
54
48
  - lib/skylight/compat.rb
55
49
  - lib/skylight/config.rb
56
50
  - lib/skylight/data/cacert.pem
57
- - lib/skylight/formatters.rb
58
51
  - lib/skylight/formatters/http.rb
59
52
  - lib/skylight/gc.rb
60
53
  - lib/skylight/helpers.rb
61
54
  - lib/skylight/instrumenter.rb
62
- - lib/skylight/messages.rb
63
- - lib/skylight/messages/error.rb
64
- - lib/skylight/messages/hello.rb
65
- - lib/skylight/messages/trace.rb
66
- - lib/skylight/messages/trace_envelope.rb
67
- - lib/skylight/metrics.rb
68
- - lib/skylight/metrics/ewma.rb
69
- - lib/skylight/metrics/meter.rb
70
- - lib/skylight/metrics/process_cpu_gauge.rb
71
- - lib/skylight/metrics/process_mem_gauge.rb
72
55
  - lib/skylight/middleware.rb
73
56
  - lib/skylight/native.rb
74
57
  - lib/skylight/normalizers.rb
@@ -98,18 +81,19 @@ files:
98
81
  - lib/skylight/probes/redis.rb
99
82
  - lib/skylight/railtie.rb
100
83
  - lib/skylight/subscriber.rb
84
+ - lib/skylight/trace.rb
101
85
  - lib/skylight/util.rb
102
86
  - lib/skylight/util/allocation_free.rb
103
87
  - lib/skylight/util/clock.rb
104
- - lib/skylight/util/conversions.rb
105
88
  - lib/skylight/util/gzip.rb
89
+ - lib/skylight/util/hostname.rb
106
90
  - lib/skylight/util/http.rb
107
91
  - lib/skylight/util/inflector.rb
108
92
  - lib/skylight/util/logging.rb
93
+ - lib/skylight/util/multi_io.rb
109
94
  - lib/skylight/util/native_ext_fetcher.rb
110
- - lib/skylight/util/queue.rb
111
- - lib/skylight/util/task.rb
112
- - lib/skylight/util/uniform_sample.rb
95
+ - lib/skylight/util/platform.rb
96
+ - lib/skylight/util/ssl.rb
113
97
  - lib/skylight/vendor/active_support/notifications.rb
114
98
  - lib/skylight/vendor/active_support/notifications/fanout.rb
115
99
  - lib/skylight/vendor/active_support/notifications/instrumenter.rb
@@ -158,15 +142,6 @@ files:
158
142
  - lib/skylight/vendor/thread_safe/synchronized_cache_backend.rb
159
143
  - lib/skylight/version.rb
160
144
  - lib/skylight/vm/gc.rb
161
- - lib/skylight/worker.rb
162
- - lib/skylight/worker/builder.rb
163
- - lib/skylight/worker/collector.rb
164
- - lib/skylight/worker/connection.rb
165
- - lib/skylight/worker/connection_set.rb
166
- - lib/skylight/worker/embedded.rb
167
- - lib/skylight/worker/metrics_reporter.rb
168
- - lib/skylight/worker/server.rb
169
- - lib/skylight/worker/standalone.rb
170
145
  - lib/sql_lexer.rb
171
146
  - lib/sql_lexer/lexer.rb
172
147
  - lib/sql_lexer/string_scanner.rb
@@ -185,9 +160,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
160
  version: 1.9.2
186
161
  required_rubygems_version: !ruby/object:Gem::Requirement
187
162
  requirements:
188
- - - ">="
163
+ - - ">"
189
164
  - !ruby/object:Gem::Version
190
- version: '0'
165
+ version: 1.3.1
191
166
  requirements: []
192
167
  rubyforge_project:
193
168
  rubygems_version: 2.2.2
@@ -1,93 +0,0 @@
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
- }
@@ -1,85 +0,0 @@
1
- #ifndef __SKYLIGHT_H__
2
- #define __SKYLIGHT_H__
3
-
4
- #include <stddef.h>
5
- #include <stdint.h>
6
- #include <stdbool.h>
7
-
8
- #include <rust_support/ruby.h>
9
-
10
- /**
11
- * TODO: This is copied from rust_support
12
- */
13
-
14
- bool skylight_string_as_slice(RustString, RustSlice*);
15
-
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
- })
23
-
24
- /**
25
- * Externed Rust functions from libskylight
26
- */
27
-
28
- typedef void * RustSerializer;
29
- typedef void * RustHello;
30
- typedef void * RustError;
31
- typedef void * RustTrace;
32
- typedef void * RustBatch;
33
-
34
- void factory();
35
-
36
- // Rust skylight_hello prototypes
37
- bool skylight_hello_new(RustSlice, uint32_t, RustHello*);
38
- bool skylight_hello_free(RustHello);
39
- bool skylight_hello_load(RustSlice, RustHello*);
40
- bool skylight_hello_cmd_add(RustHello, RustSlice);
41
- bool skylight_hello_get_version(RustHello, RustSlice*);
42
- bool skylight_hello_cmd_length(RustHello, uint32_t*);
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);
46
- bool skylight_high_res_time(uint64_t*);
47
-
48
- // Rust skylight_trace prototypes
49
- bool skylight_trace_new(uint64_t, RustSlice, RustTrace*);
50
- bool skylight_trace_free(RustTrace);
51
- bool skylight_trace_name_from_serialized_into_new_buffer(RustSlice, RustString*);
52
- bool skylight_trace_get_started_at(RustTrace, uint64_t*);
53
- bool skylight_trace_set_name(RustTrace, RustSlice);
54
- bool skylight_trace_get_name(RustTrace, RustSlice*);
55
- bool skylight_trace_get_uuid(RustTrace, RustSlice*);
56
- bool skylight_trace_start_span(RustTrace, uint64_t, RustSlice, uint32_t*);
57
- bool skylight_trace_stop_span(RustTrace, uint32_t, uint64_t);
58
- bool skylight_trace_span_set_title(RustTrace, uint64_t, RustSlice);
59
- bool skylight_trace_span_set_description(RustTrace, uint64_t, RustSlice);
60
- bool skylight_trace_get_serializer(RustTrace, RustSerializer*);
61
- bool skylight_trace_serialize(RustTrace, RustSerializer, RustSlice);
62
-
63
- // Batch methods
64
- bool skylight_batch_new(uint32_t, RustSlice*, RustBatch*);
65
- bool skylight_batch_free(RustBatch);
66
- bool skylight_batch_set_endpoint_count(RustBatch, RustSlice, uint64_t);
67
- bool skylight_batch_move_in(RustBatch, RustSlice);
68
- bool skylight_batch_get_serializer(RustBatch, RustSerializer*);
69
- bool skylight_batch_serialize(RustBatch, RustSerializer, RustSlice);
70
-
71
- // Error methods
72
- bool skylight_error_new(RustSlice, RustSlice, RustError*);
73
- bool skylight_error_free(RustError);
74
- bool skylight_error_load(RustSlice, RustError*);
75
- bool skylight_error_get_group(RustError, RustSlice*);
76
- bool skylight_error_get_description(RustError, RustSlice*);
77
- bool skylight_error_get_details(RustError, RustSlice*);
78
- bool skylight_error_set_details(RustError, RustSlice);
79
- bool skylight_error_get_serializer(RustError, RustSerializer*);
80
- bool skylight_error_serialize(RustError, RustSerializer, RustSlice);
81
-
82
- bool skylight_serializer_get_serialized_size(RustSerializer, size_t*);
83
- bool skylight_serializer_free(RustSerializer);
84
-
85
- #endif
@@ -1,4 +0,0 @@
1
- {
2
- global: Init_skylight_native;
3
- local: *;
4
- };
@@ -1,18 +0,0 @@
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', '.'
@@ -1,82 +0,0 @@
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
- }