libcouchbase 1.2.8 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -4
  3. data/README.md +16 -8
  4. data/ext/libcouchbase/CMakeLists.txt +34 -32
  5. data/ext/libcouchbase/RELEASE_NOTES.markdown +277 -6
  6. data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +14 -0
  7. data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibevent.cmake +2 -0
  8. data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibuv.cmake +2 -1
  9. data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +2 -0
  10. data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +8 -1
  11. data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
  12. data/ext/libcouchbase/cmake/config-cmake.h.in +14 -0
  13. data/ext/libcouchbase/cmake/configure +8 -26
  14. data/ext/libcouchbase/cmake/defs.mk.in +2 -2
  15. data/ext/libcouchbase/cmake/libcouchbase.stp.in +829 -0
  16. data/ext/libcouchbase/cmake/source_files.cmake +11 -2
  17. data/ext/libcouchbase/contrib/cbsasl/CMakeLists.txt +18 -2
  18. data/ext/libcouchbase/contrib/cbsasl/include/cbsasl/cbsasl.h +44 -2
  19. data/ext/libcouchbase/contrib/cbsasl/src/client.c +285 -73
  20. data/ext/libcouchbase/contrib/cbsasl/src/common.c +4 -0
  21. data/ext/libcouchbase/contrib/cbsasl/src/scram-sha/scram_utils.c +500 -0
  22. data/ext/libcouchbase/contrib/cbsasl/src/scram-sha/scram_utils.h +99 -0
  23. data/ext/libcouchbase/contrib/cliopts/CMakeLists.txt +1 -1
  24. data/ext/libcouchbase/contrib/cliopts/cliopts.h +14 -1
  25. data/ext/libcouchbase/contrib/snappy/CMakeLists.txt +2 -3
  26. data/ext/libcouchbase/contrib/snappy/snappy-sinksource.cc +4 -0
  27. data/ext/libcouchbase/contrib/snappy/snappy-stubs-public.h +7 -5
  28. data/ext/libcouchbase/contrib/snappy/snappy.cc +7 -2
  29. data/ext/libcouchbase/example/crypto/.gitignore +2 -0
  30. data/ext/libcouchbase/example/crypto/Makefile +13 -0
  31. data/ext/libcouchbase/example/crypto/common_provider.c +24 -0
  32. data/ext/libcouchbase/example/crypto/common_provider.h +31 -0
  33. data/ext/libcouchbase/example/crypto/openssl_symmetric_decrypt.c +139 -0
  34. data/ext/libcouchbase/example/crypto/openssl_symmetric_encrypt.c +147 -0
  35. data/ext/libcouchbase/example/crypto/openssl_symmetric_provider.c +281 -0
  36. data/ext/libcouchbase/example/crypto/openssl_symmetric_provider.h +29 -0
  37. data/ext/libcouchbase/example/tracing/.gitignore +2 -0
  38. data/ext/libcouchbase/example/tracing/Makefile +8 -0
  39. data/ext/libcouchbase/example/tracing/cJSON.c +1 -0
  40. data/ext/libcouchbase/example/tracing/cJSON.h +1 -0
  41. data/ext/libcouchbase/example/tracing/tracing.c +439 -0
  42. data/ext/libcouchbase/example/tracing/views.c +444 -0
  43. data/ext/libcouchbase/include/libcouchbase/auth.h +56 -4
  44. data/ext/libcouchbase/include/libcouchbase/cbft.h +8 -0
  45. data/ext/libcouchbase/include/libcouchbase/cntl-private.h +55 -1
  46. data/ext/libcouchbase/include/libcouchbase/cntl.h +101 -1
  47. data/ext/libcouchbase/include/libcouchbase/configuration.h.in +6 -0
  48. data/ext/libcouchbase/include/libcouchbase/couchbase.h +109 -6
  49. data/ext/libcouchbase/include/libcouchbase/crypto.h +140 -0
  50. data/ext/libcouchbase/include/libcouchbase/error.h +38 -2
  51. data/ext/libcouchbase/include/libcouchbase/kvbuf.h +6 -1
  52. data/ext/libcouchbase/include/libcouchbase/metrics.h +79 -0
  53. data/ext/libcouchbase/include/libcouchbase/n1ql.h +9 -0
  54. data/ext/libcouchbase/include/libcouchbase/tracing.h +319 -0
  55. data/ext/libcouchbase/include/libcouchbase/vbucket.h +1 -1
  56. data/ext/libcouchbase/include/libcouchbase/views.h +8 -0
  57. data/ext/libcouchbase/include/memcached/protocol_binary.h +40 -10
  58. data/ext/libcouchbase/packaging/rpm/libcouchbase.spec.in +6 -14
  59. data/ext/libcouchbase/plugins/io/libuv/plugin-internal.h +3 -0
  60. data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +1 -0
  61. data/ext/libcouchbase/plugins/io/select/plugin-select.c +4 -1
  62. data/ext/libcouchbase/src/auth-priv.h +36 -4
  63. data/ext/libcouchbase/src/auth.cc +66 -27
  64. data/ext/libcouchbase/src/bootstrap.cc +1 -1
  65. data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +12 -7
  66. data/ext/libcouchbase/src/bucketconfig/bc_http.cc +26 -17
  67. data/ext/libcouchbase/src/bucketconfig/bc_http.h +1 -1
  68. data/ext/libcouchbase/src/bucketconfig/clconfig.h +4 -2
  69. data/ext/libcouchbase/src/bucketconfig/confmon.cc +6 -3
  70. data/ext/libcouchbase/src/cbft.cc +48 -0
  71. data/ext/libcouchbase/src/cntl.cc +138 -2
  72. data/ext/libcouchbase/src/config_static.h +17 -0
  73. data/ext/libcouchbase/src/connspec.cc +54 -6
  74. data/ext/libcouchbase/src/connspec.h +9 -1
  75. data/ext/libcouchbase/src/crypto.cc +386 -0
  76. data/ext/libcouchbase/src/ctx-log-inl.h +23 -6
  77. data/ext/libcouchbase/src/dump.cc +4 -0
  78. data/ext/libcouchbase/src/getconfig.cc +1 -2
  79. data/ext/libcouchbase/src/handler.cc +65 -27
  80. data/ext/libcouchbase/src/hostlist.cc +35 -7
  81. data/ext/libcouchbase/src/hostlist.h +7 -0
  82. data/ext/libcouchbase/src/http/http-priv.h +2 -0
  83. data/ext/libcouchbase/src/http/http.cc +77 -37
  84. data/ext/libcouchbase/src/http/http_io.cc +19 -2
  85. data/ext/libcouchbase/src/instance.cc +90 -17
  86. data/ext/libcouchbase/src/internal.h +5 -0
  87. data/ext/libcouchbase/src/lcbio/connect.cc +39 -4
  88. data/ext/libcouchbase/src/lcbio/connect.h +27 -0
  89. data/ext/libcouchbase/src/lcbio/ctx.c +49 -23
  90. data/ext/libcouchbase/src/lcbio/ioutils.cc +30 -3
  91. data/ext/libcouchbase/src/lcbio/ioutils.h +2 -0
  92. data/ext/libcouchbase/src/lcbio/manager.cc +44 -8
  93. data/ext/libcouchbase/src/lcbio/manager.h +2 -0
  94. data/ext/libcouchbase/src/lcbio/rw-inl.h +1 -0
  95. data/ext/libcouchbase/src/lcbio/ssl.h +3 -5
  96. data/ext/libcouchbase/src/logging.c +1 -1
  97. data/ext/libcouchbase/src/logging.h +2 -0
  98. data/ext/libcouchbase/src/mc/compress.cc +164 -0
  99. data/ext/libcouchbase/src/mc/compress.h +7 -12
  100. data/ext/libcouchbase/src/mc/mcreq-flush-inl.h +5 -1
  101. data/ext/libcouchbase/src/mc/mcreq.c +11 -1
  102. data/ext/libcouchbase/src/mc/mcreq.h +35 -4
  103. data/ext/libcouchbase/src/mcserver/mcserver.cc +30 -7
  104. data/ext/libcouchbase/src/mcserver/mcserver.h +7 -0
  105. data/ext/libcouchbase/src/mcserver/negotiate.cc +103 -57
  106. data/ext/libcouchbase/src/mcserver/negotiate.h +2 -2
  107. data/ext/libcouchbase/src/mctx-helper.h +11 -0
  108. data/ext/libcouchbase/src/metrics.cc +132 -0
  109. data/ext/libcouchbase/src/n1ql/ixmgmt.cc +2 -1
  110. data/ext/libcouchbase/src/n1ql/n1ql.cc +66 -0
  111. data/ext/libcouchbase/src/newconfig.cc +9 -2
  112. data/ext/libcouchbase/src/operations/counter.cc +2 -1
  113. data/ext/libcouchbase/src/operations/durability-cas.cc +11 -0
  114. data/ext/libcouchbase/src/operations/durability-seqno.cc +3 -0
  115. data/ext/libcouchbase/src/operations/durability.cc +24 -2
  116. data/ext/libcouchbase/src/operations/durability_internal.h +19 -0
  117. data/ext/libcouchbase/src/operations/get.cc +4 -2
  118. data/ext/libcouchbase/src/operations/observe-seqno.cc +1 -0
  119. data/ext/libcouchbase/src/operations/observe.cc +113 -62
  120. data/ext/libcouchbase/src/operations/ping.cc +246 -67
  121. data/ext/libcouchbase/src/operations/remove.cc +2 -1
  122. data/ext/libcouchbase/src/operations/store.cc +17 -14
  123. data/ext/libcouchbase/src/operations/touch.cc +3 -0
  124. data/ext/libcouchbase/src/packetutils.h +68 -4
  125. data/ext/libcouchbase/src/probes.d +132 -161
  126. data/ext/libcouchbase/src/rdb/bigalloc.c +1 -1
  127. data/ext/libcouchbase/src/retryq.cc +6 -2
  128. data/ext/libcouchbase/src/rnd.cc +68 -0
  129. data/ext/libcouchbase/src/rnd.h +39 -0
  130. data/ext/libcouchbase/src/settings.c +27 -0
  131. data/ext/libcouchbase/src/settings.h +67 -3
  132. data/ext/libcouchbase/src/ssl/CMakeLists.txt +0 -12
  133. data/ext/libcouchbase/src/ssl/ssl_common.c +23 -4
  134. data/ext/libcouchbase/src/strcodecs/base64.c +141 -16
  135. data/ext/libcouchbase/src/strcodecs/strcodecs.h +16 -1
  136. data/ext/libcouchbase/src/trace.h +68 -61
  137. data/ext/libcouchbase/src/tracing/span.cc +289 -0
  138. data/ext/libcouchbase/src/tracing/threshold_logging_tracer.cc +171 -0
  139. data/ext/libcouchbase/src/tracing/tracer.cc +53 -0
  140. data/ext/libcouchbase/src/tracing/tracing-internal.h +213 -0
  141. data/ext/libcouchbase/src/utilities.c +5 -0
  142. data/ext/libcouchbase/src/vbucket/CMakeLists.txt +2 -2
  143. data/ext/libcouchbase/src/vbucket/vbucket.c +50 -18
  144. data/ext/libcouchbase/src/views/docreq.cc +26 -1
  145. data/ext/libcouchbase/src/views/docreq.h +17 -0
  146. data/ext/libcouchbase/src/views/viewreq.cc +64 -1
  147. data/ext/libcouchbase/src/views/viewreq.h +21 -0
  148. data/ext/libcouchbase/tests/CMakeLists.txt +6 -6
  149. data/ext/libcouchbase/tests/basic/t_base64.cc +34 -6
  150. data/ext/libcouchbase/tests/basic/t_connstr.cc +14 -0
  151. data/ext/libcouchbase/tests/basic/t_creds.cc +10 -10
  152. data/ext/libcouchbase/tests/basic/t_host.cc +22 -2
  153. data/ext/libcouchbase/tests/basic/t_scram.cc +514 -0
  154. data/ext/libcouchbase/tests/check-all.cc +6 -2
  155. data/ext/libcouchbase/tests/iotests/mock-environment.cc +64 -0
  156. data/ext/libcouchbase/tests/iotests/mock-environment.h +27 -1
  157. data/ext/libcouchbase/tests/iotests/t_confmon.cc +2 -2
  158. data/ext/libcouchbase/tests/iotests/t_forward.cc +8 -0
  159. data/ext/libcouchbase/tests/iotests/t_netfail.cc +124 -0
  160. data/ext/libcouchbase/tests/iotests/t_smoke.cc +1 -1
  161. data/ext/libcouchbase/tests/iotests/t_snappy.cc +316 -0
  162. data/ext/libcouchbase/tests/socktests/socktest.cc +2 -2
  163. data/ext/libcouchbase/tests/socktests/t_basic.cc +6 -6
  164. data/ext/libcouchbase/tests/socktests/t_manager.cc +1 -1
  165. data/ext/libcouchbase/tests/socktests/t_ssl.cc +1 -1
  166. data/ext/libcouchbase/tools/CMakeLists.txt +1 -1
  167. data/ext/libcouchbase/tools/cbc-handlers.h +17 -0
  168. data/ext/libcouchbase/tools/cbc-n1qlback.cc +7 -4
  169. data/ext/libcouchbase/tools/cbc-pillowfight.cc +408 -100
  170. data/ext/libcouchbase/tools/cbc-proxy.cc +134 -3
  171. data/ext/libcouchbase/tools/cbc-subdoc.cc +1 -2
  172. data/ext/libcouchbase/tools/cbc.cc +113 -8
  173. data/ext/libcouchbase/tools/common/histogram.cc +1 -0
  174. data/ext/libcouchbase/tools/common/options.cc +28 -1
  175. data/ext/libcouchbase/tools/common/options.h +5 -0
  176. data/ext/libcouchbase/tools/docgen/docgen.h +36 -10
  177. data/ext/libcouchbase/tools/docgen/loc.h +5 -4
  178. data/ext/libcouchbase/tools/docgen/seqgen.h +28 -0
  179. data/lib/libcouchbase/ext/libcouchbase/enums.rb +10 -0
  180. data/lib/libcouchbase/n1ql.rb +6 -1
  181. data/lib/libcouchbase/version.rb +1 -1
  182. data/spec/connection_spec.rb +6 -6
  183. metadata +38 -5
  184. data/ext/libcouchbase/cmake/Modules/FindCouchbaseSnappy.cmake +0 -11
  185. data/ext/libcouchbase/src/mc/compress.c +0 -90
  186. data/ext/libcouchbase/tools/common/my_inttypes.h +0 -22
