appoptics_apm 4.8.2 → 4.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +6 -1
  3. data/.travis.yml +50 -28
  4. data/CONFIG.md +1 -1
  5. data/Gemfile +6 -7
  6. data/README.md +1 -1
  7. data/appoptics_apm.gemspec +4 -1
  8. data/examples/SDK/01_basic_tracing.rb +0 -2
  9. data/ext/oboe_metal/README.md +69 -0
  10. data/ext/oboe_metal/noop/noop.c +2 -1
  11. data/ext/oboe_metal/src/VERSION +1 -1
  12. data/ext/oboe_metal/src/bson/bson.h +105 -105
  13. data/ext/oboe_metal/src/bson/platform_hacks.h +10 -10
  14. data/ext/oboe_metal/src/oboe.h +104 -73
  15. data/ext/oboe_metal/src/oboe.hpp +103 -61
  16. data/ext/oboe_metal/src/oboe_wrap.cxx +1470 -314
  17. data/lib/appoptics_apm.rb +1 -3
  18. data/lib/appoptics_apm/api.rb +0 -1
  19. data/lib/appoptics_apm/api/tracing.rb +4 -0
  20. data/lib/appoptics_apm/config.rb +16 -5
  21. data/lib/appoptics_apm/frameworks/padrino.rb +6 -36
  22. data/lib/appoptics_apm/frameworks/rails.rb +0 -1
  23. data/lib/appoptics_apm/frameworks/rails/inst/action_controller.rb +5 -5
  24. data/lib/appoptics_apm/frameworks/rails/inst/action_controller6.rb +50 -0
  25. data/lib/appoptics_apm/frameworks/rails/inst/action_view.rb +11 -24
  26. data/lib/appoptics_apm/frameworks/rails/inst/active_record.rb +3 -3
  27. data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils.rb +1 -1
  28. data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +1 -1
  29. data/lib/appoptics_apm/frameworks/sinatra.rb +3 -32
  30. data/lib/appoptics_apm/inst/curb.rb +6 -6
  31. data/lib/appoptics_apm/inst/faraday.rb +16 -4
  32. data/lib/appoptics_apm/inst/rack.rb +11 -11
  33. data/lib/appoptics_apm/oboe_init_options.rb +17 -4
  34. data/lib/appoptics_apm/sdk/custom_metrics.rb +2 -0
  35. data/lib/appoptics_apm/sdk/tracing.rb +118 -0
  36. data/lib/appoptics_apm/support/transaction_metrics.rb +1 -0
  37. data/lib/appoptics_apm/support/transaction_settings.rb +40 -15
  38. data/lib/appoptics_apm/support/x_trace_options.rb +110 -0
  39. data/lib/appoptics_apm/version.rb +2 -2
  40. data/lib/appoptics_apm/xtrace.rb +7 -7
  41. data/lib/rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb +37 -12
  42. metadata +7 -15
  43. data/Rakefile +0 -229
  44. data/build_gem.sh +0 -15
  45. data/build_gem_upload_to_packagecloud.sh +0 -20
  46. data/lib/appoptics_apm/api/profiling.rb +0 -203
  47. data/lib/appoptics_apm/frameworks/rails/inst/action_controller3.rb +0 -55
  48. data/lib/appoptics_apm/frameworks/rails/inst/action_view_30.rb +0 -50
  49. data/lib/appoptics_apm/legacy_method_profiling.rb +0 -90
  50. data/lib/appoptics_apm/method_profiling.rb +0 -33
  51. data/lib/oboe/README +0 -2
  52. data/lib/oboe/backward_compatibility.rb +0 -80
  53. data/lib/oboe/inst/rack.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: efeb5fdc0a0dec8438fa1ed7af73324858865e20c2705c555effd282232971b1
4
- data.tar.gz: 8d3bbe8905e430d61de61f182793fc1c73e45d8bf0cfdeaa269de136e516edba
2
+ SHA1:
3
+ metadata.gz: 7e70295e3dc49a39e001776c90ae399d1c1ee522
4
+ data.tar.gz: bc03b3d467a18370ce889b6c66228172a41efd5c
5
5
  SHA512:
