appoptics_apm 4.8.1 → 4.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/.travis.yml +50 -28
- data/CONFIG.md +1 -1
- data/Gemfile +6 -6
- data/README.md +1 -1
- data/appoptics_apm.gemspec +4 -1
- data/examples/SDK/01_basic_tracing.rb +0 -2
- data/ext/oboe_metal/README.md +69 -0
- data/ext/oboe_metal/noop/noop.c +2 -1
- data/ext/oboe_metal/src/VERSION +1 -1
- data/ext/oboe_metal/src/bson/bson.h +105 -105
- data/ext/oboe_metal/src/bson/platform_hacks.h +10 -10
- data/ext/oboe_metal/src/oboe.h +104 -73
- data/ext/oboe_metal/src/oboe.hpp +103 -61
- data/ext/oboe_metal/src/oboe_wrap.cxx +1470 -314
- data/lib/appoptics_apm.rb +1 -3
- data/lib/appoptics_apm/api.rb +0 -1
- data/lib/appoptics_apm/api/tracing.rb +4 -0
- data/lib/appoptics_apm/config.rb +16 -5
- data/lib/appoptics_apm/frameworks/padrino.rb +6 -36
- data/lib/appoptics_apm/frameworks/rails.rb +0 -1
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller.rb +5 -5
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller6.rb +50 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_view.rb +11 -24
- data/lib/appoptics_apm/frameworks/rails/inst/active_record.rb +3 -3
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils.rb +1 -1
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +1 -1
- data/lib/appoptics_apm/frameworks/sinatra.rb +3 -32
- data/lib/appoptics_apm/inst/curb.rb +6 -6
- data/lib/appoptics_apm/inst/faraday.rb +16 -4
- data/lib/appoptics_apm/inst/logger_formatter.rb +4 -3
- data/lib/appoptics_apm/inst/rack.rb +11 -11
- data/lib/appoptics_apm/oboe_init_options.rb +17 -4
- data/lib/appoptics_apm/sdk/tracing.rb +118 -0
- data/lib/appoptics_apm/support/transaction_metrics.rb +1 -0
- data/lib/appoptics_apm/support/transaction_settings.rb +40 -15
- data/lib/appoptics_apm/support/x_trace_options.rb +110 -0
- data/lib/appoptics_apm/version.rb +2 -2
- data/lib/appoptics_apm/xtrace.rb +7 -7
- data/lib/rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb +37 -12
- metadata +7 -15
- data/Rakefile +0 -229
- data/build_gem.sh +0 -15
- data/build_gem_upload_to_packagecloud.sh +0 -20
- data/lib/appoptics_apm/api/profiling.rb +0 -203
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller3.rb +0 -55
- data/lib/appoptics_apm/frameworks/rails/inst/action_view_30.rb +0 -50
- data/lib/appoptics_apm/legacy_method_profiling.rb +0 -90
- data/lib/appoptics_apm/method_profiling.rb +0 -33
- data/lib/oboe/README +0 -2
- data/lib/oboe/backward_compatibility.rb +0 -80
- data/lib/oboe/inst/rack.rb +0 -11
@@ -49,20 +49,20 @@ typedef long long int int64_t;
|
|
49
49
|
|
50
50
|
/* big endian is only used for OID generation. little is used everywhere else */
|
51
51
|
#ifdef MONGO_BIG_ENDIAN
|
52
|
-
#define
|
53
|
-
#define
|
54
|
-
#define
|
55
|
-
#define
|
52
|
+
#define oboe_bson_little_endian64(out, in) ( oboe_bson_swap_endian64(out, in) )
|
53
|
+
#define oboe_bson_little_endian32(out, in) ( oboe_bson_swap_endian32(out, in) )
|
54
|
+
#define oboe_bson_big_endian64(out, in) ( memmove(out, in, 8) )
|
55
|
+
#define oboe_bson_big_endian32(out, in) ( memmove(out, in, 4) )
|
56
56
|
#else
|
57
|
-
#define
|
58
|
-
#define
|
59
|
-
#define
|
60
|
-
#define
|
57
|
+
#define oboe_bson_little_endian64(out, in) ( memmove(out, in, 8) )
|
58
|
+
#define oboe_bson_little_endian32(out, in) ( memmove(out, in, 4) )
|
59
|
+
#define oboe_bson_big_endian64(out, in) ( oboe_bson_swap_endian64(out, in) )
|
60
|
+
#define oboe_bson_big_endian32(out, in) ( oboe_bson_swap_endian32(out, in) )
|
61
61
|
#endif
|
62
62
|
|
63
63
|
MONGO_EXTERN_C_START
|
64
64
|
|
65
|
-
MONGO_INLINE void
|
65
|
+
MONGO_INLINE void oboe_bson_swap_endian64(void* outp, const void* inp){
|
66
66
|
const char *in = (const char*)inp;
|
67
67
|
char *out = (char*)outp;
|
68
68
|
|
@@ -76,7 +76,7 @@ MONGO_INLINE void bson_swap_endian64(void* outp, const void* inp){
|
|
76
76
|
out[7] = in[0];
|
77
77
|
|
78
78
|
}
|
79
|
-
MONGO_INLINE void
|
79
|
+
MONGO_INLINE void oboe_bson_swap_endian32(void* outp, const void* inp){
|
80
80
|
const char *in = (const char*)inp;
|
81
81
|
char *out = (char*)outp;
|
82
82
|
|
data/ext/oboe_metal/src/oboe.h
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
/**
|
2
2
|
* @file oboe.h
|
3
|
-
*
|
3
|
+
*
|
4
4
|
* API header for AppOptics' Oboe application tracing library for use with AppOptics.
|
5
5
|
*
|
6
6
|
* @package Oboe
|
7
7
|
* @author AppOptics
|
8
8
|
* @copyright Copyright (c) 2016, SolarWinds LLC
|
9
|
-
* @license
|
9
|
+
* @license
|
10
10
|
* @link https://appoptics.com
|
11
11
|
**/
|
12
12
|
|
@@ -81,6 +81,10 @@ extern "C" {
|
|
81
81
|
* Default events flush batch size in KB.
|
82
82
|
*/
|
83
83
|
#define OBOE_DEFAULT_EVENTS_FLUSH_BATCH_SIZE 2000
|
84
|
+
/**
|
85
|
+
* Default EC2 metadata timeout in milliseconds
|
86
|
+
*/
|
87
|
+
#define OBOE_DEFAULT_EC2_METADATA_TIMEOUT 1000
|
84
88
|
|
85
89
|
#define OBOE_SAMPLE_RESOLUTION 1000000
|
86
90
|
|
@@ -133,7 +137,7 @@ typedef struct oboe_metadata {
|
|
133
137
|
|
134
138
|
typedef struct oboe_event {
|
135
139
|
oboe_metadata_t metadata;
|
136
|
-
|
140
|
+
oboe_bson_buffer bbuf;
|
137
141
|
char * bb_str;
|
138
142
|
#ifdef _FUTURE_PLANS_
|
139
143
|
/* Can't add this without breaking the ABI, but someday... */
|
@@ -167,6 +171,8 @@ typedef struct oboe_init_options {
|
|
167
171
|
int token_bucket_capacity; // custom token bucket capacity
|
168
172
|
int token_bucket_rate; // custom token bucket rate
|
169
173
|
int file_single; // use single files in file reporter for each event
|
174
|
+
|
175
|
+
int ec2_metadata_timeout; // EC2 metadata timeout in milliseconds
|
170
176
|
} oboe_init_options_t;
|
171
177
|
|
172
178
|
typedef struct oboe_span_params {
|
@@ -183,12 +189,22 @@ typedef struct oboe_span_params {
|
|
183
189
|
int do_metrics; // boolean flag whether a (HTTP) span should be sent (1) or not (0)
|
184
190
|
} oboe_span_params_t;
|
185
191
|
|
192
|
+
//
|
193
|
+
// oboe_get_tracing_decisions input and output structures
|
194
|
+
//
|
186
195
|
typedef struct oboe_tracing_decisions_in {
|
187
|
-
int version;
|
188
|
-
const char *service_name;
|
189
|
-
const char *in_xtrace;
|
190
|
-
int custom_sample_rate;
|
191
|
-
int custom_tracing_mode;
|
196
|
+
int version; // the version of this structure
|
197
|
+
const char *service_name; // custom service name
|
198
|
+
const char *in_xtrace; // existing X-Trace from passed in HTTP header
|
199
|
+
int custom_sample_rate; // custom sample rate
|
200
|
+
int custom_tracing_mode; // custom tracing mode
|
201
|
+
|
202
|
+
// v2
|
203
|
+
int custom_trigger_mode; // custom trigger mode
|
204
|
+
int request_type; // the request type: OBOE_REQUEST_TYPE_REGULAR, OBOE_REQUEST_TYPE_TRIGGER
|
205
|
+
const char *header_options; // X-Trace-Options HTTP header value
|
206
|
+
const char *header_signature; // X-Trace-Options-Signature HTTP header value
|
207
|
+
time_t header_timestamp; // timestamp from X-Trace-Options header, converted to UNIX timestamp format
|
192
208
|
} oboe_tracing_decisions_in_t;
|
193
209
|
|
194
210
|
typedef struct oboe_tracing_decisions_out {
|
@@ -197,6 +213,12 @@ typedef struct oboe_tracing_decisions_out {
|
|
197
213
|
int sample_source;
|
198
214
|
int do_sample;
|
199
215
|
int do_metrics;
|
216
|
+
|
217
|
+
// v2
|
218
|
+
int request_provisioned;
|
219
|
+
int auth_status;
|
220
|
+
const char *auth_message;
|
221
|
+
const char *status_message;
|
200
222
|
} oboe_tracing_decisions_out_t;
|
201
223
|
|
202
224
|
typedef struct oboe_internal_stats {
|
@@ -253,7 +275,7 @@ int oboe_event_add_info_binary (oboe_event_t *, const char *, const char *, size
|
|
253
275
|
int oboe_event_add_info_int64 (oboe_event_t *, const char *, const int64_t);
|
254
276
|
int oboe_event_add_info_double (oboe_event_t *, const char *, const double);
|
255
277
|
int oboe_event_add_info_bool (oboe_event_t *, const char *, const int);
|
256
|
-
int oboe_event_add_info_bson (oboe_event_t *, const char *key, const
|
278
|
+
int oboe_event_add_info_bson (oboe_event_t *, const char *key, const oboe_bson *val);
|
257
279
|
int oboe_event_add_edge (oboe_event_t *, const oboe_metadata_t *);
|
258
280
|
int oboe_event_add_edge_fromstr(oboe_event_t *, const char *, size_t);
|
259
281
|
|
@@ -357,7 +379,7 @@ int oboe_init(oboe_init_options_t* options);
|
|
357
379
|
* Initialize the Oboe subsytems using a specific reporter configuration.
|
358
380
|
*
|
359
381
|
* This should be called before any other oboe_* functions butm may also be
|
360
|
-
* used to change or re-initialize the current reporter. To reconnect the
|
382
|
+
* used to change or re-initialize the current reporter. To reconnect the
|
361
383
|
* reporter use oboe_disconnect() and oboe_reconnect() instead.
|
362
384
|
*
|
363
385
|
* @param protocol One of OBOE_REPORTER_PROTOCOL_FILE, OBOE_REPORTER_PROTOCOL_UDP,
|
@@ -367,7 +389,12 @@ int oboe_init(oboe_init_options_t* options);
|
|
367
389
|
*/
|
368
390
|
int oboe_init_reporter(const char *protocol, oboe_init_options_t *options);
|
369
391
|
|
370
|
-
|
392
|
+
/**
|
393
|
+
* returns one of these:
|
394
|
+
* - OBOE_INIT_OPTIONS_SET_DEFAULTS_OK
|
395
|
+
* - OBOE_INIT_OPTIONS_SET_DEFAULTS_WRONG_VERSION
|
396
|
+
*/
|
397
|
+
int oboe_init_options_set_defaults(oboe_init_options_t *options);
|
371
398
|
|
372
399
|
/**
|
373
400
|
* Disconnect or shut down the Oboe reporter, but allow it to be reconnect()ed.
|
@@ -429,6 +456,7 @@ void oboe_shutdown();
|
|
429
456
|
#define OBOE_SETTINGS_FLAG_SAMPLE_START 0x4
|
430
457
|
#define OBOE_SETTINGS_FLAG_SAMPLE_THROUGH 0x8
|
431
458
|
#define OBOE_SETTINGS_FLAG_SAMPLE_THROUGH_ALWAYS 0x10
|
459
|
+
#define OBOE_SETTINGS_FLAG_TRIGGERED_TRACE 0x20
|
432
460
|
#define OBOE_SETTINGS_MAX_STRLEN 256
|
433
461
|
|
434
462
|
#define OBOE_SETTINGS_UNSET -1
|
@@ -455,9 +483,6 @@ void oboe_shutdown();
|
|
455
483
|
#pragma pack(push, 1)
|
456
484
|
#endif
|
457
485
|
|
458
|
-
#define TOKEN_BUCKET_CAPACITY_DEFAULT 16 // bucket capacity (how many tokens fit into the bucket)
|
459
|
-
#define TOKEN_BUCKET_RATE_PER_SECOND_DEFAULT 8 // rate per second (number of tokens per second)
|
460
|
-
|
461
486
|
#define OBOE_SEND_EVENT 0
|
462
487
|
#define OBOE_SEND_STATUS 1
|
463
488
|
#define OBOE_SEND_PROFILING 2
|
@@ -477,7 +502,17 @@ void oboe_shutdown();
|
|
477
502
|
#define OBOE_SPAN_NO_REPORTER -4
|
478
503
|
#define OBOE_SPAN_NOT_READY -5
|
479
504
|
|
480
|
-
// these codes are
|
505
|
+
// these codes are returned by oboe_sample_layer_custom(), oboe_tracing_decisions(),
|
506
|
+
// oboe_reporter_is_ready(), and referenced in settings_messages.c (to convert
|
507
|
+
// error codes to messages.)
|
508
|
+
//
|
509
|
+
// they are structured such that codes that are <= 0 are successful, i.e., no
|
510
|
+
// error status needs to be reported to the user, while codes > 0 are errors that
|
511
|
+
// need to be reported.
|
512
|
+
|
513
|
+
#define OBOE_TRACING_DECISIONS_FAILED_AUTH -5
|
514
|
+
#define OBOE_TRACING_DECISIONS_TRIGGERED_TRACE_EXHAUSTED -4
|
515
|
+
#define OBOE_TRACING_DECISIONS_TRIGGERED_TRACE_DISABLED -3
|
481
516
|
#define OBOE_TRACING_DECISIONS_TRACING_DISABLED -2
|
482
517
|
#define OBOE_TRACING_DECISIONS_XTRACE_NOT_SAMPLED -1
|
483
518
|
#define OBOE_TRACING_DECISIONS_OK 0
|
@@ -486,8 +521,31 @@ void oboe_shutdown();
|
|
486
521
|
#define OBOE_TRACING_DECISIONS_REPORTER_NOT_READY 3
|
487
522
|
#define OBOE_TRACING_DECISIONS_NO_VALID_SETTINGS 4
|
488
523
|
#define OBOE_TRACING_DECISIONS_QUEUE_FULL 5
|
524
|
+
#define OBOE_TRACING_DECISIONS_BAD_ARG 6
|
525
|
+
|
526
|
+
// convert above codes into const char* messages.
|
527
|
+
const char* oboe_get_tracing_decisions_message(int code);
|
528
|
+
|
529
|
+
#define OBOE_TRACING_DECISIONS_AUTH_NOT_CHECKED -2
|
530
|
+
#define OBOE_TRACING_DECISIONS_AUTH_NOT_PRESENT -1
|
531
|
+
#define OBOE_TRACING_DECISIONS_AUTH_OK 0
|
532
|
+
#define OBOE_TRACING_DECISIONS_AUTH_NO_SIG_KEY 1
|
533
|
+
#define OBOE_TRACING_DECISIONS_AUTH_INVALID_SIG 2
|
534
|
+
#define OBOE_TRACING_DECISIONS_AUTH_BAD_TIMESTAMP 3
|
489
535
|
|
490
|
-
//
|
536
|
+
// convert above codes into const char* messages.
|
537
|
+
const char* oboe_get_tracing_decisions_auth_message (int code);
|
538
|
+
|
539
|
+
#define OBOE_REQUEST_TYPE_NONE -1
|
540
|
+
#define OBOE_REQUEST_TYPE_REGULAR 0
|
541
|
+
#define OBOE_REQUEST_TYPE_TRIGGER 1
|
542
|
+
|
543
|
+
#define OBOE_INIT_OPTIONS_SET_DEFAULTS_OK 0
|
544
|
+
#define OBOE_INIT_OPTIONS_SET_DEFAULTS_WRONG_VERSION 1
|
545
|
+
|
546
|
+
//
|
547
|
+
// these codes are returned by oboe_init(), oboe_init_reporter(), _oboe_create_reporter()
|
548
|
+
//
|
491
549
|
#define OBOE_INIT_ALREADY_INIT -1
|
492
550
|
#define OBOE_INIT_OK 0
|
493
551
|
#define OBOE_INIT_WRONG_VERSION 1
|
@@ -501,6 +559,17 @@ void oboe_shutdown();
|
|
501
559
|
#define OBOE_INIT_SSL_LOAD_CERT 9
|
502
560
|
#define OBOE_INIT_SSL_REPORTER_CREATE 10
|
503
561
|
|
562
|
+
// token buckets
|
563
|
+
enum TOKEN_BUCKETS {
|
564
|
+
TOKEN_BUCKET_SAMPLING, // for normal requests
|
565
|
+
TOKEN_BUCKET_TT_RELAXED, // for triggered traces initiated by Pingdom and
|
566
|
+
// other trusted sources (relaxed settings)
|
567
|
+
TOKEN_BUCKET_TT_STRICT, // for triggered traces initiated by CLI and
|
568
|
+
// other untrusted sources (strict settings)
|
569
|
+
TOKEN_BUCKET_COUNT // IMPORTANT NOTE: this must be the last element
|
570
|
+
// inside the enum
|
571
|
+
};
|
572
|
+
|
504
573
|
typedef struct {
|
505
574
|
uint32_t magic;
|
506
575
|
uint32_t timestamp;
|
@@ -510,8 +579,9 @@ typedef struct {
|
|
510
579
|
uint32_t ttl;
|
511
580
|
uint32_t _pad;
|
512
581
|
char layer[OBOE_SETTINGS_MAX_STRLEN]; // Flawfinder: ignore
|
513
|
-
double bucket_capacity;
|
514
|
-
double bucket_rate_per_sec;
|
582
|
+
double bucket_capacity[TOKEN_BUCKET_COUNT];
|
583
|
+
double bucket_rate_per_sec[TOKEN_BUCKET_COUNT];
|
584
|
+
char signature_key[OBOE_SETTINGS_MAX_STRLEN]; // Flawfinder: ignore
|
515
585
|
} oboe_settings_t;
|
516
586
|
|
517
587
|
typedef struct {
|
@@ -531,6 +601,7 @@ typedef struct {
|
|
531
601
|
volatile uint32_t through_count; // # of through traces
|
532
602
|
volatile uint32_t through_ignored_count; // # of new requests, that are rejected due to start_always_flag == 0
|
533
603
|
// that have through_always_flag == 1
|
604
|
+
volatile uint32_t triggered_count; // # of triggered traces
|
534
605
|
volatile uint32_t last_used_sample_rate;
|
535
606
|
volatile uint32_t last_used_sample_source;
|
536
607
|
|
@@ -541,12 +612,13 @@ typedef struct {
|
|
541
612
|
typedef struct {
|
542
613
|
int tracing_mode; // pushed from server, override from config file
|
543
614
|
int sample_rate; // pushed from server, override from config file
|
615
|
+
int trigger_mode; // pushed from server, override from config file
|
544
616
|
oboe_settings_t *settings; // cached settings, updated by tracelyzer (init to NULL)
|
545
|
-
int last_auto_sample_rate; // stores last known automatic sampling rate
|
546
|
-
uint16_t last_auto_flags; // stores last known flags associated with above
|
617
|
+
int last_auto_sample_rate; // stores last known automatic sampling rate
|
618
|
+
uint16_t last_auto_flags; // stores last known flags associated with above
|
547
619
|
uint32_t last_auto_timestamp; // timestamp from last *settings lookup
|
548
620
|
uint32_t last_refresh; // last refresh time
|
549
|
-
token_bucket_t bucket;
|
621
|
+
token_bucket_t bucket[TOKEN_BUCKET_COUNT]; // token buckets for various tasks
|
550
622
|
} oboe_settings_cfg_t;
|
551
623
|
|
552
624
|
int oboe_settings_init_local();
|
@@ -560,9 +632,10 @@ entry_layer_t* oboe_settings_entry_layer_get(const char* name);
|
|
560
632
|
oboe_settings_cfg_t* oboe_settings_cfg_get();
|
561
633
|
void oboe_settings_cfg_init(oboe_settings_cfg_t *cfg);
|
562
634
|
|
563
|
-
void oboe_settings_set(int sample_rate, int tracing_mode);
|
635
|
+
void oboe_settings_set(int sample_rate, int tracing_mode, int trigger_mode);
|
564
636
|
void oboe_settings_rate_set(int sample_rate);
|
565
637
|
void oboe_settings_mode_set(int tracing_mode);
|
638
|
+
void oboe_settings_trigger_set(int trigger_mode);
|
566
639
|
|
567
640
|
int oboe_rand_get_value();
|
568
641
|
|
@@ -588,49 +661,7 @@ int oboe_sample_is_enabled(oboe_settings_cfg_t *cfg);
|
|
588
661
|
* headers, and, if appropriate, rolls the virtual dice to
|
589
662
|
* decide if this request should be sampled.
|
590
663
|
*
|
591
|
-
* This is designed to be called once per
|
592
|
-
*
|
593
|
-
* @param service_name Service name used for this request (may be NULL to use default settings)
|
594
|
-
* @param xtrace X-Trace ID string from an HTTP request or higher layer (NULL or empty string if not present).
|
595
|
-
* @param sample_rate_out The sample rate used to check if this request should be sampled
|
596
|
-
* (output - may be zero if not used).
|
597
|
-
* @param sample_source_out The OBOE_SAMPLE_RATE_SOURCE used to check if this request
|
598
|
-
* should be sampled (output - may be zero if not used).
|
599
|
-
* @return Non-zero if the given request should be sampled.
|
600
|
-
*/
|
601
|
-
int oboe_sample_layer(
|
602
|
-
const char *service_name,
|
603
|
-
const char *xtrace,
|
604
|
-
int *sample_rate_out,
|
605
|
-
int *sample_source_out
|
606
|
-
);
|
607
|
-
|
608
|
-
/**
|
609
|
-
* Same as oboe_sample_layer() but accepting custom sample rate and custom tracing mode
|
610
|
-
*
|
611
|
-
* @param service_name Service name used for this request (may be NULL to use default settings)
|
612
|
-
* @param xtrace X-Trace ID string from an HTTP request or higher layer (NULL or empty string if not present).
|
613
|
-
* @param custom_sample_rate a custom sample rate only used for this request (OBOE_SETTINGS_UNSET won't override)
|
614
|
-
* @param custom_tracing_mode a custom tracing mode only used for this request (OBOE_SETTINGS_UNSET won't override)
|
615
|
-
* @param sample_rate_out The sample rate used to check if this request should be sampled
|
616
|
-
* (output - may be zero if not used).
|
617
|
-
* @param sample_source_out The OBOE_SAMPLE_RATE_SOURCE used to check if this request
|
618
|
-
* should be sampled (output - may be zero if not used).
|
619
|
-
* @param flags_out The flags used to check if this request should be sampled
|
620
|
-
*/
|
621
|
-
int oboe_sample_layer_custom(
|
622
|
-
const char *service_name,
|
623
|
-
const char *in_xtrace,
|
624
|
-
int custom_sample_rate,
|
625
|
-
int custom_tracing_mode,
|
626
|
-
int *sampling_decision_out,
|
627
|
-
int *sample_rate_out,
|
628
|
-
int *sample_source_out,
|
629
|
-
uint16_t *flags_out
|
630
|
-
);
|
631
|
-
|
632
|
-
/**
|
633
|
-
* wrapper for calling oboe_sample_layer_custom() with input/output structs instead of individual params
|
664
|
+
* This is designed to be called once per request.
|
634
665
|
*
|
635
666
|
* @param in Struct containing all params to help making a tracing decision
|
636
667
|
* @param out Struct containing all params that get set during decision making
|
@@ -773,21 +804,21 @@ extern int oboe_debug_log_remove(OboeDebugLoggerFcn oldLogger, void *context);
|
|
773
804
|
* We use this to get a reasonable standard format between apps.
|
774
805
|
*
|
775
806
|
* @param module An OBOE_MODULE_* module identifier. Use zero for undefined.
|
776
|
-
* @param app_name Either NULL or a pointer to a string containing a name for
|
777
|
-
* the application - will prefix the log entry. Useful when multiple
|
778
|
-
* apps log to the same destination.
|
807
|
+
* @param app_name Either NULL or a pointer to a string containing a name for
|
808
|
+
* the application - will prefix the log entry. Useful when multiple
|
809
|
+
* apps log to the same destination.
|
779
810
|
* @param trace_mode A string identifying the configured tracing mode, one of:
|
780
811
|
* "enabled", "disabled", "unset", or "undef" (for invalid values)
|
781
812
|
* Use the oboe_tracing_mode_to_string() function to convert from
|
782
813
|
* numeric values.
|
783
814
|
* @param sample_rate The configured sampling rate: -1 for unset or a
|
784
815
|
* integer fraction of 1000000.
|
785
|
-
* @param reporter_type String identifying the type of reporter configured:
|
816
|
+
* @param reporter_type String identifying the type of reporter configured:
|
786
817
|
* One of 'udp' (the default), 'ssl', or 'file'.
|
787
818
|
* @param reporter_args The string of comma-separated key=value settings
|
788
819
|
* used to initialize the reporter.
|
789
820
|
* @param extra: Either NULL or a pointer to a string to be appended to
|
790
|
-
* the log message and designed to include a few other
|
821
|
+
* the log message and designed to include a few other
|
791
822
|
* configuration parameters of interest.
|
792
823
|
*/
|
793
824
|
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_INFO
|
@@ -821,7 +852,7 @@ extern int oboe_debug_log_remove(OboeDebugLoggerFcn oldLogger, void *context);
|
|
821
852
|
/**
|
822
853
|
* Log a recoverable error.
|
823
854
|
*
|
824
|
-
* Each message is limited in the number of times that it will be reported at the
|
855
|
+
* Each message is limited in the number of times that it will be reported at the
|
825
856
|
* ERROR level after which it will be logged at the debug MEDIUM level.
|
826
857
|
*/
|
827
858
|
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_ERROR
|
@@ -838,7 +869,7 @@ extern int oboe_debug_log_remove(OboeDebugLoggerFcn oldLogger, void *context);
|
|
838
869
|
/**
|
839
870
|
* Log a warning.
|
840
871
|
*
|
841
|
-
* Each message is limited in the number of times that it will be reported at the
|
872
|
+
* Each message is limited in the number of times that it will be reported at the
|
842
873
|
* WARNING level after which it will be logged at the debug MEDIUM level.
|
843
874
|
*/
|
844
875
|
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_WARNING
|
@@ -855,7 +886,7 @@ extern int oboe_debug_log_remove(OboeDebugLoggerFcn oldLogger, void *context);
|
|
855
886
|
/**
|
856
887
|
* Log an informative message.
|
857
888
|
*
|
858
|
-
* Each message is limited in the number of times that it will be reported at the
|
889
|
+
* Each message is limited in the number of times that it will be reported at the
|
859
890
|
* INFO level after which it will be logged at the debug MEDIUM level.
|
860
891
|
*/
|
861
892
|
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_INFO
|
data/ext/oboe_metal/src/oboe.hpp
CHANGED
@@ -8,6 +8,8 @@
|
|
8
8
|
#define OBOE_HPP
|
9
9
|
|
10
10
|
#include <string>
|
11
|
+
#include <iostream>
|
12
|
+
#include <cstdlib>
|
11
13
|
#include <oboe.h>
|
12
14
|
|
13
15
|
|
@@ -126,74 +128,108 @@ public:
|
|
126
128
|
*
|
127
129
|
* call once per request
|
128
130
|
*
|
129
|
-
* when compiled via SWIG this function takes
|
130
|
-
*
|
131
|
+
* when compiled via SWIG this function takes 0-8 input argss and returns 9 output args
|
132
|
+
*
|
133
|
+
* inputs (0-8, all optional):
|
134
|
+
* @param in_xtrace, a valid xtrace string
|
135
|
+
* @param custom_sample_rate, 0-1000000
|
136
|
+
* @param custom_tracing_mode, 0(disabled) or 1(enabled)
|
137
|
+
* @param request_type, 0 normal sampling, 1 trigger trace
|
138
|
+
* @param custom_custom_trigger_mode, 0(disabled) or 1(enabled)
|
139
|
+
* @param header_options, the string from the X-Trace-Options header
|
140
|
+
* @param header_signature, the string from the X-Trace-Options-Signature header
|
141
|
+
* @param header_timestamp, the timestamp insidethe X-Trace-Options header
|
142
|
+
*
|
143
|
+
* returns:
|
131
144
|
* @param do_metrics, ignore when using SWIG, it will be mapped to the second return value
|
132
145
|
* @param do_sample, ignore when using SWIG, it will be mapped to the first return value
|
133
146
|
* @param sample_rate, ignore when using SWIG, it will be mapped to the third return value
|
134
147
|
* @param sample_source, ignore when using SWIG, it will be mapped to the forth return value
|
135
|
-
* @param
|
136
|
-
* @param
|
137
|
-
* @param
|
138
|
-
* @param
|
139
|
-
*
|
140
|
-
* @
|
141
|
-
* OBOE_TRACING_DECISIONS_TRACING_DISABLED == -2
|
142
|
-
* OBOE_TRACING_DECISIONS_XTRACE_NOT_SAMPLED == -1
|
143
|
-
* OBOE_TRACING_DECISIONS_OK == 0
|
144
|
-
* OBOE_TRACING_DECISIONS_NULL_OUT == 1
|
145
|
-
* OBOE_TRACING_DECISIONS_NO_CONFIG == 2
|
146
|
-
* OBOE_TRACING_DECISIONS_REPORTER_NOT_READY == 3
|
147
|
-
* OBOE_TRACING_DECISIONS_NO_VALID_SETTINGS == 4
|
148
|
+
* @param type, 0 normal sampling, 1 - trigger trace
|
149
|
+
* @param auth, 0 success, 1 failure, -1 not requested
|
150
|
+
* @param status_msg, message describing the trigger tracing decision
|
151
|
+
* @param auth_msg, message describing the succes/failure of the authorization
|
152
|
+
*
|
153
|
+
* @status one of the OBOE_TRACING_DECISION_* codes
|
148
154
|
*/
|
149
|
-
|
150
|
-
|
155
|
+
|
156
|
+
static void getDecisions(int *do_metrics, int *do_sample, int *sample_rate, int *sample_source,
|
157
|
+
int *type, int *auth,
|
158
|
+
std::string *status_msg, std::string *auth_msg,
|
159
|
+
int *status,
|
160
|
+
const char *in_xtrace = NULL,
|
151
161
|
int custom_tracing_mode = OBOE_SETTINGS_UNSET,
|
152
|
-
int custom_sample_rate = OBOE_SETTINGS_UNSET,
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
162
|
+
int custom_sample_rate = OBOE_SETTINGS_UNSET,
|
163
|
+
int request_type = 0,
|
164
|
+
int custom_trigger_mode = 0,
|
165
|
+
const char *header_options = NULL,
|
166
|
+
const char *header_signature = NULL,
|
167
|
+
long header_timestamp = 0
|
168
|
+
) {
|
169
|
+
|
170
|
+
oboe_tracing_decisions_in_t tdi;
|
171
|
+
memset(&tdi, 0, sizeof(tdi));
|
172
|
+
tdi.custom_tracing_mode = custom_tracing_mode;
|
173
|
+
tdi.custom_sample_rate = custom_sample_rate;
|
174
|
+
tdi.custom_trigger_mode = custom_trigger_mode;
|
175
|
+
tdi.request_type = request_type;
|
176
|
+
tdi.version = 2;
|
177
|
+
tdi.in_xtrace = in_xtrace;
|
178
|
+
tdi.header_options = header_options;
|
179
|
+
tdi.header_signature = header_signature;
|
180
|
+
tdi.header_timestamp = header_timestamp;
|
181
|
+
|
182
|
+
oboe_tracing_decisions_out_t tdo;
|
183
|
+
memset(&tdo, 0, sizeof(tdo));
|
184
|
+
tdo.version = 2;
|
185
|
+
|
186
|
+
*status = oboe_tracing_decisions(&tdi, &tdo);
|
187
|
+
|
188
|
+
// TODO this can be removed once everything is debugged
|
189
|
+
if (std::getenv("OBOE_VERBOSE")) { // Flawfinder: ignore
|
190
|
+
std::cout << "- - - - - - - - - - - - - - - - - -" << std::endl;
|
191
|
+
std::cout << "Decisions in: " << std::endl;
|
192
|
+
|
193
|
+
std::cout << "version " << tdi.version << std::endl;
|
194
|
+
if (tdi.service_name) { std::cout << "service_name " << tdi.service_name << std::endl; }
|
195
|
+
if (tdi.in_xtrace) { std::cout << "in_xtrace " << tdi.in_xtrace << std::endl; }
|
196
|
+
std::cout << "custom_sample_rate " << tdi.custom_sample_rate << std::endl;
|
197
|
+
std::cout << "custom_tracing_mode " << tdi.custom_tracing_mode << std::endl;
|
198
|
+
std::cout << "custom_trigger_mode " << tdi.custom_trigger_mode << std::endl;
|
199
|
+
std::cout << "request_type " << tdi.request_type << std::endl;
|
200
|
+
if (tdi.header_options) { std::cout << "header_options " << tdi.header_options << std::endl; }
|
201
|
+
if (tdi.header_signature) { std::cout << "header_signature " << tdi.header_signature << std::endl; }
|
202
|
+
std::cout << "header_timestamp " << tdi.header_timestamp << std::endl;
|
203
|
+
|
204
|
+
std::cout << std::endl;
|
205
|
+
std::cout << "Decisions out: " << std::endl;
|
206
|
+
|
207
|
+
std::cout << "version " << tdo.version << std::endl;
|
208
|
+
std::cout << "sample_rate " << tdo.sample_rate << std::endl;
|
209
|
+
std::cout << "sample_source " << tdo.sample_source << std::endl;
|
210
|
+
std::cout << "do_sample " << tdo.do_sample << std::endl;
|
211
|
+
std::cout << "do_metrics " << tdo.do_metrics << std::endl;
|
212
|
+
std::cout << "request_provisioned " << tdo.request_provisioned << std::endl;
|
213
|
+
std::cout << "auth_status " << tdo.auth_status << std::endl;
|
214
|
+
std::cout << "auth_message " << tdo.auth_message << std::endl;
|
215
|
+
std::cout << "status_message " << tdo.status_message << std::endl;
|
216
|
+
|
217
|
+
std::cout << std::endl << "status is " << *status << std::endl;
|
218
|
+
std::cout << "- - - - - - - - - - - - - - - - - -" << std::endl;
|
219
|
+
}
|
165
220
|
|
166
221
|
*do_sample = tdo.do_sample;
|
167
222
|
*do_metrics = tdo.do_metrics;
|
168
223
|
*sample_rate = tdo.sample_rate;
|
169
224
|
*sample_source = tdo.sample_source;
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
* Different services may have special rules.
|
179
|
-
*
|
180
|
-
* This is designed to be called once per service per request.
|
181
|
-
*
|
182
|
-
* @param service_name Name of the service being considered for tracing
|
183
|
-
* if empty, the default service name will be used
|
184
|
-
* @param in_xtrace Incoming X-Trace ID (NULL or empty string if not present)
|
185
|
-
* @return Zero to not trace; otherwise return the sample rate used in the low order
|
186
|
-
* bytes 0 to 2 and the sample source in the higher-order byte 3.
|
187
|
-
*/
|
188
|
-
static int sampleRequest(
|
189
|
-
std::string service_name,
|
190
|
-
std::string in_xtrace)
|
191
|
-
{
|
192
|
-
int sample_rate = 0;
|
193
|
-
int sample_source = 0;
|
194
|
-
int rc = (oboe_sample_layer(service_name.c_str(), in_xtrace.c_str(), &sample_rate, &sample_source));
|
195
|
-
|
196
|
-
return (rc == 0 ? 0 : (((sample_source & 0xFF) << 24) | (sample_rate & 0xFFFFFF)));
|
225
|
+
*type = tdo.request_provisioned;
|
226
|
+
if (tdo.status_message && tdo.status_message[0] != '\0') {
|
227
|
+
*status_msg = tdo.status_message;
|
228
|
+
}
|
229
|
+
*auth = tdo.auth_status;
|
230
|
+
if (tdo.auth_message && tdo.auth_message[0] != '\0') {
|
231
|
+
*auth_msg = tdo.auth_message;
|
232
|
+
}
|
197
233
|
}
|
198
234
|
|
199
235
|
/**
|
@@ -276,20 +312,23 @@ public:
|
|
276
312
|
* @param max_flush_wait_time Optional parameter to configure maximum wait time for flushing data before terminating in milli seconds
|
277
313
|
* @param events_flush_interval Optional parameter to configure how frequently events are flushed
|
278
314
|
* @param events_flush_batch_size Optional parameter to configure the batch size before events are flushed
|
315
|
+
* @param ec2_metadata_timeout Optional parameter to configure the timeout (milli seconds) for retrieving EC2 metadata
|
279
316
|
*/
|
280
317
|
static void init(std::string access_key = "", std::string hostname_alias = "",
|
281
318
|
int log_level = LOGLEVEL_DEFAULT,
|
282
319
|
int max_flush_wait_time = DEFAULT_FLUSH_MAX_WAIT_TIME,
|
283
320
|
int events_flush_interval = OBOE_DEFAULT_EVENTS_FLUSH_INTERVAL,
|
284
|
-
int events_flush_batch_size = OBOE_DEFAULT_EVENTS_FLUSH_BATCH_SIZE
|
321
|
+
int events_flush_batch_size = OBOE_DEFAULT_EVENTS_FLUSH_BATCH_SIZE,
|
322
|
+
int ec2_metadata_timeout = OBOE_DEFAULT_EC2_METADATA_TIMEOUT) {
|
285
323
|
oboe_init_options_t options;
|
286
324
|
memset(&options, 0, sizeof(options));
|
287
|
-
options.version =
|
325
|
+
options.version = 7;
|
288
326
|
options.log_level = log_level;
|
289
327
|
options.hostname_alias = hostname_alias.c_str();
|
290
328
|
options.max_flush_wait_time = max_flush_wait_time;
|
291
329
|
options.events_flush_interval = events_flush_interval;
|
292
330
|
options.events_flush_batch_size = events_flush_batch_size;
|
331
|
+
options.ec2_metadata_timeout = ec2_metadata_timeout;
|
293
332
|
|
294
333
|
oboe_init(&options);
|
295
334
|
}
|
@@ -610,14 +649,16 @@ public:
|
|
610
649
|
int histogram_precision, // the histogram precision (only for ssl)
|
611
650
|
int token_bucket_capacity, // custom token bucket capacity
|
612
651
|
int token_bucket_rate, // custom token bucket rate
|
613
|
-
int file_single
|
652
|
+
int file_single, // use single files in file reporter for each event
|
653
|
+
|
654
|
+
int ec2_metadata_timeout // the timeout (milli seconds) for retrieving EC2 metadata
|
614
655
|
) {
|
615
656
|
|
616
657
|
oboe_init_options_t options;
|
617
658
|
memset(&options, 0, sizeof(options));
|
659
|
+
options.version = 7;
|
618
660
|
oboe_init_options_set_defaults(&options);
|
619
661
|
|
620
|
-
options.version = 5;
|
621
662
|
if (hostname_alias != "") {
|
622
663
|
options.hostname_alias = hostname_alias.c_str();
|
623
664
|
}
|
@@ -645,6 +686,7 @@ public:
|
|
645
686
|
options.token_bucket_capacity = token_bucket_capacity;
|
646
687
|
options.token_bucket_rate = token_bucket_rate;
|
647
688
|
options.file_single = file_single;
|
689
|
+
options.ec2_metadata_timeout = ec2_metadata_timeout;
|
648
690
|
|
649
691
|
init_status = oboe_init(&options);
|
650
692
|
}
|