@@ -97,8 +97,8 @@ public:
97
97
  /**
98
98
  * @brief Get the mechanism employed for authentication
99
99
  * @param info pointer retrieved via mc_sasl_get()
100
- * @return A string indicating the mechanism used. This may be `PLAIN` or
101
- * `CRAM-MD5`.
100
+ * @return A string indicating the mechanism used. This may be `PLAIN`,
101
+ * `CRAM-MD5`, `SCRAM-SHA1`, `SCRAM-SHA256` or `SCRAM-SHA512` .
102
102
  */
103
103
  const std::string& get_mech() const {
104
104
  return mech;
@@ -25,11 +25,17 @@ protected:
25
25
  virtual lcb_error_t MCTX_addcmd(const lcb_CMDBASE* cmd) = 0;
26
26
  virtual lcb_error_t MCTX_done(const void *cookie) = 0;
27
27
  virtual void MCTX_fail() = 0;
28
+ #ifdef LCB_TRACING
29
+ virtual void MCTX_setspan(lcbtrace_SPAN *span) = 0;
30
+ #endif
28
31
 
29
32
  MultiCmdContext() {
30
33
  lcb_MULTICMD_CTX::addcmd = dispatch_mctx_addcmd;
31
34
  lcb_MULTICMD_CTX::done = dispatch_mctx_done;
32
35
  lcb_MULTICMD_CTX::fail = dispatch_mctx_fail;
36
+ #ifdef LCB_TRACING
37
+ lcb_MULTICMD_CTX::setspan = dispatch_mctx_setspan;
38
+ #endif
33
39
  }
34
40
 
35
41
  virtual ~MultiCmdContext() {}
@@ -44,6 +50,11 @@ private:
44
50
  static void dispatch_mctx_fail(lcb_MULTICMD_CTX* ctx) {
45
51
  static_cast<MultiCmdContext*>(ctx)->MCTX_fail();
46
52
  }
53
+ #ifdef LCB_TRACING
54
+ static void dispatch_mctx_setspan(lcb_MULTICMD_CTX* ctx, lcbtrace_SPAN *span) {
55
+ static_cast<MultiCmdContext*>(ctx)->MCTX_setspan(span);
56
+ }
57
+ #endif
47
58
  };