6
- metadata.gz: 3904ed8d0f79a0786a9fef1e4f9feb555843035fba8165ca225d72682a1576b37a220da1edf7e0e11be34c7553b47cf46908d3e38f81723c90286c27f573e384
7
- data.tar.gz: 9cd0d8b27c28c9c020bcc6990b5e799dbacfebed34707324922416eca0240df5519f76966271a7ae4183624d2c2a43c5a0e93367a5e91e36003e9f61b56cec73
6
+ metadata.gz: f9d957a9d608fd1c3e3499125c96784b9767485934666986c8ecc1ca6befe89d870eb67b087887d5e6caf274452522e52c70dd773bf624a3144c225334688fe8
7
+ data.tar.gz: 01e0625d7242ea1717d5264e65ab3b53df8f4e534e08ba7c67e6959a1e0478d81cdc2dcb6c08d7361008bdf78dbfd962879a59e0fd2ce3302d5c4e9e38e57d1a
data/.gitignore CHANGED
@@ -1,5 +1,5 @@
1
1
  oboe*.gem
2
- Gemfile.lock
2
+ *.lock
3
3
  gemfiles/*.lock
4
4
  .ruby-version
5
5
  *~
@@ -27,3 +27,8 @@ coverage
27
27
  doc
28
28
  .*byebug*
29
29
  gemfiles/vendor*
30
+ scrap*
31
+ .irbrc
32
+ *.code-workspace
33
+ .irb_history
34
+ .bundle/
data/.travis.yml CHANGED
@@ -11,10 +11,11 @@ env:
11
11
  - DBTYPE=mysql
12
12
 
13
13
  rvm:
14
- - 2.6.2
15
- - 2.5.3
14
+ - 2.6.4
15
+ - 2.5.5
16
16
  - 2.4.5
17
- - ruby-head
17
+ - 2.7.0-preview2
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.6.2
37
+ - rvm: 2.7.0-preview2
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.5.3
46
+ - rvm: 2.7.0-preview2
42
47
  env: DBTYPE=mysql
43
- - rvm: 2.4.5
48
+ - rvm: 2.6.4
44
49
  env: DBTYPE=mysql
45
- - rvm: ruby-head
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-preview2
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
- before_install:
89
- - sudo service cassandra stop
90
- - sudo sh -c "echo 'JVM_OPTS=\"\${JVM_OPTS} -Djava.net.preferIPv4Stack=false\"' >> /etc/cassandra/cassandra-env.sh"
91
- - echo "127.0.0.1 localhost" | sudo tee /etc/hosts
92
- - echo "127.0.0.1 " `hostname` | sudo tee -a /etc/hosts
93
- - sudo service cassandra start
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.8/swig-3.0.8.tar.gz
97
- - tar xzf swig-3.0.8.tar.gz
98
- - pushd swig-3.0.8
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 fetch_ext_deps
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: "N=1 bundle exec rake test"
129
+ script: "bundle exec rake test"
115
130
 
116
131
  services:
117
132
  - mongodb
118
133
  - memcached
119
- - cassandra
120
- # - redis
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. Traces are written to /tmp/trace_output.bson. | `false`
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,13 +18,12 @@ group :development, :test do
18
18
  gem 'byebug'
19
19
  gem 'get_process_mem'
20
20
  gem 'memory_profiler'
21
- gem 'stackprof'
22
- end
23
21
 
24
- if defined?(JRUBY_VERSION)
25
- gem 'sinatra', :require => false
26
- else
27
- gem 'sinatra'
22
+ if defined?(JRUBY_VERSION)
23
+ gem 'sinatra', :require => false
24
+ else
25
+ gem 'sinatra'
26
+ end
28
27
  end
29
28
 
30
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/)
@@ -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.0.0'
60
+ s.required_ruby_version = '>= 2.4.0'
58
61
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
59
62
  end
@@ -63,8 +63,6 @@ def do_traced_work
63
63
  end
64
64
  end
65
65
 
66
- # Example with logging
67
66
  AppOpticsAPM::SDK.start_trace('outer_span_2') do
68
- AppopticsAPM.logger.warn "Hello World!"
69
67
  do_traced_work
70
68
  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
@@ -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
  }
@@ -1 +1 @@
1
- 5.0.2
1
+ 7.0.0
@@ -25,196 +25,196 @@
25
25
  MONGO_EXTERN_C_START
26
26
 
27
27
  typedef enum {
28
- bson_error=-1,
29
- bson_eoo=0,
30
- bson_double=1,
31
- bson_string=2,
32
- bson_object=3,
33
- bson_array=4,
34
- bson_bindata=5,
35
- bson_undefined=6,
36
- bson_oid=7,
37
- bson_bool=8,
38
- bson_date=9,
39
- bson_null=10,
40
- bson_regex=11,
41
- bson_dbref=12, /* deprecated */
42
- bson_code=13,
43
- bson_symbol=14,
44
- bson_codewscope=15,
45
- bson_int = 16,
46
- bson_timestamp = 17,
47
- bson_long = 18
48
- } bson_type;
49
-
50
- typedef int bson_bool_t;
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
- bson_bool_t owned;
55
- } bson;
54
+ oboe_bson_bool_t owned;
55
+ } oboe_bson;
56
56
 
