appoptics_apm 4.8.1 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/.travis.yml +50 -28
- data/CONFIG.md +1 -1
- data/Gemfile +6 -6
- data/README.md +1 -1
- data/appoptics_apm.gemspec +4 -1
- data/examples/SDK/01_basic_tracing.rb +0 -2
- data/ext/oboe_metal/README.md +69 -0
- data/ext/oboe_metal/noop/noop.c +2 -1
- data/ext/oboe_metal/src/VERSION +1 -1
- data/ext/oboe_metal/src/bson/bson.h +105 -105
- data/ext/oboe_metal/src/bson/platform_hacks.h +10 -10
- data/ext/oboe_metal/src/oboe.h +104 -73
- data/ext/oboe_metal/src/oboe.hpp +103 -61
- data/ext/oboe_metal/src/oboe_wrap.cxx +1470 -314
- data/lib/appoptics_apm.rb +1 -3
- data/lib/appoptics_apm/api.rb +0 -1
- data/lib/appoptics_apm/api/tracing.rb +4 -0
- data/lib/appoptics_apm/config.rb +16 -5
- data/lib/appoptics_apm/frameworks/padrino.rb +6 -36
- data/lib/appoptics_apm/frameworks/rails.rb +0 -1
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller.rb +5 -5
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller6.rb +50 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_view.rb +11 -24
- data/lib/appoptics_apm/frameworks/rails/inst/active_record.rb +3 -3
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils.rb +1 -1
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +1 -1
- data/lib/appoptics_apm/frameworks/sinatra.rb +3 -32
- data/lib/appoptics_apm/inst/curb.rb +6 -6
- data/lib/appoptics_apm/inst/faraday.rb +16 -4
- data/lib/appoptics_apm/inst/logger_formatter.rb +4 -3
- data/lib/appoptics_apm/inst/rack.rb +11 -11
- data/lib/appoptics_apm/oboe_init_options.rb +17 -4
- data/lib/appoptics_apm/sdk/tracing.rb +118 -0
- data/lib/appoptics_apm/support/transaction_metrics.rb +1 -0
- data/lib/appoptics_apm/support/transaction_settings.rb +40 -15
- data/lib/appoptics_apm/support/x_trace_options.rb +110 -0
- data/lib/appoptics_apm/version.rb +2 -2
- data/lib/appoptics_apm/xtrace.rb +7 -7
- data/lib/rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb +37 -12
- metadata +7 -15
- data/Rakefile +0 -229
- data/build_gem.sh +0 -15
- data/build_gem_upload_to_packagecloud.sh +0 -20
- data/lib/appoptics_apm/api/profiling.rb +0 -203
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller3.rb +0 -55
- data/lib/appoptics_apm/frameworks/rails/inst/action_view_30.rb +0 -50
- data/lib/appoptics_apm/legacy_method_profiling.rb +0 -90
- data/lib/appoptics_apm/method_profiling.rb +0 -33
- data/lib/oboe/README +0 -2
- data/lib/oboe/backward_compatibility.rb +0 -80
- data/lib/oboe/inst/rack.rb +0 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: df0f7977cb5f0fdf91217b32c632c0349fd66eedca4e3aec3a744c5a93db5fa3
|
|
4
|
+
data.tar.gz: b85f35a591b5ce51050cdbbc5a59e1ca8dd3aa92f62578419aaca710fa3e23f7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 347da55c1ec4b00c842b217171a256dc97a04f4c8a9cf57f64cc2a595e2809dc0cacaa7e7e52a7a2635bf203f1706c8e86bc83a54071887a868f5362cfdf86c8
|
|
7
|
+
data.tar.gz: 80466d964db1077a415c8d4ca39f63b0cf3af8bdd68f1b1c564389d74bc156c60386dca008e85ba7afecdf4b3650aa5c519ab974b0c25b81a23559ee058aad8b
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
|
@@ -11,10 +11,11 @@ env:
|
|
|
11
11
|
- DBTYPE=mysql
|
|
12
12
|
|
|
13
13
|
rvm:
|
|
14
|
-
- 2.6.
|
|
15
|
-
- 2.5.
|
|
14
|
+
- 2.6.4
|
|
15
|
+
- 2.5.5
|
|
16
16
|
- 2.4.5
|
|
17
|
-
-
|
|
17
|
+
- 2.7.0-preview1
|
|
18
|
+
# - ruby-head
|
|
18
19
|
# - jruby-9.0.5.0
|
|
19
20
|
|
|
20
21
|
gemfile:
|
|
@@ -23,6 +24,7 @@ gemfile:
|
|
|
23
24
|
- gemfiles/instrumentation_mocked.gemfile
|
|
24
25
|
- gemfiles/instrumentation_mocked_oldgems.gemfile
|
|
25
26
|
- gemfiles/frameworks.gemfile
|
|
27
|
+
- gemfiles/rails60.gemfile
|
|
26
28
|
- gemfiles/rails52.gemfile
|
|
27
29
|
- gemfiles/rails42.gemfile
|
|
28
30
|
- gemfiles/delayed_job.gemfile
|
|
@@ -32,17 +34,22 @@ matrix:
|
|
|
32
34
|
exclude:
|
|
33
35
|
- rvm: ruby-head
|
|
34
36
|
gemfile: gemfiles/rails42.gemfile
|
|
35
|
-
- rvm: 2.
|
|
37
|
+
- rvm: 2.7.0-preview1
|
|
36
38
|
gemfile: gemfiles/rails42.gemfile
|
|
39
|
+
- rvm: 2.6.4
|
|
40
|
+
gemfile: gemfiles/rails42.gemfile
|
|
41
|
+
- rvm: 2.4.5
|
|
42
|
+
gemfile: gemfiles/rails60.gemfile
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
- rmv: 2.6.2
|
|
44
|
+
- rvm: ruby-head
|
|
40
45
|
env: DBTYPE=mysql
|
|
41
|
-
- rvm: 2.
|
|
46
|
+
- rvm: 2.7.0-preview1
|
|
42
47
|
env: DBTYPE=mysql
|
|
43
|
-
-
|
|
48
|
+
- rmv: 2.6.4
|
|
44
49
|
env: DBTYPE=mysql
|
|
45
|
-
- rvm:
|
|
50
|
+
- rvm: 2.5.5
|
|
51
|
+
env: DBTYPE=mysql
|
|
52
|
+
- rvm: 2.4.5
|
|
46
53
|
env: DBTYPE=mysql
|
|
47
54
|
|
|
48
55
|
- gemfile: gemfiles/unit.gemfile
|
|
@@ -57,10 +64,10 @@ matrix:
|
|
|
57
64
|
env: DBTYPE=mysql
|
|
58
65
|
- gemfile: gemfiles/frameworks.gemfile
|
|
59
66
|
env: DBTYPE=mysql
|
|
60
|
-
- gemfile: gemfiles/rails51.gemfile
|
|
61
|
-
env: DBTYPE=mysql
|
|
62
67
|
- gemfile: gemfiles/rails52.gemfile
|
|
63
68
|
env: DBTYPE=mysql
|
|
69
|
+
- gemfile: gemfiles/rails60.gemfile
|
|
70
|
+
env: DBTYPE=mysql
|
|
64
71
|
- gemfile: gemfiles/delayed_job.gemfile
|
|
65
72
|
env: DBTYPE=mysql
|
|
66
73
|
|
|
@@ -80,42 +87,57 @@ matrix:
|
|
|
80
87
|
env: DBTYPE=mysql2
|
|
81
88
|
allow_failures:
|
|
82
89
|
- rvm: ruby-head
|
|
90
|
+
- rvm: 2.7.0-preview1
|
|
83
91
|
|
|
84
92
|
# FIXME: Figure out if this is still an issue when reviewing cassandra test setup
|
|
85
93
|
# Attempt Travis/Cassandra fix re: https://github.com/travis-ci/travis-ci/issues/1484
|
|
86
94
|
# Updated Cassandra: https://github.com/travis-ci/travis-ci/issues/1650
|
|
87
95
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
-
|
|
93
|
-
- sudo
|
|
96
|
+
# the following is not working anymore on travis
|
|
97
|
+
# commenting it out as per AO-13532 as we currently don't have instrumentation
|
|
98
|
+
# for cassandra
|
|
99
|
+
#before_install:
|
|
100
|
+
# - sudo service cassandra stop
|
|
101
|
+
# - sudo sh -c "echo 'JVM_OPTS=\"\${JVM_OPTS} -Djava.net.preferIPv4Stack=false\"' >> /etc/cassandra/cassandra-env.sh"
|
|
102
|
+
# - echo "127.0.0.1 localhost" | sudo tee /etc/hosts
|
|
103
|
+
# - echo "127.0.0.1 " `hostname` | sudo tee -a /etc/hosts
|
|
104
|
+
# - sudo service cassandra start
|
|
94
105
|
|
|
95
106
|
install:
|
|
96
|
-
- curl -LO http://kent.dl.sourceforge.net/project/swig/swig/swig-3.0.
|
|
97
|
-
- tar xzf swig-3.0.
|
|
98
|
-
- pushd swig-3.0.
|
|
107
|
+
- curl -LO http://kent.dl.sourceforge.net/project/swig/swig/swig-3.0.12/swig-3.0.12.tar.gz
|
|
108
|
+
- tar xzf swig-3.0.12.tar.gz
|
|
109
|
+
- pushd swig-3.0.12
|
|
99
110
|
- ./configure && make && sudo make install
|
|
100
111
|
- popd
|
|
101
112
|
|
|
102
113
|
before_script:
|
|
114
|
+
- export APPOPTICS_GEM_TEST=true
|
|
115
|
+
- export APPOPTICS_REPORTER=file
|
|
116
|
+
- export APPOPTICS_COLLECTOR=/tmp/appoptics_traces.bson
|
|
117
|
+
- export APPOPTICS_REPORTER_FILE_SINGLE=false
|
|
118
|
+
- export APPOPTICS_TOKEN_BUCKET_CAPACITY=1000
|
|
119
|
+
- export APPOPTICS_TOKEN_BUCKET_RATE=1000
|
|
120
|
+
- export APPOPTICS_FROM_S3=true
|
|
121
|
+
|
|
103
122
|
- bundle update --jobs=3 --retry=3
|
|
104
|
-
- bundle exec rake
|
|
105
|
-
- bundle exec rake clean
|
|
106
|
-
- bundle exec rake compile
|
|
123
|
+
- bundle exec rake clean fetch compile
|
|
107
124
|
- psql -c 'create database travis_ci_test;' -U postgres
|
|
108
125
|
- mysql -e 'create database travis_ci_test;'
|
|
109
126
|
- redis-server --requirepass secret_pass &
|
|
110
127
|
- sleep 10
|
|
111
|
-
- export APPOPTICS_TOKEN_BUCKET_CAPACITY=1000
|
|
112
|
-
- export APPOPTICS_TOKEN_BUCKET_RATE=1000
|
|
113
128
|
|
|
114
|
-
script: "
|
|
129
|
+
script: "bundle exec rake test"
|
|
115
130
|
|
|
116
131
|
services:
|
|
117
132
|
- mongodb
|
|
118
133
|
- memcached
|
|
119
|
-
-
|
|
120
|
-
# -
|
|
134
|
+
- mysql
|
|
135
|
+
# - cassandra
|
|
136
|
+
- postgresql
|
|
137
|
+
# - redis-server
|
|
121
138
|
- rabbitmq
|
|
139
|
+
|
|
140
|
+
addons:
|
|
141
|
+
apt:
|
|
142
|
+
packages:
|
|
143
|
+
- rabbitmq-server
|
data/CONFIG.md
CHANGED
|
@@ -17,7 +17,7 @@ Name | Description | Default
|
|
|
17
17
|
|
|
18
18
|
Name | Description | Default
|
|
19
19
|
---- | ----------- | -------
|
|
20
|
-
`APPOPTICS_GEM_TEST` | puts the gem in test mode
|
|
20
|
+
`APPOPTICS_GEM_TEST` | puts the gem in test mode to avoid restarting certain background services used in testing. `false`
|
|
21
21
|
`DBTYPE` | For tests on Ruby on Rails, specifies the database type to test against. `postgres`, `mysql` and `mysql2` are valid options. | `postgres`
|
|
22
22
|
`APPOPTICS_CASSANDRA_SERVER` | specifies the Cassandra server to test against. | `127.0.0.1:9160`
|
|
23
23
|
`APPOPTICS_MONGO_SERVER` | specifies the Mongo server to test against. | `127.0.0.1:27017`
|
data/Gemfile
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
|
+
gem 'rake'
|
|
2
3
|
|
|
3
4
|
group :development, :test do
|
|
4
|
-
gem 'rake'
|
|
5
5
|
gem 'minitest'
|
|
6
6
|
gem 'minitest-reporters', '< 1.0.18'
|
|
7
7
|
gem 'minitest-debugger', :require => false
|
|
@@ -18,12 +18,12 @@ group :development, :test do
|
|
|
18
18
|
gem 'byebug'
|
|
19
19
|
gem 'get_process_mem'
|
|
20
20
|
gem 'memory_profiler'
|
|
21
|
-
end
|
|
22
21
|
|
|
23
|
-
if defined?(JRUBY_VERSION)
|
|
24
|
-
|
|
25
|
-
else
|
|
26
|
-
|
|
22
|
+
if defined?(JRUBY_VERSION)
|
|
23
|
+
gem 'sinatra', :require => false
|
|
24
|
+
else
|
|
25
|
+
gem 'sinatra'
|
|
26
|
+
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
gemspec
|
data/README.md
CHANGED
|
@@ -390,4 +390,4 @@ See the README in the test directory.
|
|
|
390
390
|
|
|
391
391
|
Copyright (c) 2018 SolarWinds, LLC
|
|
392
392
|
|
|
393
|
-
Released under the [Librato Open License](https://docs.appoptics.com/kb/apm_tracing/librato-open-license/)
|
|
393
|
+
Released under the [Librato Open License](https://docs.appoptics.com/kb/apm_tracing/librato-open-license/)
|
data/appoptics_apm.gemspec
CHANGED
|
@@ -32,6 +32,9 @@ Automatic tracing and metrics for Ruby applications. Get started at appoptics.co
|
|
|
32
32
|
'ext/oboe_metal/src/bson/bson.h',
|
|
33
33
|
'ext/oboe_metal/src/bson/platform_hacks.h',
|
|
34
34
|
'ext/oboe_metal/src/VERSION']
|
|
35
|
+
s.files -= ['build_gem.sh',
|
|
36
|
+
'build_gem_upload_to_packagecloud.sh',
|
|
37
|
+
'Rakefile']
|
|
35
38
|
|
|
36
39
|
# TODO this is commented out util we can actually provide gems for different platforms
|
|
37
40
|
# it will create a gem that goes into noop on Darwin and other unsupported platforms
|
|
@@ -54,6 +57,6 @@ Automatic tracing and metrics for Ruby applications. Get started at appoptics.co
|
|
|
54
57
|
s.add_development_dependency('benchmark-ips', '>= 2.7.2')
|
|
55
58
|
end
|
|
56
59
|
|
|
57
|
-
s.required_ruby_version = '>= 2.
|
|
60
|
+
s.required_ruby_version = '>= 2.4.0'
|
|
58
61
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
59
62
|
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Debug the c-code with gdb
|
|
2
|
+
|
|
3
|
+
inspired by: https://dev.to/wataash/how-to-create-and-debug-ruby-gem-with-c-native-extension-3l8b
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## install ruby with sources
|
|
7
|
+
|
|
8
|
+
rbenv is your friend ;) 😄 -k means keep sources
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
rbenv install -k 2.6.3
|
|
12
|
+
rbenv shell 2.6.3
|
|
13
|
+
|
|
14
|
+
# check that ruby is debuggable
|
|
15
|
+
type ruby # => ruby is /home/wsh/.rbenv/shims/ruby
|
|
16
|
+
rbenv which ruby # => /home/wsh/.rbenv/versions/2.6.3/bin/ruby
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
##
|
|
21
|
+
## add debug info when compiling appoptics_apm
|
|
22
|
+
add this line to extconf.rb to turn off optimization
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
CONFIG["optflags"] = "-O0"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
##
|
|
30
|
+
## start ruby app with gdb
|
|
31
|
+
|
|
32
|
+
This will run ruby and load the app with a breakpoint in the Reporter::startThread
|
|
33
|
+
c-function.
|
|
34
|
+
|
|
35
|
+
`bundle exec gdb -q -ex 'set breakpoint pending on' -ex 'b Reporter::startThread' -ex run --args ruby -e 'require "./app"'`
|
|
36
|
+
|
|
37
|
+
If there is a bug in the ruby code or a ruby byebug binding that halts the
|
|
38
|
+
script, the debugger will hang without showing any output.
|
|
39
|
+
So, make sure `bundle exec ruby app.rb` runs.
|
|
40
|
+
|
|
41
|
+
use the gdb navigation commands to step through the code. If it says:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
(gdb) n
|
|
45
|
+
Single stepping until exit from function _ZN8Reporter11startThreadEv@plt,
|
|
46
|
+
which has no line number information.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
type `c` and it may end up stopping in the right location.
|
|
50
|
+
|
|
51
|
+
##
|
|
52
|
+
## make ruby .gdbinit macros available
|
|
53
|
+
|
|
54
|
+
These macros are pretty elaborate. They are checked in the ruby github
|
|
55
|
+
repo: https://github.com/ruby/ruby/blob/master/.gdbinit
|
|
56
|
+
The code is nicely formatted and colorized in github and easiest to read there.
|
|
57
|
+
|
|
58
|
+
installation in the user's home dir:
|
|
59
|
+
```
|
|
60
|
+
wget https://github.com/ruby/ruby/blob/master/.gdbinit
|
|
61
|
+
```
|
|
62
|
+
##
|
|
63
|
+
## examples
|
|
64
|
+
|
|
65
|
+
Some inspiring examples here:
|
|
66
|
+
|
|
67
|
+
https://jvns.ca/blog/2016/06/12/a-weird-system-call-process-vm-readv/
|
|
68
|
+
|
|
69
|
+
https://medium.com/@zanker/finding-a-ruby-bug-with-gdb-56d6b321bc86
|
data/ext/oboe_metal/noop/noop.c
CHANGED
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
/* ruby calls this to load the extension */
|
|
4
4
|
void Init_oboe_noop(void) {
|
|
5
5
|
/* assume we haven't yet defined Hola */
|
|
6
|
-
VALUE klass = rb_define_class("OboeNoop", rb_cObject);
|
|
6
|
+
// VALUE klass = rb_define_class("OboeNoop", rb_cObject);
|
|
7
|
+
rb_define_class("OboeNoop", rb_cObject);
|
|
7
8
|
}
|
data/ext/oboe_metal/src/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
7.0.0
|
|
@@ -25,196 +25,196 @@
|
|
|
25
25
|
MONGO_EXTERN_C_START
|
|
26
26
|
|
|
27
27
|
typedef enum {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
typedef int
|
|
28
|
+
oboe_bson_error=-1,
|
|
29
|
+
oboe_bson_eoo=0,
|
|
30
|
+
oboe_bson_double=1,
|
|
31
|
+
oboe_bson_string=2,
|
|
32
|
+
oboe_bson_object=3,
|
|
33
|
+
oboe_bson_array=4,
|
|
34
|
+
oboe_bson_bindata=5,
|
|
35
|
+
oboe_bson_undefined=6,
|
|
36
|
+
oboe_bson_oid=7,
|
|
37
|
+
oboe_bson_bool=8,
|
|
38
|
+
oboe_bson_date=9,
|
|
39
|
+
oboe_bson_null=10,
|
|
40
|
+
oboe_bson_regex=11,
|
|
41
|
+
oboe_bson_dbref=12, /* deprecated */
|
|
42
|
+
oboe_bson_code=13,
|
|
43
|
+
oboe_bson_symbol=14,
|
|
44
|
+
oboe_bson_codewscope=15,
|
|
45
|
+
oboe_bson_int = 16,
|
|
46
|
+
oboe_bson_timestamp = 17,
|
|
47
|
+
oboe_bson_long = 18
|
|
48
|
+
} oboe_bson_type;
|
|
49
|
+
|
|
50
|
+
typedef int oboe_bson_bool_t;
|
|
51
51
|
|
|
52
52
|
typedef struct {
|
|
53
53
|
char * data;
|
|
54
|
-
|
|
55
|
-
}
|
|
54
|
+
oboe_bson_bool_t owned;
|
|
55
|
+
} oboe_bson;
|
|
56
56
|
|
|
57
57
|
typedef struct {
|
|
58
58
|
const char * cur;
|
|
59
|
-
|
|
60
|
-
}
|
|
59
|
+
oboe_bson_bool_t first;
|
|
60
|
+
} oboe_bson_iterator;
|
|
61
61
|
|
|
62
62
|
typedef struct {
|
|
63
63
|
char * buf;
|
|
64
64
|
char * cur;
|
|
65
65
|
int bufSize;
|
|
66
|
-
|
|
66
|
+
oboe_bson_bool_t finished;
|
|
67
67
|
int stack[32];
|
|
68
68
|
int stackPos;
|
|
69
|
-
}
|
|
69
|
+
} oboe_bson_buffer;
|
|
70
70
|
|
|
71
71
|
#pragma pack(1)
|
|
72
72
|
typedef union{
|
|
73
73
|
char bytes[12]; // Flawfinder: ignore
|
|
74
74
|
int ints[3];
|
|
75
|
-
}
|
|
75
|
+
} oboe_bson_oid_t;
|
|
76
76
|
#pragma pack()
|
|
77
77
|
|
|
78
|
-
typedef int64_t
|
|
78
|
+
typedef int64_t oboe_bson_date_t; /* milliseconds since epoch UTC */
|
|
79
79
|
|
|
80
80
|
/* ----------------------------
|
|
81
81
|
READING
|
|
82
82
|
------------------------------ */
|
|
83
83
|
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
int
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
int
|
|
91
|
-
void
|
|
85
|
+
oboe_bson * oboe_bson_empty(oboe_bson * obj); /* returns pointer to static empty bson object */
|
|
86
|
+
int oboe_bson_copy(oboe_bson* out, const oboe_bson* in); /* puts data in new buffer. NOOP if out==NULL */
|
|
87
|
+
oboe_bson * oboe_bson_from_buffer(oboe_bson * b, oboe_bson_buffer * buf);
|
|
88
|
+
oboe_bson * oboe_bson_init( oboe_bson * b , char * data , oboe_bson_bool_t mine );
|
|
89
|
+
oboe_bson * oboe_bson_init_safe( oboe_bson * b , char * data , oboe_bson_bool_t mine , size_t buflen);
|
|
90
|
+
int oboe_bson_size(const oboe_bson * b );
|
|
91
|
+
void oboe_bson_destroy( oboe_bson * b );
|
|
92
92
|
|
|
93
|
-
void
|
|
94
|
-
void
|
|
93
|
+
void oboe_bson_print( oboe_bson * b );
|
|
94
|
+
void oboe_bson_print_raw( const char * bson , int depth );
|
|
95
95
|
|
|
96
96
|
/* advances iterator to named field */
|
|
97
97
|
/* returns bson_eoo (which is false) if field not found */
|
|
98
|
-
|
|
98
|
+
oboe_bson_type oboe_bson_find(oboe_bson_iterator* it, const oboe_bson* obj, const char* name);
|
|
99
99
|
|
|
100
|
-
void
|
|
100
|
+
void oboe_bson_iterator_init( oboe_bson_iterator * i , const char * bson );
|
|
101
101
|
|
|
102
102
|
/* more returns true for eoo. best to loop with bson_iterator_next(&it) */
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
oboe_bson_bool_t oboe_bson_iterator_more( const oboe_bson_iterator * i );
|
|
104
|
+
oboe_bson_type oboe_bson_iterator_next( oboe_bson_iterator * i );
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
const char *
|
|
108
|
-
const char *
|
|
106
|
+
oboe_bson_type oboe_bson_iterator_type( const oboe_bson_iterator * i );
|
|
107
|
+
const char * oboe_bson_iterator_key( const oboe_bson_iterator * i );
|
|
108
|
+
const char * oboe_bson_iterator_value( const oboe_bson_iterator * i );
|
|
109
109
|
|
|
110
110
|
/* these convert to the right type (return 0 if non-numeric) */
|
|
111
|
-
double
|
|
112
|
-
int
|
|
113
|
-
int64_t
|
|
111
|
+
double oboe_bson_iterator_double( const oboe_bson_iterator * i );
|
|
112
|
+
int oboe_bson_iterator_int( const oboe_bson_iterator * i );
|
|
113
|
+
int64_t oboe_bson_iterator_long( const oboe_bson_iterator * i );
|
|
114
114
|
|
|
115
115
|
/* false: boolean false, 0 in any type, or null */
|
|
116
116
|
/* true: anything else (even empty strings and objects) */
|
|
117
|
-
|
|
117
|
+
oboe_bson_bool_t oboe_bson_iterator_bool( const oboe_bson_iterator * i );
|
|
118
118
|
|
|
119
119
|
/* these assume you are using the right type */
|
|
120
|
-
double
|
|
121
|
-
int
|
|
122
|
-
int64_t
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
double oboe_bson_iterator_double_raw( const oboe_bson_iterator * i );
|
|
121
|
+
int oboe_bson_iterator_int_raw( const oboe_bson_iterator * i );
|
|
122
|
+
int64_t oboe_bson_iterator_long_raw( const oboe_bson_iterator * i );
|
|
123
|
+
oboe_bson_bool_t oboe_bson_iterator_bool_raw( const oboe_bson_iterator * i );
|
|
124
|
+
oboe_bson_oid_t* oboe_bson_iterator_oid( const oboe_bson_iterator * i );
|
|
125
125
|
|
|
126
126
|
/* these can also be used with bson_code and bson_symbol*/
|
|
127
|
-
const char *
|
|
128
|
-
int
|
|
127
|
+
const char * oboe_bson_iterator_string( const oboe_bson_iterator * i );
|
|
128
|
+
int oboe_bson_iterator_string_len( const oboe_bson_iterator * i );
|
|
129
129
|
|
|
130
130
|
/* works with bson_code, bson_codewscope, and bson_string */
|
|
131
131
|
/* returns NULL for everything else */
|
|
132
|
-
const char *
|
|
132
|
+
const char * oboe_bson_iterator_code(const oboe_bson_iterator * i);
|
|
133
133
|
|
|
134
134
|
/* calls bson_empty on scope if not a bson_codewscope */
|
|
135
|
-
void
|
|
135
|
+
void oboe_bson_iterator_code_scope(const oboe_bson_iterator * i, oboe_bson * scope);
|
|
136
136
|
|
|
137
137
|
/* both of these only work with bson_date */
|
|
138
|
-
|
|
139
|
-
time_t
|
|
138
|
+
oboe_bson_date_t oboe_bson_iterator_date(const oboe_bson_iterator * i);
|
|
139
|
+
time_t oboe_bson_iterator_time_t(const oboe_bson_iterator * i);
|
|
140
140
|
|
|
141
|
-
int
|
|
142
|
-
char
|
|
143
|
-
const char *
|
|
141
|
+
int oboe_bson_iterator_bin_len( const oboe_bson_iterator * i );
|
|
142
|
+
char oboe_bson_iterator_bin_type( const oboe_bson_iterator * i );
|
|
143
|
+
const char * oboe_bson_iterator_bin_data( const oboe_bson_iterator * i );
|
|
144
144
|
|
|
145
|
-
const char *
|
|
146
|
-
const char *
|
|
145
|
+
const char * oboe_bson_iterator_regex( const oboe_bson_iterator * i );
|
|
146
|
+
const char * oboe_bson_iterator_regex_opts( const oboe_bson_iterator * i );
|
|
147
147
|
|
|
148
148
|
/* these work with bson_object and bson_array */
|
|
149
|
-
void
|
|
150
|
-
void
|
|
149
|
+
void oboe_bson_iterator_subobject(const oboe_bson_iterator * i, oboe_bson * sub);
|
|
150
|
+
void oboe_bson_iterator_subiterator(const oboe_bson_iterator * i, oboe_bson_iterator * sub);
|
|
151
151
|
|
|
152
152
|
/* str must be at least 24 hex chars + null byte */
|
|
153
|
-
void
|
|
154
|
-
void
|
|
155
|
-
void
|
|
153
|
+
void oboe_bson_oid_from_string(oboe_bson_oid_t* oid, const char* str);
|
|
154
|
+
void oboe_bson_oid_to_string(const oboe_bson_oid_t* oid, char* str);
|
|
155
|
+
void oboe_bson_oid_gen(oboe_bson_oid_t* oid);
|
|
156
156
|
|
|
157
|
-
time_t
|
|
157
|
+
time_t oboe_bson_oid_generated_time(oboe_bson_oid_t* oid); /* Gives the time the OID was created */
|
|
158
158
|
|
|
159
159
|
/* ----------------------------
|
|
160
160
|
BUILDING
|
|
161
161
|
------------------------------ */
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
oboe_bson_buffer * oboe_bson_buffer_init( oboe_bson_buffer * b );
|
|
164
|
+
oboe_bson_buffer * oboe_bson_ensure_space( oboe_bson_buffer * b , const int bytesNeeded );
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
167
|
* @return the raw data. you either should free this OR call bson_destroy not both
|
|
168
168
|
*/
|
|
169
|
-
char *
|
|
170
|
-
void
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
169
|
+
char * oboe_bson_buffer_finish( oboe_bson_buffer * b );
|
|
170
|
+
void oboe_bson_buffer_destroy( oboe_bson_buffer * b );
|
|
171
|
+
|
|
172
|
+
oboe_bson_buffer * oboe_bson_append_oid( oboe_bson_buffer * b , const char * name , const oboe_bson_oid_t* oid );
|
|
173
|
+
oboe_bson_buffer * oboe_bson_append_int( oboe_bson_buffer * b , const char * name , const int i );
|
|
174
|
+
oboe_bson_buffer * oboe_bson_append_long( oboe_bson_buffer * b , const char * name , const int64_t i );
|
|
175
|
+
oboe_bson_buffer * oboe_bson_append_double( oboe_bson_buffer * b , const char * name , const double d );
|
|
176
|
+
oboe_bson_buffer * oboe_bson_append_string( oboe_bson_buffer * b , const char * name , const char * str );
|
|
177
|
+
oboe_bson_buffer * oboe_bson_append_symbol( oboe_bson_buffer * b , const char * name , const char * str );
|
|
178
|
+
oboe_bson_buffer * oboe_bson_append_code( oboe_bson_buffer * b , const char * name , const char * str );
|
|
179
|
+
oboe_bson_buffer * oboe_bson_append_code_w_scope( oboe_bson_buffer * b , const char * name , const char * code , const oboe_bson * scope);
|
|
180
|
+
oboe_bson_buffer * oboe_bson_append_binary( oboe_bson_buffer * b, const char * name, char type, const char * str, int len );
|
|
181
|
+
oboe_bson_buffer * oboe_bson_append_bool( oboe_bson_buffer * b , const char * name , const oboe_bson_bool_t v );
|
|
182
|
+
oboe_bson_buffer * oboe_bson_append_null( oboe_bson_buffer * b , const char * name );
|
|
183
|
+
oboe_bson_buffer * oboe_bson_append_undefined( oboe_bson_buffer * b , const char * name );
|
|
184
|
+
oboe_bson_buffer * oboe_bson_append_regex( oboe_bson_buffer * b , const char * name , const char * pattern, const char * opts );
|
|
185
|
+
oboe_bson_buffer * oboe_bson_append_bson( oboe_bson_buffer * b , const char * name , const oboe_bson* bson);
|
|
186
|
+
oboe_bson_buffer * oboe_bson_append_element( oboe_bson_buffer * b, const char * name_or_null, const oboe_bson_iterator* elem);
|
|
187
187
|
|
|
188
188
|
/* these both append a bson_date */
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
oboe_bson_buffer * oboe_bson_append_date(oboe_bson_buffer * b, const char * name, oboe_bson_date_t millis);
|
|
190
|
+
oboe_bson_buffer * oboe_bson_append_time_t(oboe_bson_buffer * b, const char * name, time_t secs);
|
|
191
191
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
oboe_bson_buffer * oboe_bson_append_start_object( oboe_bson_buffer * b , const char * name );
|
|
193
|
+
oboe_bson_buffer * oboe_bson_append_start_array( oboe_bson_buffer * b , const char * name );
|
|
194
|
+
oboe_bson_buffer * oboe_bson_append_finish_object( oboe_bson_buffer * b );
|
|
195
195
|
|
|
196
|
-
void
|
|
197
|
-
void
|
|
196
|
+
void oboe_bson_numstr(char* str, int i);
|
|
197
|
+
void oboe_bson_incnumstr(char* str);
|
|
198
198
|
|
|
199
199
|
|
|
200
200
|
/* ------------------------------
|
|
201
201
|
ERROR HANDLING - also used in mongo code
|
|
202
202
|
------------------------------ */
|
|
203
203
|
|
|
204
|
-
void *
|
|
204
|
+
void * oboe_bson_malloc(int size); /* checks return value */
|
|
205
205
|
|
|
206
206
|
/* bson_err_handlers shouldn't return!!! */
|
|
207
|
-
typedef void(*
|
|
207
|
+
typedef void(*ob_bson_err_handler)(const char* errmsg);
|
|
208
208
|
|
|
209
209
|
/* returns old handler or NULL */
|
|
210
210
|
/* default handler prints error then exits with failure*/
|
|
211
|
-
|
|
211
|
+
ob_bson_err_handler oboe_set_bson_err_handler(ob_bson_err_handler func);
|
|
212
212
|
|
|
213
213
|
|
|
214
214
|
|
|
215
215
|
/* does nothing is ok != 0 */
|
|
216
|
-
void
|
|
217
|
-
int
|
|
216
|
+
void oboe_bson_fatal( int ok );
|
|
217
|
+
int oboe_bson_fatal_msg( int ok, const char* msg );
|
|
218
218
|
|
|
219
219
|
MONGO_EXTERN_C_END
|
|
220
220
|
#endif
|