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