57
57
  typedef struct {
58
58
  const char * cur;
59
- bson_bool_t first;
60
- } bson_iterator;
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
- bson_bool_t finished;
66
+ oboe_bson_bool_t finished;
67
67
  int stack[32];
68
68
  int stackPos;
69
- } bson_buffer;
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
- } bson_oid_t;
75
+ } oboe_bson_oid_t;
76
76
  #pragma pack()
77
77
 
78
- typedef int64_t bson_date_t; /* milliseconds since epoch UTC */
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
- bson * bson_empty(bson * obj); /* returns pointer to static empty bson object */
86
- int bson_copy(bson* out, const bson* in); /* puts data in new buffer. NOOP if out==NULL */
87
- bson * bson_from_buffer(bson * b, bson_buffer * buf);
88
- bson * bson_init( bson * b , char * data , bson_bool_t mine );
89
- bson * bson_init_safe( bson * b , char * data , bson_bool_t mine , size_t buflen);
90
- int bson_size(const bson * b );
91
- void bson_destroy( bson * b );
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 bson_print( bson * b );
94
- void bson_print_raw( const char * bson , int depth );
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
- bson_type bson_find(bson_iterator* it, const bson* obj, const char* name);
98
+ oboe_bson_type oboe_bson_find(oboe_bson_iterator* it, const oboe_bson* obj, const char* name);
99
99
 
