solarwinds_apm 6.0.0.preV5 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/ext/oboe_metal/extconf.rb +5 -4
  3. data/ext/oboe_metal/lib/liboboe-1.0-aarch64.so.sha256 +1 -1
  4. data/ext/oboe_metal/lib/liboboe-1.0-alpine-aarch64.so.sha256 +1 -1
  5. data/ext/oboe_metal/lib/liboboe-1.0-alpine-x86_64.so.sha256 +1 -1
  6. data/ext/oboe_metal/lib/liboboe-1.0-x86_64.so.sha256 +1 -1
  7. data/ext/oboe_metal/src/VERSION +1 -1
  8. data/ext/oboe_metal/src/oboe.h +56 -13
  9. data/ext/oboe_metal/src/oboe_api.cpp +105 -6
  10. data/ext/oboe_metal/src/oboe_api.h +121 -2
  11. data/ext/oboe_metal/src/oboe_debug.h +4 -315
  12. data/ext/oboe_metal/src/oboe_swig_wrap.cc +2987 -549
  13. data/lib/oboe_metal.rb +23 -64
  14. data/lib/rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb +1 -1
  15. data/lib/solarwinds_apm/api/current_trace_info.rb +2 -3
  16. data/lib/solarwinds_apm/api/opentelemetry.rb +2 -2
  17. data/lib/solarwinds_apm/api/tracing.rb +1 -1
  18. data/lib/solarwinds_apm/api.rb +1 -1
  19. data/lib/solarwinds_apm/config.rb +56 -17
  20. data/lib/solarwinds_apm/constants.rb +5 -7
  21. data/lib/solarwinds_apm/noop/README.md +1 -1
  22. data/lib/solarwinds_apm/noop/api.rb +83 -0
  23. data/lib/solarwinds_apm/noop/context.rb +13 -2
  24. data/lib/solarwinds_apm/noop/metadata.rb +5 -2
  25. data/lib/solarwinds_apm/{thread_local.rb → noop/span.rb} +14 -20
  26. data/lib/solarwinds_apm/{base.rb → noop.rb} +22 -27
  27. data/lib/solarwinds_apm/oboe_init_options.rb +23 -82
  28. data/lib/solarwinds_apm/opentelemetry/solarwinds_exporter.rb +1 -1
  29. data/lib/solarwinds_apm/opentelemetry/solarwinds_processor.rb +2 -2
  30. data/lib/solarwinds_apm/opentelemetry/solarwinds_sampler.rb +4 -3
  31. data/lib/solarwinds_apm/opentelemetry.rb +1 -1
  32. data/lib/solarwinds_apm/otel_config.rb +14 -43
  33. data/lib/solarwinds_apm/patch/dummy_patch.rb +12 -0
  34. data/lib/solarwinds_apm/patch.rb +11 -0
  35. data/lib/solarwinds_apm/support/logger_formatter.rb +1 -1
  36. data/lib/solarwinds_apm/support/oboe_tracing_mode.rb +20 -22
  37. data/lib/solarwinds_apm/support/service_key_checker.rb +94 -0
  38. data/lib/solarwinds_apm/{support_report.rb → support/support_report.rb} +11 -8
  39. data/lib/solarwinds_apm/support/swomarginalia/comment.rb +2 -2
  40. data/lib/solarwinds_apm/support/swomarginalia/swomarginalia.rb +1 -1
  41. data/lib/solarwinds_apm/support/transaction_settings.rb +1 -5
  42. data/lib/solarwinds_apm/support.rb +1 -0
  43. data/lib/solarwinds_apm/version.rb +1 -1
  44. data/lib/solarwinds_apm.rb +70 -55
  45. metadata +12 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b23156203ec3589196c343c4d16ba3fb44018e94ea34e585e7b62a03fd909832
4
- data.tar.gz: de12c6839abf0ecfb195ebf78f259c778aa05769b3f3fe48541c05707b67ab03
3
+ metadata.gz: 5dfd38bd4d4e3d70c56b86ffd34d9fe830e0944eb3fd02a82bff26da07900056
4
+ data.tar.gz: 1ec9662543689c97af6509f2db2bde6e62bd9274fd2b792925d4ebf9fd46c4fb
5
5
  SHA512:
