oboe 2.1.3 → 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,275 @@
1
+ #ifndef LIBOBOE_H
2
+ #define LIBOBOE_H
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ #include <sys/types.h>
9
+ #include <inttypes.h>
10
+ #include "bson/bson.h"
11
+
12
+ #define OBOE_SAMPLE_RATE_DEFAULT 300000 // 30%
13
+ #define OBOE_SAMPLE_RESOLUTION 1000000
14
+
15
+ #define OBOE_MAX_TASK_ID_LEN 20
16
+ #define OBOE_MAX_OP_ID_LEN 8
17
+ #define OBOE_MAX_METADATA_PACK_LEN 512
18
+
19
+ #define XTR_CURRENT_VERSION 1
20
+ #define XTR_UDP_PORT 7831
21
+
22
+
23
+ // structs
24
+
25
+ typedef struct oboe_ids {
26
+ uint8_t task_id[OBOE_MAX_TASK_ID_LEN];
27
+ uint8_t op_id[OBOE_MAX_OP_ID_LEN];
28
+ } oboe_ids_t;
29
+
30
+ typedef struct oboe_metadata {
31
+ oboe_ids_t ids;
32
+ size_t task_len;
33
+ size_t op_len;
34
+ } oboe_metadata_t;
35
+
36
+ typedef struct oboe_event {
37
+ oboe_metadata_t metadata;
38
+ bson_buffer bbuf;
39
+ char * bb_str;
40
+ } oboe_event_t;
41
+
42
+
43
+ // oboe_metadata
44
+
45
+ int oboe_metadata_init (oboe_metadata_t *);
46
+ int oboe_metadata_destroy (oboe_metadata_t *);
47
+
48
+ int oboe_metadata_is_valid (const oboe_metadata_t *);
49
+
50
+ void oboe_metadata_copy (oboe_metadata_t *, const oboe_metadata_t *);
51
+
52
+ void oboe_metadata_random (oboe_metadata_t *);
53
+
54
+ int oboe_metadata_set_lengths (oboe_metadata_t *, size_t, size_t);
55
+ int oboe_metadata_create_event (const oboe_metadata_t *, oboe_event_t *);
56
+
57
+ int oboe_metadata_tostr (const oboe_metadata_t *, char *, size_t);
58
+ int oboe_metadata_fromstr (oboe_metadata_t *, const char *, size_t);
59
+
60
+
61
+ // oboe_event
62
+
63
+ int oboe_event_init (oboe_event_t *, const oboe_metadata_t *);
64
+ int oboe_event_destroy (oboe_event_t *);
65
+
66
+ int oboe_event_add_info (oboe_event_t *, const char *, const char *);
67
+ int oboe_event_add_info_binary (oboe_event_t *, const char *, const char *, size_t);
68
+ int oboe_event_add_info_int64 (oboe_event_t *, const char *, const int64_t);
69
+ int oboe_event_add_info_double (oboe_event_t *, const char *, const double);
70
+ int oboe_event_add_info_bool (oboe_event_t *, const char *, const int);
71
+ int oboe_event_add_info_fmt (oboe_event_t *, const char *key, const char *fmt, ...);
72
+ int oboe_event_add_info_bson (oboe_event_t *, const char *key, const bson *val);
73
+ int oboe_event_add_edge (oboe_event_t *, const oboe_metadata_t *);
74
+ int oboe_event_add_edge_fromstr(oboe_event_t *, const char *, size_t);
75
+
76
+
77
+ // oboe_context
78
+
79
+ oboe_metadata_t *oboe_context_get();
80
+ void oboe_context_set(oboe_metadata_t *);
81
+ int oboe_context_set_fromstr(const char *, size_t);
82
+
83
+ void oboe_context_clear();
84
+
85
+ int oboe_context_is_valid();
86
+
87
+
88
+ // oboe_reporter
89
+
90
+ typedef ssize_t (*reporter_send)(void *, const char *, size_t);
91
+ typedef int (*reporter_destroy)(void *);
92
+
93
+ typedef struct oboe_reporter {
94
+ void * descriptor;
95
+ reporter_send send;
96
+ reporter_destroy destroy;
97
+ } oboe_reporter_t;
98
+
99
+ int oboe_reporter_udp_init (oboe_reporter_t *, const char *, const char *);
100
+ int oboe_reporter_file_init (oboe_reporter_t *, const char *);
101
+
102
+ int oboe_reporter_send(oboe_reporter_t *, oboe_metadata_t *, oboe_event_t *);
103
+ int oboe_reporter_destroy(oboe_reporter_t *);
104
+ ssize_t oboe_reporter_udp_send(void *desc, const char *data, size_t len);
105
+
106
+
107
+ // initialization
108
+
109
+ void oboe_init();
110
+
111
+
112
+ // Settings interface
113
+
114
+ #define OBOE_SETTINGS_VERSION 1
115
+ #define OBOE_SETTINGS_MAGIC_NUMBER 0x6f626f65
116
+ #define OBOE_SETTINGS_TYPE_SKIP 0
117
+ #define OBOE_SETTINGS_TYPE_STOP 1
118
+ #define OBOE_SETTINGS_TYPE_DEFAULT_SAMPLE_RATE 2
119
+ #define OBOE_SETTINGS_TYPE_LAYER_SAMPLE_RATE 3
120
+ #define OBOE_SETTINGS_TYPE_LAYER_APP_SAMPLE_RATE 4
121
+ #define OBOE_SETTINGS_TYPE_LAYER_HTTPHOST_SAMPLE_RATE 5
122
+ #define OBOE_SETTINGS_TYPE_CONFIG_STRING 6
123
+ #define OBOE_SETTINGS_TYPE_CONFIG_INT 7
124
+ #define OBOE_SETTINGS_FLAG_OK 0x0
125
+ #define OBOE_SETTINGS_FLAG_INVALID 0x1
126
+ #define OBOE_SETTINGS_FLAG_OVERRIDE 0x2
127
+ #define OBOE_SETTINGS_FLAG_SAMPLE_START 0x4
128
+ #define OBOE_SETTINGS_FLAG_SAMPLE_THROUGH 0x8
129
+ #define OBOE_SETTINGS_FLAG_SAMPLE_THROUGH_ALWAYS 0x10
130
+ #define OBOE_SETTINGS_FLAG_SAMPLE_AVW_ALWAYS 0x20
131
+ #define OBOE_SETTINGS_MAX_STRLEN 256
132
+
133
+ #define OBOE_SETTINGS_UNSET -1
134
+ #define OBOE_SETTINGS_MIN_REFRESH_INTERVAL 30
135
+
136
+ // Value for "SampleSource" info key
137
+ // where was the sample rate specified? (oboe settings, config file, hard-coded default, etc)
138
+ #define OBOE_SAMPLE_RATE_SOURCE_FILE 1
139
+ #define OBOE_SAMPLE_RATE_SOURCE_DEFAULT 2
140
+ #define OBOE_SAMPLE_RATE_SOURCE_OBOE 3
141
+ #define OBOE_SAMPLE_RATE_SOURCE_LAST_OBOE 4
142
+ #define OBOE_SAMPLE_RATE_SOURCE_DEFAULT_MISCONFIGURED 5
143
+ #define OBOE_SAMPLE_RATE_SOURCE_OBOE_DEFAULT 6
144
+
145
+ #define OBOE_SAMPLE_RESOLUTION 1000000
146
+
147
+ // Used to convert to settings flags:
148
+ #define OBOE_TRACE_NEVER 0
149
+ #define OBOE_TRACE_ALWAYS 1
150
+ #define OBOE_TRACE_THROUGH 2
151
+
152
+ typedef struct {
153
+ volatile uint32_t magic;
154
+ volatile uint32_t timestamp;
155
+ volatile uint16_t type;
156
+ volatile uint16_t flags;
157
+ volatile uint32_t value;
158
+ uint32_t _pad;
159
+ char layer[OBOE_SETTINGS_MAX_STRLEN];
160
+ char arg[OBOE_SETTINGS_MAX_STRLEN];
161
+ } __attribute__((packed)) oboe_settings_t;
162
+
163
+ // Current settings configuration:
164
+ typedef struct {
165
+ int tracing_mode; // loaded from config file
166
+ int sample_rate; // loaded from config file
167
+ int default_sample_rate; // default sample rate (fallback)
168
+ oboe_settings_t *settings; // cached settings, updated by tracelyzer (init to NULL)
169
+ int last_auto_sample_rate; // stores last known automatic sampling rate
170
+ uint16_t last_auto_flags; // stores last known flags associated with above
171
+ uint32_t last_auto_timestamp; // timestamp from last *settings lookup
172
+ uint32_t last_refresh; // last refresh time
173
+ } oboe_settings_cfg_t;
174
+
175
+ oboe_settings_t* oboe_settings_get(uint16_t type, const char* layer, const char* arg);
176
+ oboe_settings_t* oboe_settings_get_layer_tracing_mode(const char* layer);
177
+ oboe_settings_t* oboe_settings_get_layer_sample_rate(const char* layer);
178
+ oboe_settings_t* oboe_settings_get_layer_app_sample_rate(const char* layer, const char* app);
179
+ uint32_t oboe_settings_get_latest_timestamp(const char* layer);
180
+ int oboe_settings_get_value(oboe_settings_t *s, int *outval, unsigned short *outflags, uint32_t *outtimestamp);
181
+
182
+ oboe_settings_cfg_t* oboe_settings_cfg_get();
183
+ void oboe_settings_cfg_init(oboe_settings_cfg_t *cfg);
184
+ void oboe_settings_cfg_tracing_mode_set(int new_mode);
185
+ void oboe_settings_cfg_sample_rate_set(int new_rate);
186
+
187
+ /**
188
+ * Check if this request should be sampled (deprecated - use oboe_sample_layer() instead).
189
+ *
190
+ * @param layer Layer name as used in oboe_settings_t.layer (may be NULL to use default settings)
191
+ * @param xtrace X-Trace ID string from an HTTP request or higher layer (NULL or empty string if not present).
192
+ * @param cfg The settings configuration to use for this evaluation.
193
+ * @param sample_rate_out The sample rate used to check if this request should be sampled
194
+ * (output - may be zero if not used).
195
+ * @param sample_source_out The OBOE_SAMPLE_RATE_SOURCE used to check if this request
196
+ * should be sampled (output - may be zero if not used).
197
+ * @return Non-zero if the given layer should be sampled.
198
+ */
199
+ int oboe_sample_request(const char *layer, const char *in_xtrace, oboe_settings_cfg_t *cfg,
200
+ int *sample_rate_out, int *sample_source_out);
201
+ int oboe_rand_get_value();
202
+
203
+ /**
204
+ * Check if this request should be sampled.
205
+ *
206
+ * Checks for sample rate flags and settings for the specified layer, considers any
207
+ * special features in the X-Trace and X-TV-Meta HTTP headers, and, if appropriate,
208
+ * rolls the virtual dice to decide if this request should be sampled.
209
+ *
210
+ * This replaces oboe_sample_request with a version that uses the settings
211
+ * configuration kept in thread-local storage and takes the X-TV-Meta HTTP
212
+ * header value in order to support AppView Web integration.
213
+ *
214
+ * @param layer Layer name as used in oboe_settings_t.layer (may be NULL to use default settings)
215
+ * @param xtrace X-Trace ID string from an HTTP request or higher layer (NULL or empty string if not present).
216
+ * @param tv_meta AppView Web ID from X-TV-Meta HTTP header or higher layer (NULL or empty string if not present).
217
+ * @param sample_rate_out The sample rate used to check if this request should be sampled
218
+ * (output - may be zero if not used).
219
+ * @param sample_source_out The OBOE_SAMPLE_RATE_SOURCE used to check if this request
220
+ * should be sampled (output - may be zero if not used).
221
+ * @return Non-zero if the given layer should be sampled.
222
+ */
223
+ int oboe_sample_layer(
224
+ const char *layer,
225
+ const char *xtrace,
226
+ const char *tv_meta,
227
+ int *sample_rate_out,
228
+ int *sample_source_out
229
+ );
230
+
231
+ /* Oboe configuration interface. */
232
+
233
+ /**
234
+ * Check if the Oboe library is compatible with a given version.revision.
235
+ *
236
+ * This will succeed if the library is at least as recent as specified and if no
237
+ * definitions have been removed since that revision.
238
+ *
239
+ * @param version The library's version number which increments every time the API changes.
240
+ * @param revision The revision of the current version of the library.
241
+ * @return Non-zero if the Oboe library is considered compatible with the specified revision.
242
+ */
243
+ extern int oboe_config_check_version(int version, int revision);
244
+
245
+ /**
246
+ * Get the Oboe library version number.
247
+ *
248
+ * This number increments whenever the API is changed.
249
+ *
250
+ * @return The library's version number or -1 if the version is not known.
251
+ */
252
+ extern int oboe_config_get_version();
253
+
254
+ /**
255
+ * Get the Oboe library revision number.
256
+ *
257
+ * This is the revision of the current version which is updated whenever
258
+ * compatible changes are made to the API/ABI (ie. additions).
259
+ *
260
+ * @return The library's revision number or -1 if not known.
261
+ */
262
+ extern int oboe_config_get_revision();
263
+
264
+ /*
265
+ * Get the Oboe library version as a string.
266
+ *
267
+ * Returns the complete VERSION string or null
268
+ */
269
+ const char* oboe_config_get_version_string();
270
+
271
+ #ifdef __cplusplus
272
+ } // extern "C"
273
+ #endif
274
+
275
+ #endif // LIBOBOE_H
@@ -1,16 +1,9 @@
1
- // Copyright (c) 2012 by Tracelytics, Inc.
2
- // All rights reserved.
3
-
4
1
  #ifndef OBOE_HPP