100
- void bson_iterator_init( bson_iterator * i , const char * bson );
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
- bson_bool_t bson_iterator_more( const bson_iterator * i );
104
- bson_type bson_iterator_next( bson_iterator * i );
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
- bson_type bson_iterator_type( const bson_iterator * i );
107
- const char * bson_iterator_key( const bson_iterator * i );
108
- const char * bson_iterator_value( const bson_iterator * i );
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 bson_iterator_double( const bson_iterator * i );
112
- int bson_iterator_int( const bson_iterator * i );
113
- int64_t bson_iterator_long( const bson_iterator * i );
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
- bson_bool_t bson_iterator_bool( const bson_iterator * i );
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 bson_iterator_double_raw( const bson_iterator * i );
121
- int bson_iterator_int_raw( const bson_iterator * i );
122
- int64_t bson_iterator_long_raw( const bson_iterator * i );
123
- bson_bool_t bson_iterator_bool_raw( const bson_iterator * i );
124
- bson_oid_t* bson_iterator_oid( const bson_iterator * i );
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 * bson_iterator_string( const bson_iterator * i );
128
- int bson_iterator_string_len( const bson_iterator * i );
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 * bson_iterator_code(const bson_iterator * i);
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 bson_iterator_code_scope(const bson_iterator * i, bson * scope);
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
- bson_date_t bson_iterator_date(const bson_iterator * i);
139
- time_t bson_iterator_time_t(const bson_iterator * i);
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 bson_iterator_bin_len( const bson_iterator * i );
142
- char bson_iterator_bin_type( const bson_iterator * i );
143
- const char * bson_iterator_bin_data( const bson_iterator * i );
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 * bson_iterator_regex( const bson_iterator * i );
146
- const char * bson_iterator_regex_opts( const bson_iterator * i );
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 bson_iterator_subobject(const bson_iterator * i, bson * sub);
150
- void bson_iterator_subiterator(const bson_iterator * i, bson_iterator * sub);
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 bson_oid_from_string(bson_oid_t* oid, const char* str);
154
- void bson_oid_to_string(const bson_oid_t* oid, char* str);
155
- void bson_oid_gen(bson_oid_t* oid);
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 bson_oid_generated_time(bson_oid_t* oid); /* Gives the time the OID was created */
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
- bson_buffer * bson_buffer_init( bson_buffer * b );
164
- bson_buffer * bson_ensure_space( bson_buffer * b , const int bytesNeeded );
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 * bson_buffer_finish( bson_buffer * b );
170
- void bson_buffer_destroy( bson_buffer * b );
171
-
172
- bson_buffer * bson_append_oid( bson_buffer * b , const char * name , const bson_oid_t* oid );
173
- bson_buffer * bson_append_int( bson_buffer * b , const char * name , const int i );
174
- bson_buffer * bson_append_long( bson_buffer * b , const char * name , const int64_t i );
175
- bson_buffer * bson_append_double( bson_buffer * b , const char * name , const double d );
176
- bson_buffer * bson_append_string( bson_buffer * b , const char * name , const char * str );
177
- bson_buffer * bson_append_symbol( bson_buffer * b , const char * name , const char * str );
178
- bson_buffer * bson_append_code( bson_buffer * b , const char * name , const char * str );
179
- bson_buffer * bson_append_code_w_scope( bson_buffer * b , const char * name , const char * code , const bson * scope);
180
- bson_buffer * bson_append_binary( bson_buffer * b, const char * name, char type, const char * str, int len );
181
- bson_buffer * bson_append_bool( bson_buffer * b , const char * name , const bson_bool_t v );
182
- bson_buffer * bson_append_null( bson_buffer * b , const char * name );
183
- bson_buffer * bson_append_undefined( bson_buffer * b , const char * name );
184
- bson_buffer * bson_append_regex( bson_buffer * b , const char * name , const char * pattern, const char * opts );
185
- bson_buffer * bson_append_bson( bson_buffer * b , const char * name , const bson* bson);
186
- bson_buffer * bson_append_element( bson_buffer * b, const char * name_or_null, const bson_iterator* elem);
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
- bson_buffer * bson_append_date(bson_buffer * b, const char * name, bson_date_t millis);
190
- bson_buffer * bson_append_time_t(bson_buffer * b, const char * name, time_t secs);
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
- bson_buffer * bson_append_start_object( bson_buffer * b , const char * name );
193
- bson_buffer * bson_append_start_array( bson_buffer * b , const char * name );
194
- bson_buffer * bson_append_finish_object( bson_buffer * b );
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 bson_numstr(char* str, int i);
197
- void bson_incnumstr(char* str);
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 * bson_malloc(int size); /* checks return value */
204
+ void * oboe_bson_malloc(int size); /* checks return value */
205
205
 
206
206
  /* bson_err_handlers shouldn't return!!! */
207
- typedef void(*bson_err_handler)(const char* errmsg);
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
- bson_err_handler set_bson_err_handler(bson_err_handler func);
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 bson_fatal( int ok );
217
- int bson_fatal_msg( int ok, const char* msg );
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