6
- metadata.gz: 8fdb15ee558dea8d3f6737180e8542485c3a0bbeedd71372ab63f0fac552d0d1aac01c07f0076e95e691d9f1c97ce1013f22b76fd235d77fcf3d4422c5b4f6b5
7
- data.tar.gz: 7cce1f862385ce15655ede15071c429aced9e4f4af744c2496978fba2873642620520a7b3325a2945abfc127c720cea4bcae2c18320e83c88280b2ae0c612c04
6
+ metadata.gz: c90b9be36843bf092833fafc3fc16e6f97cf293787fd9551375b39a67c8f057b737c11145764eb47590b060bc22a60c367911bf8e31b3b5718452ad8b0e50234
7
+ data.tar.gz: 29e352eb73da5c09fc0caf35e73e65facb842d7becab500e0183071ec4aaa563daf0ae2bd483972f0ef2e5b51a780821b0075b432d2a86892e82eedc8c4f71ad
@@ -26,10 +26,10 @@ swo_include = File.join(ext_dir, 'src')
26
26
 
27
27
  # Download the appropriate liboboe from Staging or Production
28
28
  version = File.read(File.join(swo_include, 'VERSION')).strip
29
- if ENV['OBOE_DEV'].to_s.downcase == 'true'
29
+ if ENV['OBOE_DEV'].to_s.casecmp('true').zero?
30
30
  swo_path = "https://solarwinds-apm-staging.s3.us-west-2.amazonaws.com/apm/c-lib/nightly"
31
31
  puts 'Fetching c-lib from DEVELOPMENT Build'
32
- elsif ENV['OBOE_STAGING'].to_s.downcase == 'true'
32
+ elsif ENV['OBOE_STAGING'].to_s.casecmp('true').zero?
33
33
  swo_path = File.join('https://agent-binaries.global.st-ssp.solarwinds.com/apm/c-lib/', version)
34
34
  puts 'Fetching c-lib from STAGING'
35
35
  else
@@ -38,10 +38,11 @@ end
38
38
 
39
39
  swo_arch = 'x86_64'
40
40
  system_arch = `uname -m` # for mac, the command is `uname` # "Darwin\n"; try `uname -a`
41
- case system_arch.gsub("\n","")
41
+ system_arch.delete!("\n")
42
+ case system_arch
42
43
  when 'x86_64'
43
44
  swo_arch = 'x86_64'
44
- when 'aarch64'
45
+ when 'aarch64' || 'arm64'
45
46
  swo_arch = 'aarch64'
46
47
  end
47
48
 