5
2
  #define OBOE_HPP
6
3
 
7
4
  #include <string>
8
- #include <oboe/oboe.h>
5
+ #include <oboe.h>
9
6
 
10
- // oboe prefix added in liboboe 1.0
11
- #ifndef MAX_METADATA_PACK_LEN
12
- #define MAX_METADATA_PACK_LEN OBOE_MAX_METADATA_PACK_LEN
13
- #endif
14
7
 
15
8
  class Event;
16
9
 
@@ -57,7 +50,7 @@ public:
57
50
  #else
58
51
  std::string toString() {
59
52
  #endif
60
- char buf[MAX_METADATA_PACK_LEN];
53
+ char buf[OBOE_MAX_METADATA_PACK_LEN];
61
54
 
62
55
  int rc = oboe_metadata_tostr(this, buf, sizeof(buf) - 1);
63
56
  if (rc == 0) {
@@ -71,6 +64,55 @@ public:
71
64
 
72
65
  class Context {
73
66
  public:
67
+ /**
68
+ * Set the tracing mode.
69
+ *
70
+ * @param newMode One of
71
+ * - OBOE_TRACE_NEVER(0) to disable tracing,
72
+ * - OBOE_TRACE_ALWAYS(1) to start a new trace if needed, or
73
+ * - OBOE_TRACE_THROUGH(2) to only add to an existing trace.
74
+ */
75
+ static void setTracingMode(int newMode) {
76
+ oboe_settings_cfg_tracing_mode_set(newMode);
77
+ }
78
+
79
+ /**
80
+ * Set the default sample rate.
81
+ *
82
+ * This rate is used until overridden by the TraceView servers. If not set then the
83
+ * value 300,000 will be used (ie. 30%).
84
+ *
85
+ * The rate is interpreted as a ratio out of OBOE_SAMPLE_RESOLUTION (currently 1,000,000).
86
+ *
87
+ * @param newRate A number between 0 (none) and OBOE_SAMPLE_RESOLUTION (a million)
88
+ */
89
+ static void setDefaultSampleRate(int newRate) {
90
+ oboe_settings_cfg_sample_rate_set(newRate);
91
+ }
92
+
93
+ /**
94
+ * Check if the current request should be sampled based on settings.
95
+ *
96
+ * If in_xtrace is empty, then sampling will be considered as a new trace.
97
+ * Otherwise sampling will be considered as adding to the current trace.
98
+ * Different layers may have special rules.
99
+ *
100
+ * If a valid X-TV-Meta identifier is provided and AppView Web sample
101
+ * always is enabled then return true independent of the other conditions.
102
+ *
103
+ * @param layer Name of the layer being considered for tracing
104
+ * @param in_xtrace Incoming X-Trace ID (NULL or empty string if not present)
105
+ * @param in_tv_meta AppView Web ID from X-TV-Meta HTTP header or higher layer (NULL or empty string if not present).
106
+ * @return True if we should trace; otherwise false.
107
+ */
108
+ static bool sampleRequest(
109
+ std::string layer,
110
+ std::string in_xtrace,
111
+ std::string in_tv_meta)
112
+ {
113
+ return (oboe_sample_layer(layer.c_str(), in_xtrace.c_str(), in_tv_meta.c_str(), NULL, NULL));
114
+ }
115
+
74
116
  // returns pointer to current context (from thread-local storage)
75
117
  static oboe_metadata_t *get() {
76
118
  return oboe_context_get();
@@ -81,7 +123,7 @@ public:
81
123
  #else
82
124
  static std::string toString() {
83
125
  #endif
84
- char buf[MAX_METADATA_PACK_LEN];
126
+ char buf[OBOE_MAX_METADATA_PACK_LEN];
85
127
 
86
128
  oboe_metadata_t *md = Context::get();
87
129
  int rc = oboe_metadata_tostr(md, buf, sizeof(buf) - 1);
@@ -152,6 +194,8 @@ public:
152
194
  // called e.g. from Python e.addInfo("Key", None) & Ruby e.addInfo("Key", nil)
153
195
  bool addInfo(char *key, void* val) {
154
196
  // oboe_event_add_info(evt, key, NULL) does nothing
197
+ (void) key;
198
+ (void) val;
155
199
  return true;
156
200
  }
157
201
 
@@ -176,12 +220,16 @@ public:
176
220
  return oboe_event_add_edge(this, md) == 0;
177
221
  }
178
222
 
223
+ bool addEdgeStr(const std::string& val) {
224
+ return oboe_event_add_edge_fromstr(this, val.c_str(), val.size()) == 0;
225
+ }
226
+
179
227
  Metadata* getMetadata() {
180
228
  return new Metadata(&this->metadata);
181
229
  }
182
230
 
183
231
  std::string metadataString() {
184
- char buf[MAX_METADATA_PACK_LEN];
232
+ char buf[OBOE_MAX_METADATA_PACK_LEN];
185
233
 
186
234
  int rc = oboe_metadata_tostr(&this->metadata, buf, sizeof(buf) - 1);
187
235
  if (rc == 0) {
@@ -253,4 +301,46 @@ public:
253
301
  return oboe_reporter_send(this, md, evt) >= 0;
254
302
  }
255
303
  };
304
+
305
+
306
+ class Config {
307
+ public:
308
+ /**
309
+ * Check if the Oboe library is compatible with a given version.revision.
310
+ *
311
+ * This will succeed if the library is at least as recent as specified and if no
312
+ * definitions have been removed since that revision.
313
+ *
314
+ * @param version The library's version number which increments every time the API changes.
315
+ * @param revision The revision of the current version of the library.
316
+ * @return Non-zero if the Oboe library is considered compatible with the specified revision.
317
+ */
318
+ static bool checkVersion(int version, int revision) {
319
+ return (oboe_config_check_version(version, revision) != 0);
320
+ }
321
+
322
+ /**
323
+ * Get the Oboe library version number.
324
+ *
325
+ * This number increments whenever an incompatible change to the API/ABI is made.
326
+ *
327
+ * @return The library's version number or -1 if the version is not known.
328
+ */
329
+ static int getVersion() {
330
+ return oboe_config_get_version();
331
+ }
332
+
333
+ /**
334
+ * Get the Oboe library revision number.
335
+ *
336
+ * This number increments whenever a compatible change is made to the
337
+ * API/ABI (ie. an addition).
338
+ *
339
+ * @return The library's revision number or -1 if not known.
340
+ */
341
+ static int getRevision() {
342
+ return oboe_config_get_revision();
343
+ }
344
+ };
345
+
256
346
  #endif
@@ -1,6 +1,6 @@
1
1
  /* ----------------------------------------------------------------------------
2
2
  * This file was automatically generated by SWIG (http://www.swig.org).
3
- * Version 2.0.8
3
+ * Version 2.0.4
4
4
  *
5
5
  * This file is not intended to be easily readable and contains a number of
6
6
  * coding conventions designed to improve portability and efficiency. Do not make
@@ -1552,7 +1552,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
1552
1552
  downcast methods. */
1553
1553
  if (obj != Qnil) {
1554
1554
  VALUE value = rb_iv_get(obj, "@__swigtype__");
1555
- const char* type_name = RSTRING_PTR(value);
1555
+ char* type_name = RSTRING_PTR(value);
1556
1556
 
1557
1557
  if (strcmp(type->name, type_name) == 0) {
1558
1558
  return obj;
@@ -1813,15 +1813,16 @@ int SWIG_Ruby_arity( VALUE proc, int minimal )
1813
1813
 
1814
1814
  /* -------- TYPES TABLE (BEGIN) -------- */
1815
1815
 
1816
- #define SWIGTYPE_p_Context swig_types[0]
1817
- #define SWIGTYPE_p_Event swig_types[1]
1818
- #define SWIGTYPE_p_FileReporter swig_types[2]
1819
- #define SWIGTYPE_p_Metadata swig_types[3]
1820
- #define SWIGTYPE_p_UdpReporter swig_types[4]
1821
- #define SWIGTYPE_p_char swig_types[5]
1822
- #define SWIGTYPE_p_oboe_metadata_t swig_types[6]
1823
- static swig_type_info *swig_types[8];
1824
- static swig_module_info swig_module = {swig_types, 7, 0, 0, 0, 0};
1816
+ #define SWIGTYPE_p_Config swig_types[0]
1817
+ #define SWIGTYPE_p_Context swig_types[1]
1818
+ #define SWIGTYPE_p_Event swig_types[2]
1819
+ #define SWIGTYPE_p_FileReporter swig_types[3]
1820
+ #define SWIGTYPE_p_Metadata swig_types[4]
1821
+ #define SWIGTYPE_p_UdpReporter swig_types[5]
1822
+ #define SWIGTYPE_p_char swig_types[6]
1823
+ #define SWIGTYPE_p_oboe_metadata_t swig_types[7]
1824
+ static swig_type_info *swig_types[9];
1825
+ static swig_module_info swig_module = {swig_types, 8, 0, 0, 0, 0};
1825
1826
  #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
1826
1827
  #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
1827
1828
 
@@ -1836,7 +1837,7 @@ static VALUE mOboe_metal;
1836
1837
  #define SWIG_RUBY_THREAD_END_BLOCK
1837
1838
 
1838
1839
 
1839
- #define SWIGVERSION 0x020008
1840
+ #define SWIGVERSION 0x020004
1840
1841
  #define SWIG_VERSION SWIGVERSION
1841
1842
 
1842
1843
 
@@ -1966,7 +1967,14 @@ SWIG_From_std_string (const std::string& s)
1966
1967
  }
1967
1968
 
1968
1969
 
1969
-
1970
+ #include <limits.h>
1971
+ #if !defined(SWIG_NO_LLONG_MAX)
1972
+ # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
1973
+ # define LLONG_MAX __LONG_LONG_MAX__
1974
+ # define LLONG_MIN (-LLONG_MAX - 1LL)
1975
+ # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
1976
+ # endif
1977
+ #endif
1970
1978
 
1971
1979
 
1972
1980
  SWIGINTERN VALUE
@@ -1976,7 +1984,7 @@ SWIG_ruby_failed(void)
1976
1984
  }
1977
1985
 
1978
1986
 
1979
- /*@SWIG:/usr/local/share/swig/2.0.8/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
1987
+ /*@SWIG:/usr/share/swig2.0/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
1980
1988
  SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args)
1981
1989
  {
1982
1990
  VALUE obj = args[0];
@@ -2005,7 +2013,26 @@ SWIG_AsVal_long (VALUE obj, long* val)
2005
2013
  }
2006
2014
 
2007
2015
 
2008
- /*@SWIG:/usr/local/share/swig/2.0.8/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2016
+ SWIGINTERN int
2017
+ SWIG_AsVal_int (VALUE obj, int *val)
2018
+ {
2019
+ long v;
2020
+ int res = SWIG_AsVal_long (obj, &v);
2021
+ if (SWIG_IsOK(res)) {
2022
+ if ((v < INT_MIN || v > INT_MAX)) {
2023
+ return SWIG_OverflowError;
2024
+ } else {
2025
+ if (val) *val = static_cast< int >(v);
2026
+ }
2027
+ }
2028
+ return res;
2029
+ }
2030
+
2031
+
2032
+
2033
+
2034
+
2035
+ /*@SWIG:/usr/share/swig2.0/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
2009
2036
  SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE *args)
2010
2037
  {
2011
2038
  VALUE obj = args[0];
@@ -2033,7 +2060,17 @@ SWIG_AsVal_double (VALUE obj, double *val)
2033
2060
  return SWIG_TypeError;
2034
2061
  }
2035
2062
 
2036
- static swig_class SwigClassMetadata;
2063
+
2064
+ #define SWIG_From_long LONG2NUM
2065
+
2066
+
2067
+ SWIGINTERNINLINE VALUE
2068
+ SWIG_From_int (int value)
2069
+ {
2070
+ return SWIG_From_long (value);
2071
+ }
2072
+
2073
+ swig_class SwigClassMetadata;
2037
2074
 
2038
2075
  #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
2039
2076
  SWIGINTERN VALUE
@@ -2099,7 +2136,7 @@ _wrap_Metadata_fromString(int argc, VALUE *argv, VALUE self) {
2099
2136
  if (SWIG_IsNewObj(res)) delete ptr;
2100
2137
  }
2101
2138
  result = (Metadata *)Metadata::fromString(arg1);
2102
- vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Metadata, 0 | 0 );
2139
+ vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Metadata, SWIG_POINTER_OWN | 0 );
2103
2140
  return vresult;
2104
2141
  fail:
2105
2142
  return Qnil;
@@ -2218,7 +2255,95 @@ fail:
2218
2255
  }
2219
2256
 
2220
2257
 
2221
- static swig_class SwigClassContext;
2258
+ swig_class SwigClassContext;
2259
+
2260
+ SWIGINTERN VALUE
2261
+ _wrap_Context_setTracingMode(int argc, VALUE *argv, VALUE self) {
2262
+ int arg1 ;
2263
+ int val1 ;
2264
+ int ecode1 = 0 ;
2265
+
2266
+ if ((argc < 1) || (argc > 1)) {
2267
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2268
+ }
2269
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2270
+ if (!SWIG_IsOK(ecode1)) {
2271
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","Context::setTracingMode", 1, argv[0] ));
2272
+ }
2273
+ arg1 = static_cast< int >(val1);
2274
+ Context::setTracingMode(arg1);
2275
+ return Qnil;
2276
+ fail:
2277
+ return Qnil;
2278
+ }
2279
+
2280
+
2281
+ SWIGINTERN VALUE
2282
+ _wrap_Context_setDefaultSampleRate(int argc, VALUE *argv, VALUE self) {
2283
+ int arg1 ;
2284
+ int val1 ;
2285
+ int ecode1 = 0 ;
2286
+
2287
+ if ((argc < 1) || (argc > 1)) {
2288
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2289
+ }
2290
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2291
+ if (!SWIG_IsOK(ecode1)) {
2292
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","Context::setDefaultSampleRate", 1, argv[0] ));
2293
+ }
2294
+ arg1 = static_cast< int >(val1);
2295
+ Context::setDefaultSampleRate(arg1);
2296
+ return Qnil;
2297
+ fail:
2298
+ return Qnil;
2299
+ }
2300
+
2301
+
2302
+ SWIGINTERN VALUE
2303
+ _wrap_Context_sampleRequest(int argc, VALUE *argv, VALUE self) {
2304
+ std::string arg1 ;
2305
+ std::string arg2 ;
2306
+ std::string arg3 ;
2307
+ bool result;
2308
+ VALUE vresult = Qnil;
2309
+
2310
+ if ((argc < 3) || (argc > 3)) {
2311
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail;
2312
+ }
2313
+ {
2314
+ std::string *ptr = (std::string *)0;
2315
+ int res = SWIG_AsPtr_std_string(argv[0], &ptr);
2316
+ if (!SWIG_IsOK(res) || !ptr) {
2317
+ SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), Ruby_Format_TypeError( "", "std::string","Context::sampleRequest", 1, argv[0] ));
2318
+ }
2319
+ arg1 = *ptr;
2320
+ if (SWIG_IsNewObj(res)) delete ptr;
2321
+ }
2322
+ {
2323
+ std::string *ptr = (std::string *)0;
2324
+ int res = SWIG_AsPtr_std_string(argv[1], &ptr);
2325
+ if (!SWIG_IsOK(res) || !ptr) {
2326
+ SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), Ruby_Format_TypeError( "", "std::string","Context::sampleRequest", 2, argv[1] ));
2327
+ }
2328
+ arg2 = *ptr;
2329
+ if (SWIG_IsNewObj(res)) delete ptr;
2330
+ }
2331
+ {
2332
+ std::string *ptr = (std::string *)0;
2333
+ int res = SWIG_AsPtr_std_string(argv[2], &ptr);
2334
+ if (!SWIG_IsOK(res) || !ptr) {
2335
+ SWIG_exception_fail(SWIG_ArgError((ptr ? res : SWIG_TypeError)), Ruby_Format_TypeError( "", "std::string","Context::sampleRequest", 3, argv[2] ));
2336
+ }
2337
+ arg3 = *ptr;
2338
+ if (SWIG_IsNewObj(res)) delete ptr;
2339
+ }
2340
+ result = (bool)Context::sampleRequest(arg1,arg2,arg3);
2341
+ vresult = SWIG_From_bool(static_cast< bool >(result));
2342
+ return vresult;
2343
+ fail:
2344
+ return Qnil;
2345
+ }
2346
+
2222
2347
 
2223
2348
  SWIGINTERN VALUE
2224
2349
  _wrap_Context_get(int argc, VALUE *argv, VALUE self) {
@@ -2421,7 +2546,7 @@ free_Context(Context *arg1) {
2421
2546
  delete arg1;
2422
2547
  }
2423
2548
 
2424
- static swig_class SwigClassEvent;
2549
+ swig_class SwigClassEvent;
2425
2550
 
2426
2551
  SWIGINTERN void
2427
2552
  free_Event(Event *arg1) {
@@ -2733,6 +2858,45 @@ fail:
2733
2858
  }
2734
2859
 
2735
2860
 
2861
+ SWIGINTERN VALUE
2862
+ _wrap_Event_addEdgeStr(int argc, VALUE *argv, VALUE self) {
2863
+ Event *arg1 = (Event *) 0 ;
2864
+ std::string *arg2 = 0 ;
2865
+ void *argp1 = 0 ;
2866
+ int res1 = 0 ;
2867
+ int res2 = SWIG_OLDOBJ ;
2868
+ bool result;
2869
+ VALUE vresult = Qnil;
2870
+
2871
+ if ((argc < 1) || (argc > 1)) {
2872
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2873
+ }
2874
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Event, 0 | 0 );
2875
+ if (!SWIG_IsOK(res1)) {
2876
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "Event *","addEdgeStr", 1, self ));
2877
+ }
2878
+ arg1 = reinterpret_cast< Event * >(argp1);
2879
+ {
2880
+ std::string *ptr = (std::string *)0;
2881
+ res2 = SWIG_AsPtr_std_string(argv[0], &ptr);
2882
+ if (!SWIG_IsOK(res2)) {
2883
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "std::string const &","addEdgeStr", 2, argv[0] ));
2884
+ }
2885
+ if (!ptr) {
2886
+ SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::string const &","addEdgeStr", 2, argv[0]));
2887
+ }
2888
+ arg2 = ptr;
2889
+ }
2890
+ result = (bool)(arg1)->addEdgeStr((std::string const &)*arg2);
2891
+ vresult = SWIG_From_bool(static_cast< bool >(result));
2892
+ if (SWIG_IsNewObj(res2)) delete arg2;
2893
+ return vresult;
2894
+ fail:
2895
+ if (SWIG_IsNewObj(res2)) delete arg2;
2896
+ return Qnil;
2897
+ }
2898
+
2899
+
2736
2900
  SWIGINTERN VALUE
2737
2901
  _wrap_Event_getMetadata(int argc, VALUE *argv, VALUE self) {
2738
2902
  Event *arg1 = (Event *) 0 ;
@@ -2798,14 +2962,14 @@ _wrap_Event_startTrace(int argc, VALUE *argv, VALUE self) {
2798
2962
  }
2799
2963
  arg1 = reinterpret_cast< oboe_metadata_t * >(argp1);
2800
2964
  result = (Event *)Event::startTrace((oboe_metadata_t const *)arg1);
2801
- vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, 0 | 0 );
2965
+ vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_OWN | 0 );
2802
2966
  return vresult;
2803
2967
  fail:
2804
2968
  return Qnil;
2805
2969
  }
2806
2970
 
2807
2971
 
2808
- static swig_class SwigClassUdpReporter;
2972
+ swig_class SwigClassUdpReporter;
2809
2973
 
2810
2974
  SWIGINTERN VALUE
2811
2975
  _wrap_new_UdpReporter__SWIG_0(int argc, VALUE *argv, VALUE self) {
@@ -3058,7 +3222,7 @@ fail:
3058
3222
  }
3059
3223
 
3060
3224
 
3061
- static swig_class SwigClassFileReporter;
3225
+ swig_class SwigClassFileReporter;
3062
3226
 
3063
3227
  #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
3064
3228
  SWIGINTERN VALUE
@@ -3234,12 +3398,116 @@ fail:
3234
3398
  }
3235
3399
 
3236
3400
 
3401
+ swig_class SwigClassConfig;
3402
+
3403
+ SWIGINTERN VALUE
3404
+ _wrap_Config_checkVersion(int argc, VALUE *argv, VALUE self) {
3405
+ int arg1 ;
3406
+ int arg2 ;
3407
+ int val1 ;
3408
+ int ecode1 = 0 ;
3409
+ int val2 ;
3410
+ int ecode2 = 0 ;
3411
+ bool result;
3412
+ VALUE vresult = Qnil;
3413
+
3414
+ if ((argc < 2) || (argc > 2)) {
3415
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
3416
+ }
3417
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
3418
+ if (!SWIG_IsOK(ecode1)) {
3419
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","Config::checkVersion", 1, argv[0] ));
3420
+ }
3421
+ arg1 = static_cast< int >(val1);
3422
+ ecode2 = SWIG_AsVal_int(argv[1], &val2);
3423
+ if (!SWIG_IsOK(ecode2)) {
3424
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","Config::checkVersion", 2, argv[1] ));
3425
+ }
3426
+ arg2 = static_cast< int >(val2);
3427
+ result = (bool)Config::checkVersion(arg1,arg2);
3428
+ vresult = SWIG_From_bool(static_cast< bool >(result));
3429
+ return vresult;
3430
+ fail:
3431
+ return Qnil;
3432
+ }
3433
+
3434
+
3435
+ SWIGINTERN VALUE
3436
+ _wrap_Config_getVersion(int argc, VALUE *argv, VALUE self) {
3437
+ int result;
3438
+ VALUE vresult = Qnil;
3439
+
3440
+ if ((argc < 0) || (argc > 0)) {
3441
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
3442
+ }
3443
+ result = (int)Config::getVersion();
3444
+ vresult = SWIG_From_int(static_cast< int >(result));
3445
+ return vresult;
3446
+ fail:
3447
+ return Qnil;
3448
+ }
3449
+
3450
+
3451
+ SWIGINTERN VALUE
3452
+ _wrap_Config_getRevision(int argc, VALUE *argv, VALUE self) {
3453
+ int result;
3454
+ VALUE vresult = Qnil;
3455
+
3456
+ if ((argc < 0) || (argc > 0)) {
3457
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
3458
+ }
3459
+ result = (int)Config::getRevision();
3460
+ vresult = SWIG_From_int(static_cast< int >(result));
3461
+ return vresult;
3462
+ fail:
3463
+ return Qnil;
3464
+ }
3465
+
3466
+
3467
+ #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
3468
+ SWIGINTERN VALUE
3469
+ _wrap_Config_allocate(VALUE self) {
3470
+ #else
3471
+ SWIGINTERN VALUE
3472
+ _wrap_Config_allocate(int argc, VALUE *argv, VALUE self) {
3473
+ #endif
3474
+
3475
+
3476
+ VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_Config);
3477
+ #ifndef HAVE_RB_DEFINE_ALLOC_FUNC
3478
+ rb_obj_call_init(vresult, argc, argv);
3479
+ #endif
3480
+ return vresult;
3481
+ }
3482
+
3483
+
3484
+ SWIGINTERN VALUE
3485
+ _wrap_new_Config(int argc, VALUE *argv, VALUE self) {
3486
+ Config *result = 0 ;
3487
+
3488
+ if ((argc < 0) || (argc > 0)) {
3489
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
3490
+ }
3491
+ result = (Config *)new Config();
3492
+ DATA_PTR(self) = result;
3493
+ return self;
3494
+ fail:
3495
+ return Qnil;
3496
+ }
3497
+
3498
+
3499
+ SWIGINTERN void
3500
+ free_Config(Config *arg1) {
3501
+ delete arg1;
3502
+ }
3503
+
3237
3504
 
3238
3505
  /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
3239
3506
 
3240
3507
  static void *_p_MetadataTo_p_oboe_metadata_t(void *x, int *SWIGUNUSEDPARM(newmemory)) {
3241
3508
  return (void *)((oboe_metadata_t *) ((Metadata *) x));
3242
3509
  }
3510
+ static swig_type_info _swigt__p_Config = {"_p_Config", "Config *", 0, 0, (void*)0, 0};
3243
3511
  static swig_type_info _swigt__p_Context = {"_p_Context", "Context *", 0, 0, (void*)0, 0};
3244
3512
  static swig_type_info _swigt__p_Event = {"_p_Event", "Event *", 0, 0, (void*)0, 0};
3245
3513
  static swig_type_info _swigt__p_FileReporter = {"_p_FileReporter", "FileReporter *", 0, 0, (void*)0, 0};
@@ -3249,6 +3517,7 @@ static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
3249
3517
  static swig_type_info _swigt__p_oboe_metadata_t = {"_p_oboe_metadata_t", "oboe_metadata_t *", 0, 0, (void*)0, 0};
3250
3518
 
3251
3519
  static swig_type_info *swig_type_initial[] = {
3520
+ &_swigt__p_Config,
3252
3521
  &_swigt__p_Context,
3253
3522
  &_swigt__p_Event,
3254
3523
  &_swigt__p_FileReporter,
@@ -3258,6 +3527,7 @@ static swig_type_info *swig_type_initial[] = {
3258
3527
  &_swigt__p_oboe_metadata_t,
3259
3528
  };
3260
3529
 
3530
+ static swig_cast_info _swigc__p_Config[] = { {&_swigt__p_Config, 0, 0, 0},{0, 0, 0, 0}};
3261
3531
  static swig_cast_info _swigc__p_Context[] = { {&_swigt__p_Context, 0, 0, 0},{0, 0, 0, 0}};
3262
3532
  static swig_cast_info _swigc__p_Event[] = { {&_swigt__p_Event, 0, 0, 0},{0, 0, 0, 0}};
3263
3533
  static swig_cast_info _swigc__p_FileReporter[] = { {&_swigt__p_FileReporter, 0, 0, 0},{0, 0, 0, 0}};
@@ -3267,6 +3537,7 @@ static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0,
3267
3537
  static swig_cast_info _swigc__p_oboe_metadata_t[] = { {&_swigt__p_Metadata, _p_MetadataTo_p_oboe_metadata_t, 0, 0}, {&_swigt__p_oboe_metadata_t, 0, 0, 0},{0, 0, 0, 0}};
3268
3538
 
3269
3539
  static swig_cast_info *swig_cast_initial[] = {
3540
+ _swigc__p_Config,
3270
3541
  _swigc__p_Context,
3271
3542
  _swigc__p_Event,
3272
3543
  _swigc__p_FileReporter,
@@ -3337,7 +3608,8 @@ SWIG_InitializeModule(void *clientdata) {
3337
3608
  size_t i;
3338
3609
  swig_module_info *module_head, *iter;
3339
3610
  int found, init;
3340
- (void *)clientdata;
3611
+
3612
+ clientdata = clientdata;
3341
3613
 
3342
3614
  /* check to see if the circular list has been setup, if not, set it up */
3343
3615
  if (swig_module.next==0) {
@@ -3552,6 +3824,9 @@ SWIGEXPORT void Init_oboe_metal(void) {
3552
3824
  SWIG_TypeClientData(SWIGTYPE_p_Context, (void *) &SwigClassContext);
3553
3825
  rb_define_alloc_func(SwigClassContext.klass, _wrap_Context_allocate);
3554
3826
  rb_define_method(SwigClassContext.klass, "initialize", VALUEFUNC(_wrap_new_Context), -1);
3827
+ rb_define_singleton_method(SwigClassContext.klass, "setTracingMode", VALUEFUNC(_wrap_Context_setTracingMode), -1);
3828
+ rb_define_singleton_method(SwigClassContext.klass, "setDefaultSampleRate", VALUEFUNC(_wrap_Context_setDefaultSampleRate), -1);
3829
+ rb_define_singleton_method(SwigClassContext.klass, "sampleRequest", VALUEFUNC(_wrap_Context_sampleRequest), -1);
3555
3830
  rb_define_singleton_method(SwigClassContext.klass, "get", VALUEFUNC(_wrap_Context_get), -1);
3556
3831
  rb_define_singleton_method(SwigClassContext.klass, "toString", VALUEFUNC(_wrap_Context_toString), -1);
3557
3832
  rb_define_singleton_method(SwigClassContext.klass, "set", VALUEFUNC(_wrap_Context_set), -1);
@@ -3571,6 +3846,7 @@ SWIGEXPORT void Init_oboe_metal(void) {
3571
3846
  rb_undef_alloc_func(SwigClassEvent.klass);
3572
3847
  rb_define_method(SwigClassEvent.klass, "addInfo", VALUEFUNC(_wrap_Event_addInfo), -1);
3573
3848
  rb_define_method(SwigClassEvent.klass, "addEdge", VALUEFUNC(_wrap_Event_addEdge), -1);
3849
+ rb_define_method(SwigClassEvent.klass, "addEdgeStr", VALUEFUNC(_wrap_Event_addEdgeStr), -1);
3574
3850
  rb_define_method(SwigClassEvent.klass, "getMetadata", VALUEFUNC(_wrap_Event_getMetadata), -1);
3575
3851
  rb_define_method(SwigClassEvent.klass, "metadataString", VALUEFUNC(_wrap_Event_metadataString), -1);
3576
3852
  rb_define_singleton_method(SwigClassEvent.klass, "startTrace", VALUEFUNC(_wrap_Event_startTrace), -1);
@@ -3595,5 +3871,16 @@ SWIGEXPORT void Init_oboe_metal(void) {
3595
3871
  SwigClassFileReporter.mark = 0;
3596
3872
  SwigClassFileReporter.destroy = (void (*)(void *)) free_FileReporter;
3597
3873
  SwigClassFileReporter.trackObjects = 0;
3874
+
3875
+ SwigClassConfig.klass = rb_define_class_under(mOboe_metal, "Config", rb_cObject);
3876
+ SWIG_TypeClientData(SWIGTYPE_p_Config, (void *) &SwigClassConfig);
3877
+ rb_define_alloc_func(SwigClassConfig.klass, _wrap_Config_allocate);
3878
+ rb_define_method(SwigClassConfig.klass, "initialize", VALUEFUNC(_wrap_new_Config), -1);
3879
+ rb_define_singleton_method(SwigClassConfig.klass, "checkVersion", VALUEFUNC(_wrap_Config_checkVersion), -1);
3880
+ rb_define_singleton_method(SwigClassConfig.klass, "getVersion", VALUEFUNC(_wrap_Config_getVersion), -1);
3881
+ rb_define_singleton_method(SwigClassConfig.klass, "getRevision", VALUEFUNC(_wrap_Config_getRevision), -1);
3882
+ SwigClassConfig.mark = 0;
3883
+ SwigClassConfig.destroy = (void (*)(void *)) free_Config;
3884
+ SwigClassConfig.trackObjects = 0;
3598
3885
  }
3599
3886