@@ -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
@@ -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 {
@@ -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
- void oboe_init_options_set_defaults (oboe_init_options_t * options );
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 used by oboe_sample_layer_custom(), oboe_tracing_decisions(), oboe_reporter_is_ready()
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
535
+
536
+ // convert above codes into const char* messages.
537
+ const char * oboe_get_tracing_decisions_auth_message (int code );
489
538
490
- // these codes are used by oboe_init(), oboe_init_reporter(), _oboe_create_reporter()
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
617
int last_auto_sample_rate ; // stores last known automatic sampling rate
546
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 layer per request.
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
0 commit comments