48
59
 
49
60
  }
@@ -0,0 +1,132 @@
1
+ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2015 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #include "internal.h"
19
+ #include <libcouchbase/metrics.h>
20
+ #include <string>
21
+ #include <vector>
22
+ #include <map>
23
+
24
+ namespace lcbmetrics {
25
+
26
+ class MetricsEntry : public lcb_SERVERMETRICS {
27
+ public:
28
+ std::string m_hostport;
29
+ MetricsEntry(const std::string key) : m_hostport(key) {
30
+ memset(static_cast<lcb_SERVERMETRICS*>(this), 0, sizeof (lcb_SERVERMETRICS));
31
+ iometrics.hostport = m_hostport.c_str();
32
+ }
33
+
34
+ private:
35
+ MetricsEntry();
36
+ MetricsEntry(const MetricsEntry&);
37
+ };
38
+
39
+ class Metrics : public lcb_METRICS {
40
+ public:
41
+ std::vector<MetricsEntry *> entries;
42
+ std::vector<lcb_SERVERMETRICS *> raw_entries;
43
+
44
+ Metrics() {
45
+ memset(static_cast<lcb_METRICS*>(this), 0, sizeof (lcb_METRICS));
46
+ }
47
+
48
+ ~Metrics() {
49
+ for (size_t ii = 0; ii < entries.size(); ++ii) {
50
+ delete entries[ii];
51
+ }
52
+ }
53
+
54
+ MetricsEntry *get(const char *host, const char *port, int create) {
55
+ std::string key;
56
+ key.append(host).append(":").append(port);
57
+ for (size_t ii = 0; ii < entries.size(); ++ii) {
58
+ if (entries[ii]->m_hostport == key) {
59
+ return entries[ii];
60
+ }
61
+ }
62
+
63
+ if (!create) {
64
+ return NULL;
65
+ }
66
+
67
+ MetricsEntry *ent = new MetricsEntry(key);
68
+ entries.push_back(ent);
69
+ raw_entries.push_back(ent);
70
+ nservers = entries.size();
71
+ servers = (const lcb_SERVERMETRICS**) &raw_entries[0];
72
+ return ent;
73
+ }
74
+
75
+ static Metrics *from(lcb_METRICS *metrics) {
76
+ return static_cast<Metrics*>(metrics);
77
+ }
78
+ };
79
+ }
80
+
81
+ using namespace lcbmetrics;
82
+
83
+ extern "C" {
84
+ lcb_METRICS *
85
+ lcb_metrics_new(void)
86
+ {
87
+ return new Metrics();
88
+ }
89
+
90
+ void
91
+ lcb_metrics_destroy(lcb_METRICS *metrics)
92
+ {
93
+ delete Metrics::from(metrics);
94
+ }
95
+
96
+ lcb_SERVERMETRICS *
97
+ lcb_metrics_getserver(lcb_METRICS *metrics, const char *h, const char *p, int c)
98
+ {
99
+ return Metrics::from(metrics)->get(h, p, c);
100
+ }
101
+
102
+ void
103
+ lcb_metrics_dumpio(const lcb_IOMETRICS *metrics, FILE *fp)
104
+ {
105
+ fprintf(fp, "Bytes sent: %lu\n", (unsigned long int)metrics->bytes_sent);
106
+ fprintf(fp, "Bytes received: %lu\n", (unsigned long int)metrics->bytes_received);
107
+ fprintf(fp, "IO Close: %lu\n", (unsigned long int)metrics->io_close);
108
+ fprintf(fp, "IO Error: %lu\n", (unsigned long int)metrics->io_error);
109
+ }
110
+
111
+ void
112
+ lcb_metrics_dumpserver(const lcb_SERVERMETRICS *metrics, FILE *fp)
113
+ {
114
+ lcb_metrics_dumpio(&metrics->iometrics, fp);
115
+ fprintf(fp, "Packets queued: %lu\n", (unsigned long int)metrics->packets_queued);
116
+ fprintf(fp, "Bytes queued: %lu\n", (unsigned long int)metrics->bytes_queued);
117
+ fprintf(fp, "Packets sent: %lu\n", (unsigned long int)metrics->packets_sent);
118
+ fprintf(fp, "Packets received: %lu\n", (unsigned long int)metrics->packets_read);
119
+ fprintf(fp, "Packets errored: %lu\n", (unsigned long int)metrics->packets_errored);
120
+ fprintf(fp, "Packets NMV: %lu\n", (unsigned long int)metrics->packets_nmv);
121
+ fprintf(fp, "Packets timeout: %lu\n", (unsigned long int)metrics->packets_timeout);
122
+ fprintf(fp, "Packets orphaned: %lu", (unsigned long int)metrics->packets_ownerless);
123
+ }
124
+
125
+ void
126
+ lcb_metrics_reset_pipeline_gauges(lcb_SERVERMETRICS *metrics)
127
+ {
128
+ metrics->packets_queued = 0;
129
+ metrics->bytes_queued = 0;
130
+ }
131
+
132
+ }
@@ -736,7 +736,8 @@ WatchIndexCtx::do_poll()
736
736
  lcb_CMDN1XMGMT cmd;