@@ -1 +1 @@
1
- 86a0c98301b157fd2ec184e585d70e40753c721c52fbc596ab09aa3d422d5f1f
1
+ b3a0b342e5d59ea95b457bcc647b9a2e202d623d5c17a109df2719a5d61815d2
@@ -1 +1 @@
1
- 534122daed4a1a81a9e66828f206662ea8f6bf891fb84438cc3daef5f78a7af4
1
+ 5f98ddec2afd1992080d4e751b583a075e1a91b95ca3a5e5d7db49978225c8bd
@@ -1 +1 @@
1
- 89936e04f0b8cddf3fb94c8a4c21d16aa780d6e4fbf4bb66eba42eb33fe15cc6
1
+ 5227b6cc86a1d60c479f9e2021200b09e3ba70f47a563788c857f51747dbebe8
@@ -1 +1 @@
1
- 623f5b308759754c8d771567d5346c46e1d9b53739995a9b5594cc08f8bc6e54
1
+ 22d5c810eaf9b663b46ae67586059edf18e7e1e3beab89f079d2b86353ef55d9
@@ -1 +1 @@
1
- 13.0.0
1
+ 14.0.1
@@ -27,7 +27,6 @@ extern "C" {
27
27
  #include <unistd.h> // On Windows ssize_t definition was put in this header.
28
28
  #endif
29
29
  #include "bson/bson.h"
30
- #include "oboe_debug.h"
31
30
 
32
31
  /**
33
32
  * Default configuration settings update interval in seconds.
@@ -101,7 +100,6 @@ extern "C" {
101
100
  #define OBOE_REPORTER_PROTOCOL_UDP "udp"
102
101
  #define OBOE_REPORTER_PROTOCOL_SSL "ssl"
103
102
  #define OBOE_REPORTER_PROTOCOL_NULL "null"
104
- #define OBOE_REPORTER_PROTOCOL_LAMBDA "lambda"
105
103
 
106
104
  /** Maximum reasonable length of an arguments string for configuring a reporter. */
107
105
  #define OBOE_REPORTER_ARGS_SIZE 4000
@@ -163,10 +161,10 @@ typedef struct oboe_metric_tag {
163
161
  } oboe_metric_tag_t;
164
162
 
165
163
  typedef struct oboe_init_options {
166
- int version; // the version of this structure (currently on version 15)
164
+ int version; // the version of this structure (currently on version 16)
167
165
  const char *hostname_alias; // optional hostname alias
168
166
  int log_level; // level at which log messages will be written to log file (0-6)
169
- // use LOGLEVEL_DEFAULT for default log level
167
+ // use OBOE_INIT_LOG_LEVEL_INFO(3) for default log level
170
168
  const char *log_file_path; // file name including path for log file
171
169
  int max_transactions; // maximum number of transaction names to track
172
170
  int max_flush_wait_time; // maximum wait time for flushing data before terminating in milli seconds
@@ -189,6 +187,7 @@ typedef struct oboe_init_options {
189
187
  int stdout_clear_nonblocking; // flag indicating if the O_NONBLOCK flag on stdout should be cleared,
190
188
  // only used in lambda reporter (off=0, on=1, default off)
191
189
  int metric_format; // flag indicating the format of metric (0 = Both; 1 = TransactionResponseTime only; 2 = ResponseTime only; default = 0)
190
+ int log_type; // log type (0 = stderr; 1 = stdout; 2 = file; 3 = null; 4 = disabled; default = 0)
192
191
  } oboe_init_options_t;
193
192
 
194
193
  typedef struct oboe_span_params {
@@ -486,6 +485,13 @@ int oboe_raw_send(int channel, const char *data, size_t len);
486
485
  */
487
486
  void oboe_shutdown();
488
487
 
488
+ /**
489
+ * Don't call *coming_impl function directly, they are temporary
490
+ */
491
+ bool oboe_validate_tracing_decisions_in_t(oboe_tracing_decisions_in_t *in);
492
+ int oboe_init_coming_impl(const char* json);
493
+ int oboe_tracing_decisions_coming_impl(oboe_tracing_decisions_in_t *in, oboe_tracing_decisions_out_t *out);
494
+ void oboe_shutdown_coming_impl();
489
495
 
490
496
  // Settings interface
491
497
 
@@ -577,6 +583,7 @@ const char* oboe_get_tracing_decisions_message(int code);
577
583
  #define OBOE_TRACING_DECISIONS_AUTH_NO_SIG_KEY 1
578
584
  #define OBOE_TRACING_DECISIONS_AUTH_INVALID_SIG 2
579
585
  #define OBOE_TRACING_DECISIONS_AUTH_BAD_TIMESTAMP 3
586
+ #define OBOE_TRACING_DECISIONS_AUTH_INTERNAL_ERROR 4
580
587
 
581
588
  // convert above codes into const char* messages.
582
589
  const char* oboe_get_tracing_decisions_auth_message (int code);
@@ -624,6 +631,20 @@ const char* oboe_get_tracing_decisions_auth_message (int code);
624
631
  #define OBOE_REPORTER_FLUSH_NO_REPORTER 3
625
632
  #define OBOE_REPORTER_FLUSH_REPORTER_NOT_READY 4
626
633
 
634
+ #define OBOE_INIT_LOG_LEVEL_FATAL 0
635
+ #define OBOE_INIT_LOG_LEVEL_ERROR 1
636
+ #define OBOE_INIT_LOG_LEVEL_WARNING 2
637
+ #define OBOE_INIT_LOG_LEVEL_INFO 3
638
+ #define OBOE_INIT_LOG_LEVEL_DEBUG 4
639
+ #define OBOE_INIT_LOG_LEVEL_PREVIOUS_MEDIUM 5
640
+ #define OBOE_INIT_LOG_LEVEL_TRACE 6
641
+
642
+ #define OBOE_INIT_LOG_TYPE_STDERR 0
643
+ #define OBOE_INIT_LOG_TYPE_STDOUT 1
644
+ #define OBOE_INIT_LOG_TYPE_FILE 2
645
+ #define OBOE_INIT_LOG_TYPE_NULL 3 // NULL means no output
646
+ #define OBOE_INIT_LOG_TYPE_DISABLE 4 // Explicit disable logging
647
+
627
648
  // token buckets
628
649
  enum TOKEN_BUCKETS {
629
650
  TOKEN_BUCKET_SAMPLING, // for normal requests
@@ -864,18 +885,40 @@ oboe_internal_stats_t* oboe_get_internal_stats();
864
885
  // Random
865
886
  void oboe_random_bytes(uint8_t bytes[], size_t sz);
866
887
 
867
- // oboe logging macro
868
- #define OBOE_DEBUG_LOG_CONFIG(module, app_name, trace_mode, sample_rate, reporter_type, reporter_args, extra) OBOE_DEBUG_LOG_CONFIG_EX(module, app_name, trace_mode, sample_rate, reporter_type, reporter_args, extra)
869
- #define OBOE_DEBUG_LOG_FATAL(module, ...) OBOE_DEBUG_LOG_FATAL_EX(module, __VA_ARGS__)
870
- #define OBOE_DEBUG_LOG_ERROR(module, ...) OBOE_DEBUG_LOG_ERROR_EX(module, __VA_ARGS__)
871
- #define OBOE_DEBUG_LOG_WARNING(module, ...) OBOE_DEBUG_LOG_WARNING_EX(module, __VA_ARGS__)
872
- #define OBOE_DEBUG_LOG_INFO(module, ...) OBOE_DEBUG_LOG_INFO_EX(module, __VA_ARGS__)
873
- #define OBOE_DEBUG_LOG_LOW(module, ...) OBOE_DEBUG_LOG_LOW_EX(module, __VA_ARGS__)
874
- #define OBOE_DEBUG_LOG_MEDIUM(module, ...) OBOE_DEBUG_LOG_MEDIUM_EX(module, __VA_ARGS__)
875
- #define OBOE_DEBUG_LOG_HIGH(module, ...) OBOE_DEBUG_LOG_HIGH_EX(module, __VA_ARGS__)
888
+ // oboe logging macro (Phasing out marco)
889
+ #define OBOE_DEBUG_LOG_CONFIG(module, app_name, trace_mode, sample_rate, reporter_type, reporter_args, extra) do {} while(0)
890
+ #define OBOE_DEBUG_LOG_FATAL(module, ...) do {} while(0)
891
+ #define OBOE_DEBUG_LOG_ERROR(module, ...) do {} while(0)
892
+ #define OBOE_DEBUG_LOG_WARNING(module, ...) do {} while(0)
893
+ #define OBOE_DEBUG_LOG_INFO(module, ...) do {} while(0)
894
+ #define OBOE_DEBUG_LOG_LOW(module, ...) do {} while(0)
895
+ #define OBOE_DEBUG_LOG_MEDIUM(module, ...) do {} while(0)
896
+ #define OBOE_DEBUG_LOG_HIGH(module, ...) do {} while(0)
876
897
 
877
898
  void oboe_init_once();
878
899
 
900
+ /**
901
+ * Request Counts function
902
+ * If succeed, it can get the value and reset the value to 0
903
+ * @param value output value
904
+ * @return bool
905
+ */
906
+ bool oboe_consume_request_count(unsigned int* value);
907
+ bool oboe_consume_token_bucket_exhaustion_count(unsigned int* value);
908
+ bool oboe_consume_trace_count(unsigned int* value);
909
+ bool oboe_consume_sample_count(unsigned int* value);
910
+ bool oboe_consume_through_ignored_count(unsigned int* value);
911
+ bool oboe_consume_through_trace_count(unsigned int* value);
912
+ bool oboe_consume_triggered_trace_count(unsigned int* value);
913
+ /**
914
+ * Request Counts function
915
+ * If succeed, it can get the value
916
+ * @param value output value
917
+ * @return bool
918
+ */
919
+ bool oboe_get_last_used_sample_rate(unsigned int* value);
920
+ bool oboe_get_last_used_sample_source(unsigned int* value);
921
+
879
922
  #ifdef __cplusplus
880
923
  } // extern "C"
881
924
  #endif
@@ -447,9 +447,6 @@ bool Event::sendProfiling() {
447
447
  size_t len = (size_t)(this->bbuf.cur - this->bbuf.buf);
448
448
  retval = oboe_raw_send(OBOE_SEND_PROFILING, this->bb_str, len);
449
449
 
450
- if (retval < 0)
451
- OBOE_DEBUG_LOG_ERROR(OBOE_MODULE_LIBOBOE, "Raw send failed - reporter returned %d", retval);
452
-
453
450
  return (retval >= 0);
454
451
  }
455
452
 
@@ -589,11 +586,12 @@ Reporter::Reporter(
589
586
  std::string grpc_proxy, // HTTP proxy address and port to be used for the gRPC connection
590
587
  int stdout_clear_nonblocking, // flag indicating if the O_NONBLOCK flag on stdout should be cleared,
591
588
  // only used in lambda reporter (off=0, on=1, default off)
592
- int metric_format // flag indicating the format of metric (0 = Both; 1 = TransactionResponseTime only; 2 = ResponseTime only; default = 0)
589
+ int metric_format, // flag indicating the format of metric (0 = Both; 1 = TransactionResponseTime only; 2 = ResponseTime only; default = 0)
590
+ int log_type // log type (0 = stderr; 1 = stdout; 2 = file; 3 = null; 4 = disabled; default = 0)
593
591
  ) {
594
592
  oboe_init_options_t options;
595
593
  memset(&options, 0, sizeof(options));
596
- options.version = 15;
594
+ options.version = 16;
597
595
  oboe_init_options_set_defaults(&options);
598
596
 
599
597
  if (hostname_alias != "") {
@@ -629,11 +627,12 @@ Reporter::Reporter(
629
627
  }
630
628
  options.stdout_clear_nonblocking = stdout_clear_nonblocking;
631
629
  options.metric_format = metric_format;
630
+ options.log_type = log_type;
632
631
  init_status = oboe_init(&options);
633
632
  }
634
633
 
635
634
  Reporter::~Reporter() {
636
- oboe_reporter_destroy(this);
635
+ oboe_shutdown();
637
636
  }
638
637
 
639
638
  bool Reporter::sendReport(Event *evt, bool with_system_timestamp) {
@@ -690,3 +689,103 @@ bool Config::checkVersion(int version, int revision) {
690
689
  std::string Config::getVersionString() {
691
690
  return oboe_config_get_version_string();
692
691
  }
692
+
693
+ // ===================================================================================================
694
+ OboeAPI::OboeAPI(const OboeAPIOptions& options) {
695
+ oboe_init_options_t oboe_options;
696
+ memset(&oboe_options, 0, sizeof(oboe_options));
697
+ oboe_options.version = 16;
698
+ oboe_init_options_set_defaults(&oboe_options);
699
+ oboe_options.log_level = options.logging_options.level;
700
+ oboe_options.log_type = options.logging_options.type;
701
+ oboe_init(&oboe_options);
702
+ }
703
+
704
+ OboeAPI::~OboeAPI() {
705
+ oboe_shutdown();
706
+ }
707
+
708
+ void OboeAPI::getTracingDecision(
709
+ // output
710
+ int *do_metrics,
711
+ int *do_sample,
712
+ int *sample_rate,
713
+ int *sample_source,
714
+ double *bucket_rate,
715
+ double *bucket_cap,
716
+ int *type,
717
+ int *auth,
718
+ std::string *status_msg,
719
+ std::string *auth_msg,
720
+ int *status,
721
+ // input
722
+ const char *in_xtrace,
723
+ const char *tracestate,
724
+ int custom_tracing_mode,
725
+ int custom_sample_rate,
726
+ int request_type,
727
+ int custom_trigger_mode,
728
+ const char *header_options,
729
+ const char *header_signature,
730
+ long header_timestamp) {
731
+ oboe_tracing_decisions_in_t tdi;
732
+ memset(&tdi, 0, sizeof(tdi));
733
+ tdi.version = 3;
734
+
735
+ tdi.custom_tracing_mode = custom_tracing_mode;
736
+ tdi.custom_sample_rate = custom_sample_rate;
737
+ tdi.custom_trigger_mode = custom_trigger_mode;
738
+ tdi.request_type = request_type;
739
+
740
+ tdi.in_xtrace = in_xtrace;
741
+ tdi.tracestate = tracestate; // value of sw member in tracestate, ignored when not in w3c mode
742
+ tdi.header_options = header_options;
743
+ tdi.header_signature = header_signature;
744
+ tdi.header_timestamp = header_timestamp;
745
+
746
+ oboe_tracing_decisions_out_t tdo;
747
+ memset(&tdo, 0, sizeof(tdo));
748
+ tdo.version = 3;
749
+
750
+ *status = oboe_tracing_decisions(&tdi, &tdo);
751
+
752
+ *do_sample = tdo.do_sample;
753
+ *do_metrics = tdo.do_metrics;
754
+ *sample_rate = tdo.sample_rate;
755
+ *sample_source = tdo.sample_source;
756
+ *bucket_rate = tdo.token_bucket_rate;
757
+ *bucket_cap = tdo.token_bucket_capacity;
758
+ *type = tdo.request_provisioned;
759
+ if (tdo.status_message && tdo.status_message[0] != '\0') {
760
+ *status_msg = tdo.status_message;
761
+ }
762
+ *auth = tdo.auth_status;
763
+ if (tdo.auth_message && tdo.auth_message[0] != '\0') {
764
+ *auth_msg = tdo.auth_message;
765
+ }
766
+ }
767
+
768
+ bool OboeAPI::consumeRequestCount(unsigned int& counter) {
769
+ return oboe_consume_request_count(&counter);
770
+ }
771
+ bool OboeAPI::consumeTokenBucketExhaustionCount(unsigned int& counter) {
772
+ return oboe_consume_token_bucket_exhaustion_count(&counter);
773
+ }
774
+ bool OboeAPI::consumeTraceCount(unsigned int& counter) {
775
+ return oboe_consume_through_trace_count(&counter);
776
+ }
777
+ bool OboeAPI::consumeSampleCount(unsigned int& counter) {
778
+ return oboe_consume_sample_count(&counter);
779
+ }
780
+ bool OboeAPI::consumeThroughTraceCount(unsigned int& counter) {
781
+ return oboe_consume_through_trace_count(&counter);
782
+ }
783
+ bool OboeAPI::consumeTriggeredTraceCount(unsigned int& counter) {
784
+ return oboe_consume_triggered_trace_count(&counter);
785
+ }
786
+ bool OboeAPI::getLastUsedSampleRate(unsigned int& rate) {
787
+ return oboe_get_last_used_sample_rate(&rate);
788
+ }
789
+ bool OboeAPI::getLastUsedSampleSource(unsigned int& source) {
790
+ return oboe_get_last_used_sample_source(&source);
791
+ }
@@ -102,7 +102,6 @@ class Context {
102
102
  * @param newMode One of
103
103
  * - OBOE_TRACE_DISABLED(0) to disable tracing,
104
104
  * - OBOE_TRACE_ENABLED(1) to start a new trace if needed, or
105
- * - OBOE_TRACE_THROUGH(2) to only add to an existing trace.
106
105
  */
107
106
  static void setTracingMode(int newMode);
108
107
 
@@ -463,7 +462,8 @@ class Reporter : private oboe_reporter_t {
463
462
  std::string grpc_proxy, // HTTP proxy address and port to be used for the gRPC connection
464
463
  int stdout_clear_nonblocking, // flag indicating if the O_NONBLOCK flag on stdout should be cleared,
465
464
  // only used in lambda reporter (off=0, on=1, default off)
466
- int metric_format // flag indicating the format of metric (0 = Both; 1 = TransactionResponseTime only; 2 = ResponseTime only; default = 0)
465
+ int metric_format, // flag indicating the format of metric (0 = Both; 1 = TransactionResponseTime only; 2 = ResponseTime only; default = 0)
466
+ int log_type // log type (0 = stderr; 1 = stdout; 2 = file; 3 = null; 4 = disabled; default = 0)
467
467
  );
468
468
 
469
469
  ~Reporter();
@@ -498,4 +498,123 @@ class Config {
498
498
  static std::string getVersionString();
499
499
  };
500
500
 
501
+ struct LoggingOptions {
502
+ LoggingOptions() : level(2), type(0) {
503
+ }
504
+ int level;
505
+ int type;
506
+ };
507
+
508
+ struct OboeAPIOptions {
509
+ LoggingOptions logging_options;
510
+ };
511
+
512
+ class OboeAPI {
513
+ public:
514
+ OboeAPI(const OboeAPIOptions& options = OboeAPIOptions());
515
+ ~OboeAPI();
516
+ /**
517
+ * Get tracing decision
518
+ * @param do_metrics
519
+ * @param do_sample
520
+ * @param sample_rate
521
+ * @param sample_source
522
+ * @param bucket_rate
523
+ * @param bucket_cap
524
+ * @param type
525
+ * @param auth
526
+ * @param status_msg
527
+ * @param auth_msg
528
+ * @param status
529
+ * @param in_xtrace
530
+ * @param tracestate
531
+ * @param custom_tracing_mode
532
+ * @param custom_sample_rate
533
+ * @param request_type
534
+ * @param custom_trigger_mode
535
+ * @param header_options
536
+ * @param header_signature
537
+ * @param header_timestamp
538
+ */
539
+ void getTracingDecision(
540
+ // SWIG output
541
+ int *do_metrics,
542
+ int *do_sample,
543
+ int *sample_rate,
544
+ int *sample_source,
545
+ double *bucket_rate,
546
+ double *bucket_cap,
547
+ int *type,
548
+ int *auth,
549
+ std::string *status_msg,
550
+ std::string *auth_msg,
551
+ int *status,
552
+ // SWIG input
553
+ const char *in_xtrace = NULL,
554
+ const char *tracestate = NULL,
555
+ int custom_tracing_mode = OBOE_SETTINGS_UNSET,
556
+ int custom_sample_rate = OBOE_SETTINGS_UNSET,
557
+ int request_type = 0,
558
+ int custom_trigger_mode = 0,
559
+ const char *header_options = NULL,
560
+ const char *header_signature = NULL,
561
+ long header_timestamp = 0);
562
+ /**
563
+ * Consume request count
564
+ * Check the return bool before using the counter, also consumeRequestCount will set the internal counter to 0 after referencing it
565
+ * @param counter
566
+ * @return bool
567
+ */
568
+ bool consumeRequestCount(unsigned int& counter);
569
+ /**
570
+ * Consume token bucket exhaustion count
571
+ * Check the return bool before using the counter, also consumeTokenBucketExhaustionCount will set the internal counter to 0 after referencing it
572
+ * @param counter
573
+ * @return bool
574
+ */
575
+ bool consumeTokenBucketExhaustionCount(unsigned int& counter);
576
+ /**
577
+ * Consume trace count
578
+ * Check the return bool before using the counter, also consumeTraceCount will set the internal counter to 0 after referencing it
579
+ * @param counter
580
+ * @return bool
581
+ */
582
+ bool consumeTraceCount(unsigned int& counter);
583
+ /**
584
+ * Consume sample count
585
+ * Check the return bool before using the counter, also consumeSampleCount will set the internal counter to 0 after referencing it
586
+ * @param counter
587
+ * @return bool
588
+ */
589
+ bool consumeSampleCount(unsigned int& counter);
590
+ /**
591
+ * Consume through trace count
592
+ * Check the return bool before using the counter, also consumeThroughTraceCount will set the internal counter to 0 after referencing it
593
+ * @param counter
594
+ * @return bool
595
+ */
596
+ bool consumeThroughTraceCount(unsigned int& counter);
597
+ /**
598
+ * Consume triggered trace count
599
+ * Check the return bool before using the counter, also consumeTriggeredTraceCount will set the internal counter to 0 after referencing it
600
+ * @param counter
601
+ * @return bool
602
+ */
603
+ bool consumeTriggeredTraceCount(unsigned int& counter);
604
+ /**
605
+ * Get last used sample rate
606
+ * Check the return bool before using the rate
607
+ * @param rate
608
+ * @return bool
609
+ */
610
+ bool getLastUsedSampleRate(unsigned int& rate);
611
+ /**
612
+ * Get last used sample source
613
+ * Check the return bool before using the source
614
+ * @param source
615
+ * @return bool
616
+ */
617
+ bool getLastUsedSampleSource(unsigned int& source);
618
+ };
619
+
501
620
  #endif // OBOE_API_H