appoptics_apm-zearn 4.13.1
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.
- checksums.yaml +7 -0
- data/.dockerignore +5 -0
- data/.github/ISSUE_TEMPLATE/bug-or-feature-request.md +16 -0
- data/.github/workflows/build_and_release_gem.yml +103 -0
- data/.github/workflows/build_for_packagecloud.yml +70 -0
- data/.github/workflows/docker-images.yml +47 -0
- data/.github/workflows/run_cpluplus_tests.yml +73 -0
- data/.github/workflows/run_tests.yml +168 -0
- data/.github/workflows/scripts/test_install.rb +23 -0
- data/.github/workflows/swig/swig-v4.0.2.tar.gz +0 -0
- data/.github/workflows/test_on_4_linux.yml +159 -0
- data/.gitignore +36 -0
- data/.rubocop.yml +29 -0
- data/.travis.yml +130 -0
- data/.yardopts +6 -0
- data/CHANGELOG.md +769 -0
- data/CONFIG.md +33 -0
- data/Gemfile +14 -0
- data/LICENSE +202 -0
- data/README.md +393 -0
- data/appoptics_apm.gemspec +70 -0
- data/bin/appoptics_apm_config +15 -0
- data/examples/prepend.rb +13 -0
- data/examples/sdk_examples.rb +158 -0
- data/ext/oboe_metal/README.md +69 -0
- data/ext/oboe_metal/extconf.rb +151 -0
- data/ext/oboe_metal/lib/.keep +0 -0
- data/ext/oboe_metal/lib/liboboe-1.0-alpine-x86_64.so.0.0.0.sha256 +1 -0
- data/ext/oboe_metal/lib/liboboe-1.0-x86_64.so.0.0.0.sha256 +1 -0
- data/ext/oboe_metal/noop/noop.c +8 -0
- data/ext/oboe_metal/src/README.md +6 -0
- data/ext/oboe_metal/src/VERSION +2 -0
- data/ext/oboe_metal/src/bson/bson.h +220 -0
- data/ext/oboe_metal/src/bson/platform_hacks.h +91 -0
- data/ext/oboe_metal/src/frames.cc +246 -0
- data/ext/oboe_metal/src/frames.h +40 -0
- data/ext/oboe_metal/src/init_appoptics_apm.cc +21 -0
- data/ext/oboe_metal/src/logging.cc +95 -0
- data/ext/oboe_metal/src/logging.h +35 -0
- data/ext/oboe_metal/src/oboe.h +1156 -0
- data/ext/oboe_metal/src/oboe_api.cpp +652 -0
- data/ext/oboe_metal/src/oboe_api.hpp +431 -0
- data/ext/oboe_metal/src/oboe_debug.h +59 -0
- data/ext/oboe_metal/src/oboe_swig_wrap.cc +7329 -0
- data/ext/oboe_metal/src/profiling.cc +435 -0
- data/ext/oboe_metal/src/profiling.h +78 -0
- data/ext/oboe_metal/test/CMakeLists.txt +53 -0
- data/ext/oboe_metal/test/FindGMock.cmake +43 -0
- data/ext/oboe_metal/test/README.md +56 -0
- data/ext/oboe_metal/test/frames_test.cc +164 -0
- data/ext/oboe_metal/test/profiling_test.cc +93 -0
- data/ext/oboe_metal/test/ruby_inc_dir.rb +8 -0
- data/ext/oboe_metal/test/ruby_prefix.rb +8 -0
- data/ext/oboe_metal/test/ruby_test_helper.rb +67 -0
- data/ext/oboe_metal/test/test.h +11 -0
- data/ext/oboe_metal/test/test_main.cc +32 -0
- data/init.rb +4 -0
- data/lib/appoptics_apm/api/layerinit.rb +41 -0
- data/lib/appoptics_apm/api/logging.rb +381 -0
- data/lib/appoptics_apm/api/memcache.rb +37 -0
- data/lib/appoptics_apm/api/metrics.rb +63 -0
- data/lib/appoptics_apm/api/tracing.rb +57 -0
- data/lib/appoptics_apm/api/util.rb +120 -0
- data/lib/appoptics_apm/api.rb +21 -0
- data/lib/appoptics_apm/base.rb +231 -0
- data/lib/appoptics_apm/config.rb +299 -0
- data/lib/appoptics_apm/frameworks/grape.rb +98 -0
- data/lib/appoptics_apm/frameworks/padrino.rb +78 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller.rb +104 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller4.rb +48 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller5.rb +50 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller6.rb +50 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller_api.rb +50 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_view.rb +88 -0
- data/lib/appoptics_apm/frameworks/rails/inst/active_record.rb +27 -0
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/mysql.rb +43 -0
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/mysql2.rb +29 -0
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/postgresql.rb +31 -0
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils.rb +119 -0
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +114 -0
- data/lib/appoptics_apm/frameworks/rails/inst/logger_formatters.rb +27 -0
- data/lib/appoptics_apm/frameworks/rails.rb +100 -0
- data/lib/appoptics_apm/frameworks/sinatra.rb +96 -0
- data/lib/appoptics_apm/inst/bunny-client.rb +148 -0
- data/lib/appoptics_apm/inst/bunny-consumer.rb +89 -0
- data/lib/appoptics_apm/inst/curb.rb +332 -0
- data/lib/appoptics_apm/inst/dalli.rb +85 -0
- data/lib/appoptics_apm/inst/delayed_job.rb +92 -0
- data/lib/appoptics_apm/inst/em-http-request.rb +101 -0
- data/lib/appoptics_apm/inst/excon.rb +125 -0
- data/lib/appoptics_apm/inst/faraday.rb +106 -0
- data/lib/appoptics_apm/inst/graphql.rb +240 -0
- data/lib/appoptics_apm/inst/grpc_client.rb +159 -0
- data/lib/appoptics_apm/inst/grpc_server.rb +120 -0
- data/lib/appoptics_apm/inst/http.rb +81 -0
- data/lib/appoptics_apm/inst/httpclient.rb +174 -0
- data/lib/appoptics_apm/inst/logger_formatter.rb +50 -0
- data/lib/appoptics_apm/inst/logging_log_event.rb +28 -0
- data/lib/appoptics_apm/inst/lumberjack_formatter.rb +13 -0
- data/lib/appoptics_apm/inst/memcached.rb +86 -0
- data/lib/appoptics_apm/inst/mongo.rb +246 -0
- data/lib/appoptics_apm/inst/mongo2.rb +225 -0
- data/lib/appoptics_apm/inst/moped.rb +466 -0
- data/lib/appoptics_apm/inst/rack.rb +182 -0
- data/lib/appoptics_apm/inst/rack_cache.rb +35 -0
- data/lib/appoptics_apm/inst/redis.rb +274 -0
- data/lib/appoptics_apm/inst/resque.rb +151 -0
- data/lib/appoptics_apm/inst/rest-client.rb +48 -0
- data/lib/appoptics_apm/inst/sequel.rb +178 -0
- data/lib/appoptics_apm/inst/sidekiq-client.rb +55 -0
- data/lib/appoptics_apm/inst/sidekiq-worker.rb +66 -0
- data/lib/appoptics_apm/inst/twitter-cassandra.rb +294 -0
- data/lib/appoptics_apm/inst/typhoeus.rb +108 -0
- data/lib/appoptics_apm/instrumentation.rb +22 -0
- data/lib/appoptics_apm/loading.rb +65 -0
- data/lib/appoptics_apm/logger.rb +14 -0
- data/lib/appoptics_apm/noop/README.md +9 -0
- data/lib/appoptics_apm/noop/context.rb +27 -0
- data/lib/appoptics_apm/noop/metadata.rb +25 -0
- data/lib/appoptics_apm/noop/profiling.rb +21 -0
- data/lib/appoptics_apm/oboe_init_options.rb +211 -0
- data/lib/appoptics_apm/ruby.rb +35 -0
- data/lib/appoptics_apm/sdk/current_trace.rb +77 -0
- data/lib/appoptics_apm/sdk/custom_metrics.rb +94 -0
- data/lib/appoptics_apm/sdk/logging.rb +37 -0
- data/lib/appoptics_apm/sdk/tracing.rb +434 -0
- data/lib/appoptics_apm/support/profiling.rb +18 -0
- data/lib/appoptics_apm/support/transaction_metrics.rb +67 -0
- data/lib/appoptics_apm/support/transaction_settings.rb +219 -0
- data/lib/appoptics_apm/support/x_trace_options.rb +110 -0
- data/lib/appoptics_apm/support_report.rb +119 -0
- data/lib/appoptics_apm/test.rb +95 -0
- data/lib/appoptics_apm/thread_local.rb +26 -0
- data/lib/appoptics_apm/util.rb +326 -0
- data/lib/appoptics_apm/version.rb +16 -0
- data/lib/appoptics_apm/xtrace.rb +115 -0
- data/lib/appoptics_apm.rb +77 -0
- data/lib/joboe_metal.rb +212 -0
- data/lib/oboe.rb +7 -0
- data/lib/oboe_metal.rb +172 -0
- data/lib/rails/generators/appoptics_apm/install_generator.rb +47 -0
- data/lib/rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb +425 -0
- data/log/.keep +0 -0
- data/yardoc_frontpage.md +26 -0
- metadata +231 -0
@@ -0,0 +1,1156 @@
|
|
1
|
+
/**
|
2
|
+
* @file oboe.h
|
3
|
+
*
|
4
|
+
* API header for AppOptics' Oboe application tracing library for use with AppOptics.
|
5
|
+
*
|
6
|
+
* @package Oboe
|
7
|
+
* @author AppOptics
|
8
|
+
* @copyright Copyright (c) 2016, SolarWinds LLC
|
9
|
+
* @license
|
10
|
+
* @link https://appoptics.com
|
11
|
+
**/
|
12
|
+
|
13
|
+
#ifndef LIBOBOE_H
|
14
|
+
#define LIBOBOE_H
|
15
|
+
|
16
|
+
|
17
|
+
#ifdef __cplusplus
|
18
|
+
extern "C" {
|
19
|
+
#endif
|
20
|
+
|
21
|
+
#include <stdio.h>
|
22
|
+
#include <sys/types.h>
|
23
|
+
#include <sys/time.h>
|
24
|
+
#include <inttypes.h>
|
25
|
+
#if defined _WIN32
|
26
|
+
#include <unistd.h> // On Windows ssize_t definition was put in this header.
|
27
|
+
#endif
|
28
|
+
#include "bson/bson.h"
|
29
|
+
#include "oboe_debug.h"
|
30
|
+
|
31
|
+
/** Compile time debug logging detail level - cannot log more detailed than this. */
|
32
|
+
#define OBOE_DEBUG_LEVEL OBOE_DEBUG_HIGH
|
33
|
+
|
34
|
+
/** Limit for number of messages at specified level before demoting to debug MEDIUM. */
|
35
|
+
#define MAX_DEBUG_MSG_COUNT 1
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Default configuration settings update interval in seconds.
|
39
|
+
*
|
40
|
+
* Borrowed from the Tracelyzer's oboe.h.
|
41
|
+
*/
|
42
|
+
#define OBOE_DEFAULT_SETTINGS_INTERVAL 30
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Default interval to check for timed out settings records in seconds
|
46
|
+
*/
|
47
|
+
#define OBOE_DEFAULT_TIMEOUT_CHECK_INTERVAL 10
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Default metrics flush interval in seconds
|
51
|
+
*/
|
52
|
+
#define OBOE_DEFAULT_METRICS_FLUSH_INTERVAL 60
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Default maximum number of transaction names to track when aggregating metric and histogram data by individual service transaction
|
56
|
+
*/
|
57
|
+
#define OBOE_DEFAULT_MAX_TRANSACTIONS 200
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Default maximum number of custom metrics per flash interval
|
61
|
+
*/
|
62
|
+
#define OBOE_DEFAULT_MAX_CUSTOM_METRICS 500
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Default keepalive interval in seconds.
|
66
|
+
*
|
67
|
+
* A keepalive message will be sent after communications are idle for this interval.
|
68
|
+
*/
|
69
|
+
#define OBOE_DEFAULT_KEEPALIVE_INTERVAL 20
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Time to wait for all remaining data to be sent off
|
73
|
+
*/
|
74
|
+
#define DEFAULT_FLUSH_MAX_WAIT_TIME 5000
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Default events flush timeout in seconds.
|
78
|
+
*/
|
79
|
+
#define OBOE_DEFAULT_EVENTS_FLUSH_INTERVAL 2
|
80
|
+
/**
|
81
|
+
* Default max request size in bytes.
|
82
|
+
*/
|
83
|
+
#define OBOE_DEFAULT_MAX_REQUEST_SIZE_BYTES 3000000
|
84
|
+
/**
|
85
|
+
* Default EC2 metadata timeout in milliseconds
|
86
|
+
*/
|
87
|
+
#define OBOE_DEFAULT_EC2_METADATA_TIMEOUT 1000
|
88
|
+
|
89
|
+
#define OBOE_SAMPLE_RESOLUTION 1000000
|
90
|
+
|
91
|
+
#define OBOE_MAX_TASK_ID_LEN 20
|
92
|
+
#define OBOE_MAX_OP_ID_LEN 8
|
93
|
+
#define OBOE_MAX_METADATA_PACK_LEN 512
|
94
|
+
|
95
|
+
#define XTR_CURRENT_VERSION 2
|
96
|
+
|
97
|
+
#define XTR_FLAGS_NOT_SAMPLED 0x0
|
98
|
+
#define XTR_FLAGS_SAMPLED 0x1
|
99
|
+
|
100
|
+
#define XTR_UDP_PORT 7831
|
101
|
+
|
102
|
+
#define OBOE_REPORTER_PROTOCOL_FILE "file"
|
103
|
+
#define OBOE_REPORTER_PROTOCOL_UDP "udp"
|
104
|
+
#define OBOE_REPORTER_PROTOCOL_SSL "ssl"
|
105
|
+
#define OBOE_REPORTER_PROTOCOL_NULL "null"
|
106
|
+
#define OBOE_REPORTER_PROTOCOL_LAMBDA "lambda"
|
107
|
+
|
108
|
+
/** Maximum reasonable length of an arguments string for configuring a reporter. */
|
109
|
+
#define OBOE_REPORTER_ARGS_SIZE 4000
|
110
|
+
|
111
|
+
#ifdef _WIN32
|
112
|
+
/// SRv1 bitwise value mask for the RUM_ENABLE flag.
|
113
|
+
#define SETTINGS_RUM_ENABLE_MASK 0x00000001
|
114
|
+
#endif
|
115
|
+
|
116
|
+
#ifndef HOST_NAME_MAX
|
117
|
+
#define HOST_NAME_MAX 256
|
118
|
+
#endif
|
119
|
+
|
120
|
+
#if !defined(AO_GETPID)
|
121
|
+
#if defined(_WIN32)
|
122
|
+
#define AO_GETPID GetCurrentProcessId
|
123
|
+
#else
|
124
|
+
#define AO_GETPID getpid
|
125
|
+
#endif
|
126
|
+
#endif
|
127
|
+
|
128
|
+
|
129
|
+
// structs
|
130
|
+
|
131
|
+
typedef struct oboe_ids {
|
132
|
+
uint8_t task_id[OBOE_MAX_TASK_ID_LEN];
|
133
|
+
uint8_t op_id[OBOE_MAX_OP_ID_LEN];
|
134
|
+
} oboe_ids_t;
|
135
|
+
|
136
|
+
typedef struct oboe_metadata {
|
137
|
+
uint8_t version;
|
138
|
+
oboe_ids_t ids;
|
139
|
+
size_t task_len;
|
140
|
+
size_t op_len;
|
141
|
+
uint8_t flags;
|
142
|
+
#ifdef _FUTURE_PLANS_
|
143
|
+
/* Can't add this without breaking the ABI, but someday... */
|
144
|
+
int auto_delete;
|
145
|
+
#endif /* _FUTURE_PLANS_ */
|
146
|
+
} oboe_metadata_t;
|
147
|
+
|
148
|
+
typedef struct oboe_event {
|
149
|
+
oboe_metadata_t metadata;
|
150
|
+
oboe_bson_buffer bbuf;
|
151
|
+
char * bb_str;
|
152
|
+
#ifdef _FUTURE_PLANS_
|
153
|
+
/* Can't add this without breaking the ABI, but someday... */
|
154
|
+
int auto_delete;
|
155
|
+
#endif /* _FUTURE_PLANS_ */
|
156
|
+
} oboe_event_t;
|
157
|
+
|
158
|
+
typedef struct oboe_metric_tag {
|
159
|
+
char *key;
|
160
|
+
char *value;
|
161
|
+
} oboe_metric_tag_t;
|
162
|
+
|
163
|
+
typedef struct oboe_init_options {
|
164
|
+
int version; // the version of this structure (currently on version 12)
|
165
|
+
const char *hostname_alias; // optional hostname alias
|
166
|
+
int log_level; // level at which log messages will be written to log file (0-6)
|
167
|
+
// use LOGLEVEL_DEFAULT for default log level
|
168
|
+
const char *log_file_path; // file name including path for log file
|
169
|
+
int max_transactions; // maximum number of transaction names to track
|
170
|
+
int max_flush_wait_time; // maximum wait time for flushing data before terminating in milli seconds
|
171
|
+
int events_flush_interval; // events flush timeout in seconds (threshold for batching messages before sending off)
|
172
|
+
int max_request_size_bytes; // limit max RPC request size
|
173
|
+
|
174
|
+
const char *reporter; // the reporter to be used (ssl, upd, file, null, lambda)
|
175
|
+
const char *host; // collector endpoint (reporter=ssl), udp address (reporter=udp), or file path (reporter=file)
|
176
|
+
const char *service_key; // the service key
|
177
|
+
const char *trusted_path; // path to the SSL certificate (only for ssl)
|
178
|
+
int buffer_size; // size of the message buffer
|
179
|
+
int trace_metrics; // flag indicating if trace metrics reporting should be enabled (default) or disabled
|
180
|
+
int histogram_precision; // the histogram precision (only for ssl)
|
181
|
+
double token_bucket_capacity; // custom token bucket capacity
|
182
|
+
double token_bucket_rate; // custom token bucket rate
|
183
|
+
int file_single; // use single files in file reporter for each event
|
184
|
+
|
185
|
+
int ec2_metadata_timeout; // EC2 metadata timeout in milliseconds
|
186
|
+
const char *proxy; // HTTP proxy address and port to be used for the gRPC connection
|
187
|
+
int stdout_clear_nonblocking; // flag indicating if the O_NONBLOCK flag on stdout should be cleared,
|
188
|
+
// only used in lambda reporter (off=0, on=1, default off)
|
189
|
+
int is_grpc_clean_hack_enabled; // flag indicating if custom grpc clean hack enabled (default 0)
|
190
|
+
} oboe_init_options_t;
|
191
|
+
|
192
|
+
typedef struct oboe_span_params {
|
193
|
+
int version; // the version of this structure
|
194
|
+
const char *service; // custom service name (will be NULL or empty if default service name should be used)
|
195
|
+
const char *transaction; // transaction name (will be NULL or empty if url given)
|
196
|
+
const char *url; // the raw url which will be processed and used as transaction name
|
197
|
+
// (if transaction is NULL or empty)
|
198
|
+
const char *domain; // a domain to be prepended to the transaction name (can be NULL)
|
199
|
+
int64_t duration; // the duration of the span in micro seconds (usec)
|
200
|
+
int status; // HTTP status code (e.g. 200, 500, ...)
|
201
|
+
const char *method; // HTTP method (e.g. GET, POST, ...)
|
202
|
+
int has_error; // boolean flag whether this transaction contains an error (1) or not (0)
|
203
|
+
int do_metrics; // boolean flag whether a (HTTP) span should be sent (1) or not (0)
|
204
|
+
} oboe_span_params_t;
|
205
|
+
|
206
|
+
//
|
207
|
+
// oboe_get_tracing_decisions input and output structures
|
208
|
+
//
|
209
|
+
typedef struct oboe_tracing_decisions_in {
|
210
|
+
int version; // the version of this structure
|
211
|
+
const char *service_name; // custom service name
|
212
|
+
const char *in_xtrace; // existing X-Trace from passed in HTTP header
|
213
|
+
int custom_sample_rate; // custom sample rate
|
214
|
+
int custom_tracing_mode; // custom tracing mode
|
215
|
+
|
216
|
+
// v2
|
217
|
+
int custom_trigger_mode; // custom trigger mode
|
218
|
+
int request_type; // the request type: OBOE_REQUEST_TYPE_REGULAR, OBOE_REQUEST_TYPE_TRIGGER
|
219
|
+
const char *header_options; // X-Trace-Options HTTP header value
|
220
|
+
const char *header_signature; // X-Trace-Options-Signature HTTP header value
|
221
|
+
time_t header_timestamp; // timestamp from X-Trace-Options header, converted to UNIX timestamp format
|
222
|
+
} oboe_tracing_decisions_in_t;
|
223
|
+
|
224
|
+
typedef struct oboe_tracing_decisions_out {
|
225
|
+
int version;
|
226
|
+
int sample_rate;
|
227
|
+
int sample_source;
|
228
|
+
int do_sample;
|
229
|
+
int do_metrics;
|
230
|
+
|
231
|
+
// v2
|
232
|
+
int request_provisioned;
|
233
|
+
int auth_status;
|
234
|
+
const char *auth_message;
|
235
|
+
const char *status_message;
|
236
|
+
|
237
|
+
// v3
|
238
|
+
double token_bucket_rate;
|
239
|
+
double token_bucket_capacity;
|
240
|
+
} oboe_tracing_decisions_out_t;
|
241
|
+
|
242
|
+
typedef struct oboe_internal_stats {
|
243
|
+
int version;
|
244
|
+
int reporters_initialized;
|
245
|
+
int event_queue_free;
|
246
|
+
int collector_response_ok;
|
247
|
+
int collector_response_try_later;
|
248
|
+
int collector_response_limit_exceeded;
|
249
|
+
} oboe_internal_stats_t;
|
250
|
+
|
251
|
+
#define OBOE_SPAN_PARAMS_VERSION 2 // version of oboe_span_params_t
|
252
|
+
#define OBOE_TRANSACTION_NAME_MAX_LENGTH 255 // max allowed length for transaction name
|
253
|
+
|
254
|
+
#ifndef MIN
|
255
|
+
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
256
|
+
#endif
|
257
|
+
#ifndef MAX
|
258
|
+
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
259
|
+
#endif
|
260
|
+
|
261
|
+
// oboe_metadata
|
262
|
+
|
263
|
+
#ifdef _FUTURE_PLANS_
|
264
|
+
oboe_metadata_t *oboe_metadata_new();
|
265
|
+
#endif /* _FUTURE_PLANS_ */
|
266
|
+
int oboe_metadata_init (oboe_metadata_t *);
|
267
|
+
int oboe_metadata_destroy (oboe_metadata_t *);
|
268
|
+
|
269
|
+
int oboe_metadata_is_valid (const oboe_metadata_t *);
|
270
|
+
|
271
|
+
int oboe_metadata_copy (oboe_metadata_t *, const oboe_metadata_t *);
|
272
|
+
|
273
|
+
int oboe_metadata_random (oboe_metadata_t *);
|
274
|
+
|
275
|
+
int oboe_metadata_set_lengths (oboe_metadata_t *, size_t, size_t);
|
276
|
+
int oboe_metadata_create_event (const oboe_metadata_t *, oboe_event_t *);
|
277
|
+
|
278
|
+
int oboe_metadata_tostr (const oboe_metadata_t *, char *, size_t);
|
279
|
+
int oboe_metadata_fromstr (oboe_metadata_t *, const char *, size_t);
|
280
|
+
|
281
|
+
int oboe_metadata_is_sampled(oboe_metadata_t *md);
|
282
|
+
|
283
|
+
// oboe_event
|
284
|
+
|
285
|
+
#ifdef _FUTURE_PLANS_
|
286
|
+
oboe_event_t *oboe_event_new(const oboe_metadata_t *);
|
287
|
+
#endif /* _FUTURE_PLANS_ */
|
288
|
+
int oboe_event_init (oboe_event_t *, const oboe_metadata_t *, const uint8_t* event_op_id);
|
289
|
+
int oboe_event_destroy (oboe_event_t *);
|
290
|
+
|
291
|
+
int oboe_event_add_info (oboe_event_t *, const char *, const char *);
|
292
|
+
int oboe_event_add_info_binary (oboe_event_t *, const char *, const char *, size_t);
|
293
|
+
int oboe_event_add_info_int64 (oboe_event_t *, const char *, const int64_t);
|
294
|
+
int oboe_event_add_info_double (oboe_event_t *, const char *, const double);
|
295
|
+
int oboe_event_add_info_bool (oboe_event_t *, const char *, const int);
|
296
|
+
int oboe_event_add_info_bson (oboe_event_t *, const char *key, const oboe_bson *val);
|
297
|
+
int oboe_event_add_edge (oboe_event_t *, const oboe_metadata_t *);
|
298
|
+
int oboe_event_add_edge_fromstr(oboe_event_t *, const char *, size_t);
|
299
|
+
|
300
|
+
int oboe_event_add_timestamp(oboe_event_t *evt);
|
301
|
+
int oboe_event_add_hostname(oboe_event_t *evt);
|
302
|
+
|
303
|
+
/**
|
304
|
+
* Send event message using the default reporter.
|
305
|
+
*
|
306
|
+
* @param channel the channel to send out this message (OBOE_SEND_EVENT or OBOE_SEND_STATUS)
|
307
|
+
* @param evt The event message.
|
308
|
+
* @param md The X-Trace metadata.
|
309
|
+
* @return Length of message sent in bytes on success; otherwise -1.
|
310
|
+
*/
|
311
|
+
int oboe_event_send(int channel, oboe_event_t *evt, oboe_metadata_t *md);
|
312
|
+
|
313
|
+
|
314
|
+
// oboe_context
|
315
|
+
|
316
|
+
oboe_metadata_t *oboe_context_get();
|
317
|
+
int oboe_context_set(oboe_metadata_t *);
|
318
|
+
int oboe_context_set_fromstr(const char *, size_t);
|
319
|
+
|
320
|
+
int oboe_context_clear();
|
321
|
+
|
322
|
+
int oboe_context_is_valid();
|
323
|
+
|
324
|
+
int oboe_context_is_sampled();
|
325
|
+
|
326
|
+
// oboe_reporter
|
327
|
+
|
328
|
+
struct oboe_reporter;
|
329
|
+
|
330
|
+
/* TODO: Move struct oboe_reporter to private header. */
|
331
|
+
typedef int (*reporter_ready)(void *);
|
332
|
+
typedef int (*reporter_is_within_limit)(void *, const char *, const char *);
|
333
|
+
typedef ssize_t (*reporter_send)(void *, int, const char *, size_t);
|
334
|
+
typedef int (*reporter_send_span)(void *, const char *, const char *, const int64_t, const int);
|
335
|
+
typedef int (*reporter_send_http_span)(void *, const char *, const char *, const int64_t, const int, const char *, const int);
|
336
|
+
typedef int (*reporter_add_custom_metric)(void *, const char *, const double, const int, const int, const char *, const int, const oboe_metric_tag_t*, const size_t);
|
337
|
+
typedef int (*reporter_destroy)(void *);
|
338
|
+
typedef int (*reporter_server_response)(void *);
|
339
|
+
typedef const char* (*reporter_server_warning)(void *);
|
340
|
+
typedef int (*reporter_profiling_interval)(void *);
|
341
|
+
typedef int (*reporter_flush)(void *);
|
342
|
+
typedef struct oboe_reporter {
|
343
|
+
void * descriptor; /*!< Reporter's context. */
|
344
|
+
reporter_ready eventReady; /*!< Check if the reporter is ready for another trace. */
|
345
|
+
reporter_ready profilingReady; /*!< Check if the reporter is ready for another profiling snapshot. */
|
346
|
+
reporter_ready statusReady; /*!< Check if the reporter is ready for another status. */
|
347
|
+
reporter_ready spanReady; /*!< Check if the reporter is ready for another span. */
|
348
|
+
reporter_is_within_limit isWithinLimit;
|
349
|
+
reporter_ready customMetricsReady; /*!< Check if the reporter is ready for another custom metric. */
|
350
|
+
reporter_send send; /*!< Send a trace event message. */
|
351
|
+
reporter_send_span sendSpan;
|
352
|
+
reporter_send_http_span sendHttpSpan;
|
353
|
+
reporter_add_custom_metric addCustomMetric;
|
354
|
+
reporter_destroy destroy; /*!< Destroy the reporter - release all resources. */
|
355
|
+
reporter_server_response getServerResponse;
|
356
|
+
reporter_profiling_interval profilingInterval;
|
357
|
+
reporter_server_warning getServerWarning;
|
358
|
+
reporter_flush flush;
|
359
|
+
} oboe_reporter_t;
|
360
|
+
|
361
|
+
/**
|
362
|
+
* Check if the reporter is ready to send.
|
363
|
+
*
|
364
|
+
* The concept of 'ready' is depends on the specific reporter being used.
|
365
|
+
*
|
366
|
+
* @param rep The reporter context (optional).
|
367
|
+
* @return Non-zero if the reporter is ready to send.
|
368
|
+
*/
|
369
|
+
int oboe_reporter_is_ready(oboe_reporter_t *rep); /* DEPRECATE: Use oboe_is_ready() */
|
370
|
+
|
371
|
+
/**
|
372
|
+
* Release any resources held by the reporter context.
|
373
|
+
*
|
374
|
+
* @param rep Pointer to a reporter context structure.
|
375
|
+
* @return Zero on success; otherwise non-zero to indicate an error.
|
376
|
+
*/
|
377
|
+
int oboe_reporter_destroy(oboe_reporter_t *rep); /* DEPRECATE: Use oboe_shutdown() */
|
378
|
+
|
379
|
+
ssize_t oboe_reporter_udp_send(void *desc, const char *data, size_t len); /* DEPRECATE - Use oboe_event_send() */
|
380
|
+
|
381
|
+
|
382
|
+
/* Oboe initialization and reporter management */
|
383
|
+
|
384
|
+
/**
|
385
|
+
* Initialize the Oboe subsystems.
|
386
|
+
*
|
387
|
+
* Should be called before any other oboe_* functions.
|
388
|
+
* However, in order to make the library easier to work with, checks
|
389
|
+
* are in place so that it will be called by any of the other functions
|
390
|
+
* that depend on it.
|
391
|
+
*
|
392
|
+
* Besides initializing the oboe library, this will also initialize a
|
393
|
+
* reporter based on the values of environment variables, configuration
|
394
|
+
* file options, and whether a tracelyzer is installed.
|
395
|
+
*
|
396
|
+
* @param options init options
|
397
|
+
* @return One of the OBOE_INIT_* macros
|
398
|
+
*/
|
399
|
+
int oboe_init(oboe_init_options_t* options);
|
400
|
+
|
401
|
+
/**
|
402
|
+
* Initialize the Oboe subsytems using a specific reporter configuration.
|
403
|
+
*
|
404
|
+
* This should be called before any other oboe_* functions butm may also be
|
405
|
+
* used to change or re-initialize the current reporter. To reconnect the
|
406
|
+
* reporter use oboe_disconnect() and oboe_reconnect() instead.
|
407
|
+
*
|
408
|
+
* @param protocol One of OBOE_REPORTER_PROTOCOL_FILE, OBOE_REPORTER_PROTOCOL_UDP,
|
409
|
+
* or OBOE_REPORTER_PROTOCOL_SSL.
|
410
|
+
* @param args A configuration string for the specified protocol (protocol dependent syntax).
|
411
|
+
* @return One of the OBOE_INIT_* macros
|
412
|
+
*/
|
413
|
+
int oboe_init_reporter(const char *protocol, oboe_init_options_t *options);
|
414
|
+
|
415
|
+
/**
|
416
|
+
* returns one of these:
|
417
|
+
* - OBOE_INIT_OPTIONS_SET_DEFAULTS_OK
|
418
|
+
* - OBOE_INIT_OPTIONS_SET_DEFAULTS_WRONG_VERSION
|
419
|
+
*/
|
420
|
+
int oboe_init_options_set_defaults(oboe_init_options_t *options);
|
421
|
+
|
422
|
+
/**
|
423
|
+
* Disconnect or shut down the Oboe reporter, but allow it to be reconnect()ed.
|
424
|
+
*/
|
425
|
+
void oboe_reporter_disconnect(); /* TODO: Need implementation. */
|
426
|
+
|
427
|
+
/**
|
428
|
+
* Reconnect or restart the Oboe reporter.
|
429
|
+
*/
|
430
|
+
void oboe_reporter_reconnect(); /* TODO: Need implementation. */
|
431
|
+
|
432
|
+
/**
|
433
|
+
* tell reporter to flush all messages that are currently buffered
|
434
|
+
*/
|
435
|
+
int oboe_reporter_flush();
|
436
|
+
|
437
|
+
/**
|
438
|
+
* get the reporter type used
|
439
|
+
*/
|
440
|
+
const char* oboe_get_reporter_type();
|
441
|
+
|
442
|
+
/**
|
443
|
+
* Check if system is AWS Lambda
|
444
|
+
*/
|
445
|
+
int oboe_is_lambda();
|
446
|
+
|
447
|
+
/**
|
448
|
+
* Check if oboe is ready
|
449
|
+
*
|
450
|
+
* Ready means reporters are ready and settings have been received
|
451
|
+
*
|
452
|
+
* @param timeout a timeout value (in milli seconds) to wait until ready, zero means don't wait
|
453
|
+
* @return server response code (e.g. OBOE_SERVER_RESPONSE_OK)
|
454
|
+
*/
|
455
|
+
int oboe_is_ready(const uint32_t timeout);
|
456
|
+
|
457
|
+
/**
|
458
|
+
* Send a raw message using the current reporter.
|
459
|
+
*
|
460
|
+
* Use oboe_event_send() unless you are handling all the details of constructing
|
461
|
+
* the messages for a valid trace.
|
462
|
+
*
|
463
|
+
* @param channel the channel to send out this message (OBOE_SEND_EVENT or OBOE_SEND_STATUS)
|
464
|
+
* @param data A BSON-encoded event message.
|
465
|
+
* @param len The length of the message data in bytes.
|
466
|
+
* @return Length of message sent in bytes on success; otherwise -1.
|
467
|
+
*/
|
468
|
+
int oboe_raw_send(int channel, const char *data, size_t len);
|
469
|
+
|
470
|
+
/**
|
471
|
+
* Shut down the Oboe subsystems.
|
472
|
+
*
|
473
|
+
* This may be called on exit in order to release any resources held by
|
474
|
+
* the Oboe library including any child threads.
|
475
|
+
*/
|
476
|
+
void oboe_shutdown();
|
477
|
+
|
478
|
+
|
479
|
+
// Settings interface
|
480
|
+
|
481
|
+
#define OBOE_SETTINGS_VERSION 1
|
482
|
+
#define OBOE_SETTINGS_MAGIC_NUMBER 0x6f626f65
|
483
|
+
#define OBOE_SETTINGS_TYPE_DEFAULT_SAMPLE_RATE 0
|
484
|
+
#define OBOE_SETTINGS_TYPE_LAYER_SAMPLE_RATE 1
|
485
|
+
#define OBOE_SETTINGS_TYPE_LAYER_APP_SAMPLE_RATE 2
|
486
|
+
#define OBOE_SETTINGS_TYPE_LAYER_HTTPHOST_SAMPLE_RATE 3
|
487
|
+
#define OBOE_SETTINGS_TYPE_CONFIG_STRING 4
|
488
|
+
#define OBOE_SETTINGS_TYPE_CONFIG_INT 5
|
489
|
+
#define OBOE_SETTINGS_FLAG_OK 0x0
|
490
|
+
#define OBOE_SETTINGS_FLAG_INVALID 0x1
|
491
|
+
#define OBOE_SETTINGS_FLAG_OVERRIDE 0x2
|
492
|
+
#define OBOE_SETTINGS_FLAG_SAMPLE_START 0x4
|
493
|
+
#define OBOE_SETTINGS_FLAG_SAMPLE_THROUGH 0x8
|
494
|
+
#define OBOE_SETTINGS_FLAG_SAMPLE_THROUGH_ALWAYS 0x10
|
495
|
+
#define OBOE_SETTINGS_FLAG_TRIGGERED_TRACE 0x20
|
496
|
+
#define OBOE_SETTINGS_MAX_STRLEN 256
|
497
|
+
|
498
|
+
#define OBOE_SETTINGS_UNSET -1
|
499
|
+
|
500
|
+
// Value for "SampleSource" info key
|
501
|
+
// where was the sample rate specified? (oboe settings, config file, hard-coded default, etc)
|
502
|
+
#define OBOE_SAMPLE_RATE_SOURCE_CONTINUED -1
|
503
|
+
#define OBOE_SAMPLE_RATE_SOURCE_FILE 1
|
504
|
+
#define OBOE_SAMPLE_RATE_SOURCE_DEFAULT 2
|
505
|
+
#define OBOE_SAMPLE_RATE_SOURCE_OBOE 3
|
506
|
+
#define OBOE_SAMPLE_RATE_SOURCE_LAST_OBOE 4
|
507
|
+
#define OBOE_SAMPLE_RATE_SOURCE_DEFAULT_MISCONFIGURED 5
|
508
|
+
#define OBOE_SAMPLE_RATE_SOURCE_OBOE_DEFAULT 6
|
509
|
+
#define OBOE_SAMPLE_RATE_SOURCE_CUSTOM 7
|
510
|
+
|
511
|
+
#define OBOE_SAMPLE_RESOLUTION 1000000
|
512
|
+
|
513
|
+
// Used to convert to settings flags:
|
514
|
+
#define OBOE_TRACE_NEVER 0 // deprecated: do not use, only here for backward compatibility
|
515
|
+
#define OBOE_TRACE_ALWAYS 1 // deprecated: do not use, only here for backward compatibility
|
516
|
+
#define OBOE_TRACE_DISABLED 0
|
517
|
+
#define OBOE_TRACE_ENABLED 1
|
518
|
+
|
519
|
+
#define OBOE_SEND_EVENT 0
|
520
|
+
#define OBOE_SEND_STATUS 1
|
521
|
+
#define OBOE_SEND_PROFILING 2
|
522
|
+
|
523
|
+
// these codes are used by oboe_is_ready()
|
524
|
+
#define OBOE_SERVER_RESPONSE_UNKNOWN 0
|
525
|
+
#define OBOE_SERVER_RESPONSE_OK 1
|
526
|
+
#define OBOE_SERVER_RESPONSE_TRY_LATER 2
|
527
|
+
#define OBOE_SERVER_RESPONSE_LIMIT_EXCEEDED 3
|
528
|
+
#define OBOE_SERVER_RESPONSE_INVALID_API_KEY 4 // deprecated
|
529
|
+
#define OBOE_SERVER_RESPONSE_CONNECT_ERROR 5
|
530
|
+
|
531
|
+
// these codes are used by oboe_span() and oboe_http_span()
|
532
|
+
#define OBOE_SPAN_NULL_PARAMS -1
|
533
|
+
#define OBOE_SPAN_NULL_BUFFER -2
|
534
|
+
#define OBOE_SPAN_INVALID_VERSION -3
|
535
|
+
#define OBOE_SPAN_NO_REPORTER -4
|
536
|
+
#define OBOE_SPAN_NOT_READY -5
|
537
|
+
|
538
|
+
// these codes are returned by oboe_sample_layer_custom(), oboe_tracing_decisions(),
|
539
|
+
// oboe_reporter_is_ready(), and referenced in settings_messages.c (to convert
|
540
|
+
// error codes to messages.)
|
541
|
+
//
|
542
|
+
// they are structured such that codes that are <= 0 are successful, i.e., no
|
543
|
+
// error status needs to be reported to the user, while codes > 0 are errors that
|
544
|
+
// need to be reported.
|
545
|
+
|
546
|
+
#define OBOE_TRACING_DECISIONS_FAILED_AUTH -5
|
547
|
+
#define OBOE_TRACING_DECISIONS_TRIGGERED_TRACE_EXHAUSTED -4
|
548
|
+
#define OBOE_TRACING_DECISIONS_TRIGGERED_TRACE_DISABLED -3
|
549
|
+
#define OBOE_TRACING_DECISIONS_TRACING_DISABLED -2
|
550
|
+
#define OBOE_TRACING_DECISIONS_XTRACE_NOT_SAMPLED -1
|
551
|
+
#define OBOE_TRACING_DECISIONS_OK 0
|
552
|
+
#define OBOE_TRACING_DECISIONS_NULL_OUT 1
|
553
|
+
#define OBOE_TRACING_DECISIONS_NO_CONFIG 2
|
554
|
+
#define OBOE_TRACING_DECISIONS_REPORTER_NOT_READY 3
|
555
|
+
#define OBOE_TRACING_DECISIONS_NO_VALID_SETTINGS 4
|
556
|
+
#define OBOE_TRACING_DECISIONS_QUEUE_FULL 5
|
557
|
+
#define OBOE_TRACING_DECISIONS_BAD_ARG 6
|
558
|
+
|
559
|
+
// convert above codes into const char* messages.
|
560
|
+
const char* oboe_get_tracing_decisions_message(int code);
|
561
|
+
|
562
|
+
#define OBOE_TRACING_DECISIONS_AUTH_NOT_CHECKED -2
|
563
|
+
#define OBOE_TRACING_DECISIONS_AUTH_NOT_PRESENT -1
|
564
|
+
#define OBOE_TRACING_DECISIONS_AUTH_OK 0
|
565
|
+
#define OBOE_TRACING_DECISIONS_AUTH_NO_SIG_KEY 1
|
566
|
+
#define OBOE_TRACING_DECISIONS_AUTH_INVALID_SIG 2
|
567
|
+
#define OBOE_TRACING_DECISIONS_AUTH_BAD_TIMESTAMP 3
|
568
|
+
|
569
|
+
// convert above codes into const char* messages.
|
570
|
+
const char* oboe_get_tracing_decisions_auth_message (int code);
|
571
|
+
|
572
|
+
#define OBOE_REQUEST_TYPE_NONE -1
|
573
|
+
#define OBOE_REQUEST_TYPE_REGULAR 0
|
574
|
+
#define OBOE_REQUEST_TYPE_TRIGGER 1
|
575
|
+
|
576
|
+
#define OBOE_INIT_OPTIONS_SET_DEFAULTS_OK 0
|
577
|
+
#define OBOE_INIT_OPTIONS_SET_DEFAULTS_WRONG_VERSION 1
|
578
|
+
|
579
|
+
//
|
580
|
+
// these codes are returned by oboe_init(), oboe_init_reporter(), _oboe_create_reporter()
|
581
|
+
//
|
582
|
+
#define OBOE_INIT_ALREADY_INIT -1
|
583
|
+
#define OBOE_INIT_OK 0
|
584
|
+
#define OBOE_INIT_WRONG_VERSION 1
|
585
|
+
#define OBOE_INIT_INVALID_PROTOCOL 2
|
586
|
+
#define OBOE_INIT_NULL_REPORTER 3
|
587
|
+
#define OBOE_INIT_DESC_ALLOC 4
|
588
|
+
#define OBOE_INIT_FILE_OPEN_LOG 5
|
589
|
+
#define OBOE_INIT_UDP_NO_SUPPORT 6
|
590
|
+
#define OBOE_INIT_UDP_OPEN 7
|
591
|
+
#define OBOE_INIT_SSL_CONFIG_AUTH 8
|
592
|
+
#define OBOE_INIT_SSL_LOAD_CERT 9
|
593
|
+
#define OBOE_INIT_SSL_REPORTER_CREATE 10
|
594
|
+
#define OBOE_INIT_SSL_MISSING_KEY 11
|
595
|
+
|
596
|
+
//
|
597
|
+
// these codes are returned by oboe_notifier_status()
|
598
|
+
//
|
599
|
+
#define OBOE_NOTIFIER_SHUTTING_DOWN -3
|
600
|
+
#define OBOE_NOTIFIER_INITIALIZING -2
|
601
|
+
#define OBOE_NOTIFIER_DISABLED -1
|
602
|
+
#define OBOE_NOTIFIER_OK 0
|
603
|
+
#define OBOE_NOTIFIER_SOCKET_PATH_TOO_LONG 1
|
604
|
+
#define OBOE_NOTIFIER_SOCKET_CREATE 2
|
605
|
+
#define OBOE_NOTIFIER_SOCKET_CONNECT 3
|
606
|
+
#define OBOE_NOTIFIER_SOCKET_WRITE_FULL 4
|
607
|
+
#define OBOE_NOTIFIER_SOCKET_WRITE_ERROR 5
|
608
|
+
#define OBOE_NOTIFIER_SHUTDOWN_TIMED_OUT 6
|
609
|
+
|
610
|
+
//
|
611
|
+
// these codes are used for testing the notifier using oboe_notifier_test()
|
612
|
+
//
|
613
|
+
#define OBOE_NOTIFIER_TEST_KEEPALIVE 0
|
614
|
+
#define OBOE_NOTIFIER_TEST_LOG 1
|
615
|
+
#define OBOE_NOTIFIER_TEST_REMOTE_WARNING 2
|
616
|
+
#define OBOE_NOTIFIER_TEST_REMOTE_CONFIG 3
|
617
|
+
|
618
|
+
//
|
619
|
+
// interval (in seconds) at which the notifier sends a keep-alive msg,
|
620
|
+
// note that a keep-alive is only sent if no other message made it through
|
621
|
+
// within the interval time
|
622
|
+
//
|
623
|
+
#define OBOE_NOTIFIER_KEEP_ALIVE_INTERVAL_SEC 10
|
624
|
+
|
625
|
+
//
|
626
|
+
// these codes are returned by oboe_custom_metric_summary() and oboe_custom_metric_increment()
|
627
|
+
//
|
628
|
+
#define OBOE_CUSTOM_METRICS_OK 0
|
629
|
+
#define OBOE_CUSTOM_METRICS_INVALID_COUNT 1
|
630
|
+
#define OBOE_CUSTOM_METRICS_INVALID_REPORTER 2
|
631
|
+
#define OBOE_CUSTOM_METRICS_TAG_LIMIT_EXCEEDED 3
|
632
|
+
#define OBOE_CUSTOM_METRICS_STOPPING 4
|
633
|
+
#define OBOE_CUSTOM_METRICS_QUEUE_LIMIT_EXCEEDED 5
|
634
|
+
|
635
|
+
//
|
636
|
+
// these codes are returned by oboe_reporter_flush()
|
637
|
+
//
|
638
|
+
#define OBOE_REPORTER_FLUSH_OK 0
|
639
|
+
#define OBOE_REPORTER_FLUSH_METRIC_ERROR 1
|
640
|
+
#define OBOE_REPORTER_FLUSH_BAD_UTF8 2
|
641
|
+
#define OBOE_REPORTER_FLUSH_NO_REPORTER 3
|
642
|
+
#define OBOE_REPORTER_FLUSH_REPORTER_NOT_READY 4
|
643
|
+
|
644
|
+
// token buckets
|
645
|
+
enum TOKEN_BUCKETS {
|
646
|
+
TOKEN_BUCKET_SAMPLING, // for normal requests
|
647
|
+
TOKEN_BUCKET_TT_RELAXED, // for triggered traces initiated by Pingdom and
|
648
|
+
// other trusted sources (relaxed settings)
|
649
|
+
TOKEN_BUCKET_TT_STRICT, // for triggered traces initiated by CLI and
|
650
|
+
// other untrusted sources (strict settings)
|
651
|
+
TOKEN_BUCKET_COUNT // IMPORTANT NOTE: this must be the last element
|
652
|
+
// inside the enum
|
653
|
+
};
|
654
|
+
|
655
|
+
typedef struct {
|
656
|
+
uint32_t magic;
|
657
|
+
uint32_t timestamp;
|
658
|
+
uint16_t type;
|
659
|
+
uint16_t flags;
|
660
|
+
uint32_t value;
|
661
|
+
uint32_t ttl;
|
662
|
+
uint32_t _pad;
|
663
|
+
char layer[OBOE_SETTINGS_MAX_STRLEN]; // Flawfinder: ignore
|
664
|
+
double bucket_capacity[TOKEN_BUCKET_COUNT];
|
665
|
+
double bucket_rate_per_sec[TOKEN_BUCKET_COUNT];
|
666
|
+
char signature_key[OBOE_SETTINGS_MAX_STRLEN]; // Flawfinder: ignore
|
667
|
+
} oboe_settings_t;
|
668
|
+
|
669
|
+
typedef struct {
|
670
|
+
float available;
|
671
|
+
double capacity;
|
672
|
+
double rate_per_usec; // time is usecs from gettimeofday
|
673
|
+
struct timeval last_check;
|
674
|
+
} token_bucket_t;
|
675
|
+
|
676
|
+
|
677
|
+
typedef struct {
|
678
|
+
char name[OBOE_SETTINGS_MAX_STRLEN]; // Flawfinder: ignore
|
679
|
+
volatile uint32_t request_count; // all the requests that came through this layer
|
680
|
+
volatile uint32_t exhaustion_count; // # of times the token bucket limiting caused a trace to not occur
|
681
|
+
volatile uint32_t trace_count; // # of traces that were sent (includes "enabled" or "through" traces)
|
682
|
+
volatile uint32_t sample_count; // # of traces that caused a random coin-flip (not "through" traces)
|
683
|
+
volatile uint32_t through_count; // # of through traces
|
684
|
+
volatile uint32_t through_ignored_count; // # of new requests, that are rejected due to start_always_flag == 0
|
685
|
+
// that have through_always_flag == 1
|
686
|
+
volatile uint32_t triggered_count; // # of triggered traces
|
687
|
+
volatile uint32_t last_used_sample_rate;
|
688
|
+
volatile uint32_t last_used_sample_source;
|
689
|
+
|
690
|
+
volatile uint8_t used;
|
691
|
+
} entry_layer_t;
|
692
|
+
|
693
|
+
// Current settings configuration:
|
694
|
+
typedef struct {
|
695
|
+
int tracing_mode; // pushed from server, override from config file
|
696
|
+
int sample_rate; // pushed from server, override from config file
|
697
|
+
int trigger_mode; // pushed from server, override from config file
|
698
|
+
oboe_settings_t *settings; // cached settings, updated by tracelyzer (init to NULL)
|
699
|
+
int last_auto_sample_rate; // stores last known automatic sampling rate
|
700
|
+
uint16_t last_auto_flags; // stores last known flags associated with above
|
701
|
+
uint32_t last_auto_timestamp; // timestamp from last *settings lookup
|
702
|
+
uint32_t last_refresh; // last refresh time
|
703
|
+
token_bucket_t bucket[TOKEN_BUCKET_COUNT]; // token buckets for various tasks
|
704
|
+
} oboe_settings_cfg_t;
|
705
|
+
|
706
|
+
int oboe_settings_init_local();
|
707
|
+
oboe_settings_t* oboe_settings_get(uint16_t type, const char* layer, const char* arg);
|
708
|
+
oboe_settings_t* oboe_settings_get_layer_tracing_mode(const char* layer);
|
709
|
+
oboe_settings_t* oboe_settings_get_layer_sample_rate(const char* layer);
|
710
|
+
uint32_t oboe_settings_get_latest_timestamp(const char* layer);
|
711
|
+
int oboe_settings_get_value(oboe_settings_t *s, int *outval, unsigned short *outflags, uint32_t *outtimestamp);
|
712
|
+
entry_layer_t* oboe_settings_entry_layer_get(const char* name);
|
713
|
+
|
714
|
+
oboe_settings_cfg_t* oboe_settings_cfg_get();
|
715
|
+
void oboe_settings_cfg_init(oboe_settings_cfg_t *cfg);
|
716
|
+
|
717
|
+
void oboe_settings_set(int sample_rate, int tracing_mode, int trigger_mode);
|
718
|
+
void oboe_settings_rate_set(int sample_rate);
|
719
|
+
void oboe_settings_mode_set(int tracing_mode);
|
720
|
+
void oboe_settings_trigger_set(int trigger_mode);
|
721
|
+
|
722
|
+
int oboe_rand_get_value();
|
723
|
+
|
724
|
+
/**
|
725
|
+
* Convert a tracing mode to a printable string.
|
726
|
+
*/
|
727
|
+
const char *oboe_tracing_mode_to_string(int tracing_mode);
|
728
|
+
|
729
|
+
/**
|
730
|
+
* Check if sampling is enabled.
|
731
|
+
*
|
732
|
+
* @param cfg Optional pointer to the settings configuration for the current
|
733
|
+
* thread, as an optimization to avoid retrieving it. May be NULL.
|
734
|
+
* @return Non-zero if sampling is now enabled.
|
735
|
+
*/
|
736
|
+
int oboe_sample_is_enabled(oboe_settings_cfg_t *cfg);
|
737
|
+
|
738
|
+
/**
|
739
|
+
* Check if this request should be sampled.
|
740
|
+
*
|
741
|
+
* Checks for sample rate flags and settings for the specified service, considers
|
742
|
+
* the current tracing mode and any special features in the X-Trace
|
743
|
+
* headers, and, if appropriate, rolls the virtual dice to
|
744
|
+
* decide if this request should be sampled.
|
745
|
+
*
|
746
|
+
* This is designed to be called once per request.
|
747
|
+
*
|
748
|
+
* @param in Struct containing all params to help making a tracing decision
|
749
|
+
* @param out Struct containing all params that get set during decision making
|
750
|
+
*/
|
751
|
+
int oboe_tracing_decisions(oboe_tracing_decisions_in_t *in, oboe_tracing_decisions_out_t *out);
|
752
|
+
|
753
|
+
/* Oboe configuration interface. */
|
754
|
+
|
755
|
+
/**
|
756
|
+
* Check if the Oboe library is compatible with a given version.revision.
|
757
|
+
*
|
758
|
+
* This will succeed if the library is at least as recent as specified and if no
|
759
|
+
* definitions have been removed since that revision.
|
760
|
+
*
|
761
|
+
* @param version The library's version number which increments every time the API changes.
|
762
|
+
* @param revision The revision of the current version of the library.
|
763
|
+
* @return Non-zero if the Oboe library is considered compatible with the specified revision.
|
764
|
+
*/
|
765
|
+
extern int oboe_config_check_version(int version, int revision);
|
766
|
+
|
767
|
+
/**
|
768
|
+
* Get the Oboe library version number.
|
769
|
+
*
|
770
|
+
* This number increments whenever the API is changed.
|
771
|
+
*
|
772
|
+
* @return The library's version number or -1 if the version is not known.
|
773
|
+
*/
|
774
|
+
extern int oboe_config_get_version();
|
775
|
+
|
776
|
+
/**
|
777
|
+
* Prototype for a logger call-back function.
|
778
|
+
*
|
779
|
+
* A logging function of this form can be added to the logger chain using
|
780
|
+
* oboe_debug_log_add().
|
781
|
+
*
|
782
|
+
* @param context The context pointer that was registered in the call to
|
783
|
+
* oboe_debug_log_add(). Use it to pass the pointer-to-self for
|
784
|
+
* objects (ie. "this" in C++) or just a structure in C, May be
|
785
|
+
* NULL.
|
786
|
+
* @param module The module identifier as passed to oboe_debug_logger().
|
787
|
+
* @param level The diagnostic detail level as passed to oboe_debug_logger().
|
788
|
+
* @param source_name Name of the source file as passed to oboe_debug_logger().
|
789
|
+
* @param source_lineno Number of the line in the source file where message is
|
790
|
+
* logged from as passed to oboe_debug_logger().
|
791
|
+
* @param msg The formatted message produced from the format string and its
|
792
|
+
* arguments as passed to oboe_debug_logger().
|
793
|
+
*/
|
794
|
+
typedef void (*OboeDebugLoggerFcn)(void *context, int module, int level, const char *source_name, int source_lineno, const char *msg);
|
795
|
+
|
796
|
+
/**
|
797
|
+
* Get a printable name for a diagnostics logging level.
|
798
|
+
*/
|
799
|
+
extern const char *oboe_debug_log_level_name(int level);
|
800
|
+
|
801
|
+
/**
|
802
|
+
* Get a printable name for a diagnostics logging module identifier.
|
803
|
+
*/
|
804
|
+
extern const char *oboe_debug_module_name(int module);
|
805
|
+
|
806
|
+
/**
|
807
|
+
* Get the maximum logging detail level for a module or for all modules.
|
808
|
+
*
|
809
|
+
* This level applies to the stderr logger only. Added loggers get all messages
|
810
|
+
* below their registed detail level and need to do their own module-specific
|
811
|
+
* filtering.
|
812
|
+
*
|
813
|
+
* @param module One of the OBOE_MODULE_* values. Use OBOE_MODULE_ALL (-1) to
|
814
|
+
* get the overall maximum detail level.
|
815
|
+
* @return Maximum detail level value for module (or overall) where zero is the
|
816
|
+
* lowest and higher values generate more detailed log messages.
|
817
|
+
*/
|
818
|
+
extern int oboe_debug_log_level_get(int module);
|
819
|
+
|
820
|
+
/**
|
821
|
+
* Set the maximum logging detail level for a module or for all modules.
|
822
|
+
*
|
823
|
+
* This level applies to the stderr logger only. Added loggers get all messages
|
824
|
+
* below their registered detail level and need to do their own module-specific
|
825
|
+
* filtering.
|
826
|
+
*
|
827
|
+
* @param module One of the OBOE_MODULE_* values. Use OBOE_MODULE_ALL to set
|
828
|
+
* the overall maximum detail level.
|
829
|
+
* @param newLevel Maximum detail level value where zero is the lowest and higher
|
830
|
+
* values generate more detailed log messages.
|
831
|
+
*/
|
832
|
+
extern void oboe_debug_log_level_set(int module, int newLevel);
|
833
|
+
|
834
|
+
/**
|
835
|
+
* Set the output stream for the default logger.
|
836
|
+
*
|
837
|
+
* @param newStream A valid, open FILE* stream or NULL to disable the default logger.
|
838
|
+
* @return Zero on success; otherwise an error code (normally from errno).
|
839
|
+
*/
|
840
|
+
extern int oboe_debug_log_to_stream(FILE *newStream);
|
841
|
+
|
842
|
+
/**
|
843
|
+
* If we're logging to a stream, flush it.
|
844
|
+
*
|
845
|
+
* @return Zero on success; otherwise an error code (normally from errno).
|
846
|
+
*/
|
847
|
+
extern int oboe_debug_log_flush();
|
848
|
+
|
849
|
+
/**
|
850
|
+
* Set the default logger to write to the specified file.
|
851
|
+
*
|
852
|
+
* A NULL or empty path name will disable the default logger.
|
853
|
+
*
|
854
|
+
* If the file exists then it will be opened in append mode.
|
855
|
+
*
|
856
|
+
* @param pathname The path name of the
|
857
|
+
* @return Zero on success; otherwise an error code (normally from errno).
|
858
|
+
*/
|
859
|
+
extern int oboe_debug_log_to_file(const char *pathname);
|
860
|
+
|
861
|
+
/**
|
862
|
+
* Add a logger that takes messages up to a given logging detail level.
|
863
|
+
*
|
864
|
+
* This adds the logger to a chain in order of the logging level. Log messages
|
865
|
+
* are passed to each logger down the chain until the remaining loggers only
|
866
|
+
* accept messages of a lower detail level.
|
867
|
+
*
|
868
|
+
* @return Zero on success, one if re-registered with the new logging level, and
|
869
|
+
* otherwise a negative value to indicate an error.
|
870
|
+
*/
|
871
|
+
extern int oboe_debug_log_add(OboeDebugLoggerFcn newLogger, void *context, int logLevel);
|
872
|
+
|
873
|
+
/**
|
874
|
+
* Remove a logger.
|
875
|
+
*
|
876
|
+
* Remove the logger from the message handling chain.
|
877
|
+
*
|
878
|
+
* @return Zero on success, one if it was not found, and otherwise a negative
|
879
|
+
* value to indicate an error.
|
880
|
+
*/
|
881
|
+
extern int oboe_debug_log_remove(OboeDebugLoggerFcn oldLogger, void *context);
|
882
|
+
|
883
|
+
/*
|
884
|
+
* Log the application's Oboe configuration.
|
885
|
+
*
|
886
|
+
* We use this to get a reasonable standard format between apps.
|
887
|
+
*
|
888
|
+
* @param module An OBOE_MODULE_* module identifier. Use zero for undefined.
|
889
|
+
* @param app_name Either NULL or a pointer to a string containing a name for
|
890
|
+
* the application - will prefix the log entry. Useful when multiple
|
891
|
+
* apps log to the same destination.
|
892
|
+
* @param trace_mode A string identifying the configured tracing mode, one of:
|
893
|
+
* "enabled", "disabled", "unset", or "undef" (for invalid values)
|
894
|
+
* Use the oboe_tracing_mode_to_string() function to convert from
|
895
|
+
* numeric values.
|
896
|
+
* @param sample_rate The configured sampling rate: -1 for unset or a
|
897
|
+
* integer fraction of 1000000.
|
898
|
+
* @param reporter_type String identifying the type of reporter configured:
|
899
|
+
* One of 'udp' (the default), 'ssl', or 'file'.
|
900
|
+
* @param reporter_args The string of comma-separated key=value settings
|
901
|
+
* used to initialize the reporter.
|
902
|
+
* @param extra: Either NULL or a pointer to a string to be appended to
|
903
|
+
* the log message and designed to include a few other
|
904
|
+
* configuration parameters of interest.
|
905
|
+
*/
|
906
|
+
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_INFO
|
907
|
+
# define OBOE_DEBUG_LOG_CONFIG(module, app_name, trace_mode, sample_rate, reporter_type, reporter_args, extra) \
|
908
|
+
{ \
|
909
|
+
oboe_debug_logger(module, OBOE_DEBUG_INFO, __FILE__, __LINE__, \
|
910
|
+
"%s Oboe config: tracing=%s, sampling=%d, reporter=('%s', '%s') %s", \
|
911
|
+
(app_name == NULL ? "" : app_name), \
|
912
|
+
trace_mode, \
|
913
|
+
sample_rate, \
|
914
|
+
(reporter_type == NULL ? "?" : reporter_type), \
|
915
|
+
(reporter_args == NULL ? "?" : reporter_args), \
|
916
|
+
(extra == NULL ? "" : extra)); \
|
917
|
+
}
|
918
|
+
#else
|
919
|
+
# define OBOE_DEBUG_LOG_CONFIG(module, app_name, trace_mode, sample_rate, reporter_type, reporter_args, extra) {}
|
920
|
+
#endif
|
921
|
+
|
922
|
+
/**
|
923
|
+
* Log a fatal error.
|
924
|
+
*/
|
925
|
+
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_FATAL
|
926
|
+
# define OBOE_DEBUG_LOG_FATAL(module, ...) \
|
927
|
+
{ \
|
928
|
+
oboe_debug_logger(module, OBOE_DEBUG_FATAL, __FILE__, __LINE__, __VA_ARGS__); \
|
929
|
+
}
|
930
|
+
#else
|
931
|
+
# define OBOE_DEBUG_LOG_FATAL(module, format_string, ...) {}
|
932
|
+
#endif
|
933
|
+
|
934
|
+
/**
|
935
|
+
* Log a recoverable error.
|
936
|
+
*
|
937
|
+
* Each message is limited in the number of times that it will be reported at the
|
938
|
+
* ERROR level after which it will be logged at the debug MEDIUM level.
|
939
|
+
*/
|
940
|
+
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_ERROR
|
941
|
+
# define OBOE_DEBUG_LOG_ERROR(module, ...) \
|
942
|
+
{ \
|
943
|
+
static int usage_counter = 0; \
|
944
|
+
int loglev = (++usage_counter <= MAX_DEBUG_MSG_COUNT ? OBOE_DEBUG_ERROR : OBOE_DEBUG_MEDIUM); \
|
945
|
+
oboe_debug_logger(module, loglev, __FILE__, __LINE__, __VA_ARGS__); \
|
946
|
+
}
|
947
|
+
#else
|
948
|
+
# define OBOE_DEBUG_LOG_ERROR(module, format_string, ...) {}
|
949
|
+
#endif
|
950
|
+
|
951
|
+
/**
|
952
|
+
* Log a warning.
|
953
|
+
*
|
954
|
+
* Each message is limited in the number of times that it will be reported at the
|
955
|
+
* WARNING level after which it will be logged at the debug MEDIUM level.
|
956
|
+
*/
|
957
|
+
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_WARNING
|
958
|
+
# define OBOE_DEBUG_LOG_WARNING(module, ...) \
|
959
|
+
{ \
|
960
|
+
static int usage_counter = 0; \
|
961
|
+
int loglev = (++usage_counter <= MAX_DEBUG_MSG_COUNT ? OBOE_DEBUG_WARNING : OBOE_DEBUG_MEDIUM); \
|
962
|
+
oboe_debug_logger(module, loglev, __FILE__, __LINE__, __VA_ARGS__); \
|
963
|
+
}
|
964
|
+
#else
|
965
|
+
# define OBOE_DEBUG_LOG_WARNING(module, format_string,...) {}
|
966
|
+
#endif
|
967
|
+
|
968
|
+
/**
|
969
|
+
* Log an informative message.
|
970
|
+
*
|
971
|
+
* Each message is limited in the number of times that it will be reported at the
|
972
|
+
* INFO level after which it will be logged at the debug MEDIUM level.
|
973
|
+
*/
|
974
|
+
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_INFO
|
975
|
+
# define OBOE_DEBUG_LOG_INFO(module, ...) \
|
976
|
+
{ \
|
977
|
+
static int usage_counter = 0; \
|
978
|
+
int loglev = (++usage_counter <= MAX_DEBUG_MSG_COUNT ? OBOE_DEBUG_INFO : OBOE_DEBUG_MEDIUM); \
|
979
|
+
oboe_debug_logger(module, loglev, __FILE__, __LINE__, __VA_ARGS__); \
|
980
|
+
}
|
981
|
+
#else
|
982
|
+
# define OBOE_DEBUG_LOG_INFO(module, format_string, ...) {}
|
983
|
+
#endif
|
984
|
+
|
985
|
+
/**
|
986
|
+
* Log a low-detail diagnostic message.
|
987
|
+
*/
|
988
|
+
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_LOW
|
989
|
+
# define OBOE_DEBUG_LOG_LOW(module, ...) \
|
990
|
+
{ \
|
991
|
+
oboe_debug_logger(module, OBOE_DEBUG_LOW, __FILE__, __LINE__, __VA_ARGS__); \
|
992
|
+
}
|
993
|
+
#else
|
994
|
+
# define OBOE_DEBUG_LOG_LOW(module, format_string, ...) {}
|
995
|
+
#endif
|
996
|
+
|
997
|
+
/**
|
998
|
+
* Log a medium-detail diagnostic message.
|
999
|
+
*/
|
1000
|
+
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_MEDIUM
|
1001
|
+
# define OBOE_DEBUG_LOG_MEDIUM(module, ...) \
|
1002
|
+
{ \
|
1003
|
+
oboe_debug_logger(module, OBOE_DEBUG_MEDIUM, __FILE__, __LINE__, __VA_ARGS__); \
|
1004
|
+
}
|
1005
|
+
#else
|
1006
|
+
# define OBOE_DEBUG_LOG_MEDIUM(module, ...) {}
|
1007
|
+
#endif
|
1008
|
+
|
1009
|
+
/**
|
1010
|
+
* Log a high-detail diagnostic message.
|
1011
|
+
*/
|
1012
|
+
#if OBOE_DEBUG_LEVEL >= OBOE_DEBUG_HIGH
|
1013
|
+
# define OBOE_DEBUG_LOG_HIGH(module, ...) \
|
1014
|
+
{ \
|
1015
|
+
oboe_debug_logger(module, OBOE_DEBUG_HIGH, __FILE__, __LINE__, __VA_ARGS__); \
|
1016
|
+
}
|
1017
|
+
#else
|
1018
|
+
# define OBOE_DEBUG_LOG_HIGH(module, format_string, ...) {}
|
1019
|
+
#endif
|
1020
|
+
|
1021
|
+
|
1022
|
+
/**
|
1023
|
+
* Low-level diagnostics logging function.
|
1024
|
+
*
|
1025
|
+
* This is normally used only by the OBOE_DEBUG_LOG_* function macros and not used directly.
|
1026
|
+
*
|
1027
|
+
* This function may be adapted to format and route diagnostic log messages as desired.
|
1028
|
+
*
|
1029
|
+
* @param module One of the numeric module identifiers defined in debug.h - used to control logging detail by module.
|
1030
|
+
* @param level Diagnostic detail level of this message - used to control logging volume by detail level.
|
1031
|
+
* @param source_name Name of the source file, if available, or another useful name, or NULL.
|
1032
|
+
* @param source_lineno Number of the line in the source file where message is logged from, if available, or zero.
|
1033
|
+
* @param format A C language printf format specification string.
|
1034
|
+
* @param args A variable argument list in VA_ARG format containing arguments for each argument specifier in the format.
|
1035
|
+
*/
|
1036
|
+
void oboe_debug_logger(int module, int level, const char *source_name, int source_lineno, const char *format, ...);
|
1037
|
+
|
1038
|
+
/**
|
1039
|
+
* Get the Oboe library revision number.
|
1040
|
+
*
|
1041
|
+
* This is the revision of the current version which is updated whenever
|
1042
|
+
* compatible changes are made to the API/ABI (ie. additions).
|
1043
|
+
*
|
1044
|
+
* @return The library's revision number or -1 if not known.
|
1045
|
+
*/
|
1046
|
+
extern int oboe_config_get_revision();
|
1047
|
+
|
1048
|
+
/*
|
1049
|
+
* Get the Oboe library version as a string.
|
1050
|
+
*
|
1051
|
+
* Returns the complete VERSION string or null
|
1052
|
+
*/
|
1053
|
+
const char* oboe_config_get_version_string();
|
1054
|
+
|
1055
|
+
// Span reporting
|
1056
|
+
|
1057
|
+
/*
|
1058
|
+
* generate a new general span
|
1059
|
+
*
|
1060
|
+
* @param buffer a char buffer where the final transaction name will be written to
|
1061
|
+
* @param buffer_length the length of the char buffer
|
1062
|
+
* @param params additional span parameters
|
1063
|
+
*
|
1064
|
+
* @return size of the final transaction name written to buffer
|
1065
|
+
* if an error occurs, these values will be returned:
|
1066
|
+
* - OBOE_SPAN_NULL_PARAMS
|
1067
|
+
* - OBOE_SPAN_NULL_BUFFER
|
1068
|
+
* - OBOE_SPAN_INVALID_VERSION
|
1069
|
+
* - OBOE_SPAN_NO_REPORTER
|
1070
|
+
* - OBOE_SPAN_NOT_READY
|
1071
|
+
*/
|
1072
|
+
int oboe_span(char *buffer, const uint16_t buffer_length, oboe_span_params_t *params);
|
1073
|
+
|
1074
|
+
/*
|
1075
|
+
* generate a new HTTP span
|
1076
|
+
*
|
1077
|
+
* @param buffer a char buffer where the final transaction name will be written to
|
1078
|
+
* @param buffer_length the length of the char buffer
|
1079
|
+
* @param params additional span parameters
|
1080
|
+
*
|
1081
|
+
* @return size of the final transaction name written to buffer
|
1082
|
+
* if an error occurs, these values will be returned:
|
1083
|
+
* - OBOE_SPAN_NULL_PARAMS
|
1084
|
+
* - OBOE_SPAN_NULL_BUFFER
|
1085
|
+
* - OBOE_SPAN_INVALID_VERSION
|
1086
|
+
* - OBOE_SPAN_NO_REPORTER
|
1087
|
+
* - OBOE_SPAN_NOT_READY
|
1088
|
+
*/
|
1089
|
+
int oboe_http_span(char *buffer, const uint16_t buffer_length, oboe_span_params_t *params);
|
1090
|
+
|
1091
|
+
/*
|
1092
|
+
* helper functions to mark the start/end of a span
|
1093
|
+
*
|
1094
|
+
* @return monotonic time in micro seconds (usec) since some unspecified starting point
|
1095
|
+
*/
|
1096
|
+
int64_t oboe_span_start();
|
1097
|
+
int64_t oboe_span_stop();
|
1098
|
+
|
1099
|
+
// Custom metrics
|
1100
|
+
|
1101
|
+
int oboe_custom_metric_summary(const char *name, const double value, const int count, const int host_tag, const char *service_name,
|
1102
|
+
const oboe_metric_tag_t tags[], const size_t tags_count);
|
1103
|
+
|
1104
|
+
int oboe_custom_metric_increment(const char *name, const int count, const int host_tag, const char *service_name,
|
1105
|
+
const oboe_metric_tag_t tags[], const size_t tags_count);
|
1106
|
+
|
1107
|
+
// Service names
|
1108
|
+
|
1109
|
+
/*
|
1110
|
+
* Perform validation and replacement of invalid characters on the given service name.
|
1111
|
+
*
|
1112
|
+
* The rules are as follows:
|
1113
|
+
* .toLowerCase() // automatically convert to lowercase
|
1114
|
+
* .replace(/ /g, "-") // automatically convert spaces to hyphens
|
1115
|
+
* .replace(/[^a-z0-9.:_-]/g, ""); // remove remaining invalid characters
|
1116
|
+
*
|
1117
|
+
* @param service_name pointer to the service name string to perform the validation on
|
1118
|
+
* (important: address must be editable)
|
1119
|
+
* @param length pointer to the length of the service name
|
1120
|
+
*
|
1121
|
+
* @return 0 if service name is valid
|
1122
|
+
* 1 if service name was invalid and has been transformed
|
1123
|
+
* (new valid service name is stored in service_name and length)
|
1124
|
+
* -1 NULL pointer passed in for service_name or length
|
1125
|
+
*/
|
1126
|
+
int oboe_validate_transform_service_name(char *service_name, int *length);
|
1127
|
+
|
1128
|
+
// Timer tools
|
1129
|
+
void oboe_timer_tool_wait(int usec);
|
1130
|
+
|
1131
|
+
// Get profiling interval as configured remotely
|
1132
|
+
int oboe_get_profiling_interval();
|
1133
|
+
|
1134
|
+
// Get server warning message
|
1135
|
+
const char* oboe_get_server_warning();
|
1136
|
+
|
1137
|
+
// Regex tools
|
1138
|
+
void* oboe_regex_new_expression(const char* exprString);
|
1139
|
+
void oboe_regex_delete_expression(void* expression);
|
1140
|
+
int oboe_regex_match(const char* string, void* expression);
|
1141
|
+
|
1142
|
+
/* oboe internal stats for agents to consume */
|
1143
|
+
oboe_internal_stats_t* oboe_get_internal_stats();
|
1144
|
+
|
1145
|
+
/* notifier related functions */
|
1146
|
+
int oboe_notifier_init(const char *socket_path);
|
1147
|
+
int oboe_notifier_stop(int blocking);
|
1148
|
+
int oboe_notifier_status();
|
1149
|
+
int oboe_notifier_test(int test_case, const char *test_str);
|
1150
|
+
|
1151
|
+
|
1152
|
+
#ifdef __cplusplus
|
1153
|
+
} // extern "C"
|
1154
|
+
#endif
|
1155
|
+
|
1156
|
+
#endif // LIBOBOE_H
|