737
737
  memset(&cmd, 0, sizeof cmd);
738
738
  cmd.callback = cb_watch_gotlist;
739
- lcb_log(LOGARGS(this, DEBUG), LOGFMT "Will check for index readiness of %lu indexes. %lu completed", LOGID(this), m_defspend.size(), m_defsok.size());
739
+ lcb_log(LOGARGS(this, DEBUG), LOGFMT "Will check for index readiness of %lu indexes. %lu completed",
740
+ LOGID(this), (unsigned long int)m_defspend.size(), (unsigned long int)m_defsok.size());
740
741
  return lcb_n1x_list(m_instance, this, &cmd);
741
742
  }
742
743
 
@@ -1,3 +1,20 @@
1
+ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2018 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
1
18
  #include <libcouchbase/couchbase.h>
2
19
  #include <libcouchbase/n1ql.h>
3
20
  #include <jsparse/parser.h>
@@ -171,6 +188,10 @@ typedef struct lcb_N1QLREQ : lcb::jsparse::Parser::Actions {
171
188
  /** Is this query to Analytics (CBAS) service */
172
189
  bool is_cbas;
173
190
 
191
+ #ifdef LCB_TRACING
192
+ lcbtrace_SPAN *span;
193
+ #endif
194
+
174
195
  lcb_N1QLCACHE& cache() { return *instance->n1ql_cache; }
175
196
 
176
197
  /**
@@ -424,6 +445,27 @@ lcb_N1QLREQ::~lcb_N1QLREQ()
424
445
  invoke_row(&resp, 1);
425
446
  }
426
447
 
448
+ #ifdef LCB_TRACING
449
+ if (span) {
450
+ if (htreq) {
451
+ lcbio_CTX *ctx = htreq->ioctx;
452
+ if (ctx) {
453
+ std::string remote;
454
+ if (htreq->ipv6) {
455
+ remote = "[" + std::string(htreq->host) + "]:" + std::string(htreq->port);
456
+ } else {
457
+ remote = std::string(htreq->host) + ":" + std::string(htreq->port);
458
+ }
459
+ lcbtrace_span_add_tag_str(span, LCBTRACE_TAG_PEER_ADDRESS, remote.c_str());
460
+ lcbtrace_span_add_tag_str(span, LCBTRACE_TAG_LOCAL_ADDRESS,
461
+ lcbio__inet_ntop(&ctx->sock->info->sa_local).c_str());
462
+ }
463
+ }
464
+ lcbtrace_span_finish(span, LCBTRACE_NOW);
465
+ span = NULL;
466
+ }
467
+ #endif
468
+
427
469
  if (parser) {
428
470
  delete parser;
429
471
  }
@@ -609,6 +651,9 @@ lcb_N1QLREQ::lcb_N1QLREQ(lcb_t obj,
609
651
  cookie(user_cookie), callback(cmd->callback), instance(obj),
610
652
  lasterr(LCB_SUCCESS), flags(cmd->cmdflags), timeout(0),
611
653
  nrows(0), prepare_req(NULL), was_retried(false), is_cbas(false)
654
+ #ifdef LCB_TRACING
655
+ , span(NULL)
656
+ #endif
612
657
  {
613
658
  if (cmd->handle) {
614
659
  *cmd->handle = this;
@@ -675,6 +720,15 @@ lcb_N1QLREQ::lcb_N1QLREQ(lcb_t obj,
675
720
  curCreds["pass"] = ii->second;
676
721
  }
677
722
  }
723
+ #ifdef LCB_TRACING
724
+ if (instance->settings->tracer) {
725
+ char id[20] = {0};
726
+ snprintf(id, sizeof(id), "%p", (void *)this);
727
+ span = lcbtrace_span_start(instance->settings->tracer, LCBTRACE_OP_DISPATCH_TO_SERVER, LCBTRACE_NOW, NULL);
728
+ lcbtrace_span_add_tag_str(span, LCBTRACE_TAG_OPERATION_ID, id);
729
+ lcbtrace_span_add_system_tags(span, instance->settings, is_cbas ? LCBTRACE_TAG_SERVICE_ANALYTICS : LCBTRACE_TAG_SERVICE_N1QL);
730
+ }
731
+ #endif
678
732
  }
679
733
 
680
734
  LIBCOUCHBASE_API
@@ -753,3 +807,15 @@ lcb_n1ql_cancel(lcb_t instance, lcb_N1QLHANDLE handle)
753
807
  }
754
808
  handle->callback = NULL;
755
809
  }
810
+
811
+ #ifdef LCB_TRACING
812
+
813
+ LIBCOUCHBASE_API
814
+ void lcb_n1ql_set_parent_span(lcb_t, lcb_N1QLHANDLE handle, lcbtrace_SPAN *span)
815
+ {
816
+ if (handle) {
817
+ lcbtrace_span_set_parent(handle->span, span);
818
+ }
819
+ }
820
+
821
+ #endif
@@ -24,8 +24,12 @@
24
24
  #define LOGARGS(instance, lvl) (instance)->settings, "newconfig", LCB_LOG_##lvl, __FILE__, __LINE__
25
25
  #define LOG(instance, lvlbase, msg) lcb_log(instance->settings, "newconfig", LCB_LOG_##lvlbase, __FILE__, __LINE__, msg)
26
26
 
27
- #define SERVER_FMT "%s:%s (%p)"
28
- #define SERVER_ARGS(s) (s)->get_host().host, (s)->get_host().port, (void *)s
27
+ #define SERVER_FMT LCB_LOG_SPEC("%s:%s") " (%p)"
28
+ #define SERVER_ARGS(s) \
29
+ (s)->settings->log_redaction ? LCB_LOG_SD_OTAG : "", \
30
+ (s)->get_host().host, (s)->get_host().port, \
31
+ (s)->settings->log_redaction ? LCB_LOG_SD_CTAG : "", \
32
+ (void *)s
29
33
 
30
34
  typedef struct lcb_GUESSVB_st {
31
35
  time_t last_update; /**< Last time this vBucket was heuristically set */
@@ -93,6 +97,9 @@ lcb_vbguess_newconfig(lcb_t instance, lcbvb_CONFIG *cfg, lcb_GUESSVB *guesses)
93
97
  int
94
98
  lcb_vbguess_remap(lcb_t instance, int vbid, int bad)
95
99
  {
100
+ if (LCBT_SETTING(instance, vb_noremap)) {
101
+ return -1;
102
+ }
96
103
 
97
104
  if (LCBT_SETTING(instance, vb_noguess)) {
98
105
  int newix = lcbvb_nmv_remap_ex(LCBT_VBCONFIG(instance), vbid, bad, 0);
@@ -72,7 +72,8 @@ lcb_counter3(
72
72
  }
73
73
 
74
74
  memcpy(SPAN_BUFFER(&packet->kh_span), acmd.bytes, sizeof(acmd.bytes));
75
- TRACE_ARITHMETIC_BEGIN(hdr, cmd);
75
+ LCBTRACE_KV_START(instance->settings, cmd, LCBTRACE_OP_COUNTER, packet->opaque, rdata->span);
76
+ TRACE_ARITHMETIC_BEGIN(instance, hdr, cmd);
76
77
  LCB_SCHED_ADD(instance, pipeline, packet);
77
78
  return LCB_SUCCESS;
78
79
  }
@@ -186,6 +186,17 @@ CasDurset::poll_impl()
186
186
  cmd.servers_ = servers;
187
187
  cmd.nservers_ = nservers;
188
188
 
189
+ #ifdef LCB_TRACING
190
+ if (instance->settings->tracer) {
191
+ lcbtrace_REF ref;
192
+ ref.type = LCBTRACE_REF_CHILD_OF;
193
+ ref.span = span;
194
+ lcbtrace_SPAN *child =
195
+ lcbtrace_span_start(instance->settings->tracer, LCBTRACE_OP_OBSERVE_CAS_ROUND, LCBTRACE_NOW, &ref);
196
+ lcbtrace_span_add_system_tags(child, instance->settings, LCBTRACE_TAG_SERVICE_KV);
197
+ mctx->setspan(mctx, child);
198
+ }
199
+ #endif
189
200
  err = mctx->addcmd(mctx, (lcb_CMDBASE *)&cmd);
190
201
  if (err != LCB_SUCCESS) {
191
202
  mctx->fail(mctx);
@@ -120,6 +120,9 @@ SeqnoDurset::poll_impl()
120
120
  for (size_t jj = 0; jj < nservers; jj++) {
121
121
  lcb_error_t err;
122
122
  cmd.server_index = servers[jj];
123
+ #ifdef LCB_TRACING
124
+ LCB_CMD_SET_TRACESPAN(&cmd, span);
125
+ #endif
123
126
  err = lcb_observe_seqno3(instance, &ent.callback, &cmd);
124
127
  if (err == LCB_SUCCESS) {
125
128
  waiting++;
@@ -158,7 +158,7 @@ Item::update(int flags, int srvix)
158
158
  bool is_master = lcbvb_vbmaster(LCBT_VBCONFIG(instance), vbid) == srvix;
159
159
  const lcb::Server *server = instance->get_server(srvix);
160
160
 
161
- memset(info, 0, sizeof(*info));
161
+ info->clear();
162
162
  info->server = server;
163
163
 
164
164
  if (flags & UPDATE_PERSISTED) {
@@ -249,6 +249,13 @@ Durset::on_poll_done()
249
249
 
250
250
  if (nremaining > 0) {
251
251
  switch_state(STATE_OBSPOLL);
252
+ #ifdef LCB_TRACING
253
+ } else {
254
+ if (span) {
255
+ lcbtrace_span_finish(span, LCBTRACE_NOW);
256
+ span = NULL;
257
+ }
258
+ #endif
252
259
  }
253
260
  decref();
254
261
  }
@@ -326,6 +333,13 @@ lcb_durability_validate(lcb_t instance,
326
333
 
327
334
  }
328
335
 
336
+ #ifdef LCB_TRACING
337
+ void Durset::MCTX_setspan(lcbtrace_SPAN *span_)
338
+ {
339
+ span = span_;
340
+ }
341
+ #endif
342
+
329
343
  lcb_error_t Durset::MCTX_addcmd(const lcb_CMDBASE *cmd) {
330
344
  if (LCB_KEYBUF_IS_EMPTY(&cmd->key)) {
331
345
  return LCB_EMPTY_KEY;
@@ -339,7 +353,6 @@ lcb_error_t Durset::MCTX_addcmd(const lcb_CMDBASE *cmd) {
339
353
  MCREQ_PKT_BASESIZE, &vbid, &srvix);
340
354
 
341
355
  /* ok. now let's initialize the entry..*/
342
- memset(&ent, 0, sizeof (ent));
343
356
  ent.res().nkey = cmd->key.contig.nbytes;
344
357
  ent.reqcas = cmd->cas;
345
358
  ent.parent = this;
@@ -384,6 +397,12 @@ Durset::MCTX_done(const void *cookie_) {
384
397
  }
385
398
 
386
399
  void Durset::MCTX_fail() {
400
+ #ifdef LCB_TRACING
401
+ if (span) {
402
+ lcbtrace_span_finish(span, LCBTRACE_NOW);
403
+ span = NULL;
404
+ }
405
+ #endif
387
406
  delete this;
388
407
  }
389
408
 
@@ -426,6 +445,9 @@ Durset::Durset(lcb_t instance_, const lcb_durability_opts_t *options)
426
445
  nremaining(0), waiting(0), refcnt(0), next_state(STATE_OBSPOLL),
427
446
  lasterr(LCB_SUCCESS), is_durstore(false), cookie(NULL),
428
447
  ns_timeout(0), timer(NULL), instance(instance_)
448
+ #ifdef LCB_TRACING
449
+ , span(NULL)
450
+ #endif
429
451
  {
430
452
  const lcb_DURABILITYOPTSv0 *opts_in = &options->v.v0;
431
453
 
@@ -102,11 +102,24 @@ struct Durset;
102
102
  // For use in conjunction with MCREQ_F_PRIVCALLBACK
103
103
  struct CallbackCookie {
104
104
  lcb_RESPCALLBACK callback;
105
+
106
+ CallbackCookie() : callback(NULL) {}
105
107
  };
106
108
 
107
109
  /**Information a single entry in a durability set. Each entry contains a single
108
110
  * key */
109
111
  struct Item : public CallbackCookie {
112
+ Item():
113
+ reqcas(0),
114
+ reqseqno(0),
115
+ uuid(0),
116
+ result(),
117
+ parent(NULL),
118
+ vbid(0),
119
+ done(0)
120
+ {
121
+ }
122
+
110
123
  /**
111
124
  * Returns true if the entry is complete, false otherwise. This only assumes
112
125
  * successful entries.
@@ -253,6 +266,9 @@ struct Durset : public MultiCmdContext {
253
266
  lcb_error_t MCTX_done(const void *cookie);
254
267
  lcb_error_t MCTX_addcmd(const lcb_CMDBASE *cmd);
255
268
  void MCTX_fail();
269
+ #ifdef LCB_TRACING
270
+ void MCTX_setspan(lcbtrace_SPAN *span);
271
+ #endif
256
272
 
257
273
  /**
258
274
  * This function calls poll_impl(). The implementation should then call
@@ -279,6 +295,9 @@ struct Durset : public MultiCmdContext {
279
295
  hrtime_t ns_timeout; /**< Timestamp of next timeout */
280
296
  void *timer;
281
297
  lcb_t instance;
298
+ #ifdef LCB_TRACING
299
+ lcbtrace_SPAN *span;
300
+ #endif
282
301
  };
283
302
 
284
303
  } // namespace durability