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
@@ -513,7 +513,37 @@ typedef enum {
513
513
  X(LCB_NAMESERVER_ERROR, 0x53, LCB_ERRTYPE_NETWORK, \
514
514
  "Invalid reply received from nameserver") \
515
515
  X(LCB_NOT_AUTHORIZED, 0x54, LCB_ERRTYPE_INPUT|LCB_ERRTYPE_SRVGEN, \
516
- "Not authorized for operation")
516
+ "Not authorized for operation") \
517
+ X(LCB_SUBDOC_INVALID_COMBO, 0x55, \
518
+ LCB_ERRTYPE_INPUT|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
519
+ "An invalid combination of commands was specified") \
520
+ X(LCB_SUBDOC_MULTI_PATH_FAILURE, 0x56, \
521
+ LCB_ERRTYPE_INPUT|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
522
+ "Specified key was successfully found, but one or more path operations failed") \
523
+ X(LCB_SUBDOC_SUCCESS_DELETED, 0x57, \
524
+ LCB_ERRTYPE_INPUT|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
525
+ "The operation completed successfully, but operated on a deleted document") \
526
+ X(LCB_SUBDOC_XATTR_INVALID_FLAG_COMBO, 0x58, \
527
+ LCB_ERRTYPE_INPUT|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
528
+ "The combination of the subdoc flags for the xattrs is not valid") \
529
+ X(LCB_SUBDOC_XATTR_INVALID_KEY_COMBO, 0x59, \
530
+ LCB_ERRTYPE_INPUT|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
531
+ "Only a single xattr key may be accessed at the same time") \
532
+ X(LCB_SUBDOC_XATTR_UNKNOWN_MACRO, 0x5a, \
533
+ LCB_ERRTYPE_INPUT|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
534
+ "The server has no knowledge of the requested macro") \
535
+ X(LCB_SUBDOC_XATTR_UNKNOWN_VATTR, 0x5b, \
536
+ LCB_ERRTYPE_INPUT|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
537
+ "The server has no knowledge of the requested virtual xattr") \
538
+ X(LCB_SUBDOC_XATTR_CANT_MODIFY_VATTR, 0x5c, \
539
+ LCB_ERRTYPE_INPUT|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
540
+ "Virtual xattrs cannot be modified") \
541
+ X(LCB_SUBDOC_MULTI_PATH_FAILURE_DELETED, 0x5d, \
542
+ LCB_ERRTYPE_INPUT|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
543
+ "Specified key was found as a deleted document, but one or more path operations failed") \
544
+ X(LCB_SUBDOC_INVALID_XATTR_ORDER, 0x5e, \
545
+ LCB_ERRTYPE_INPUT|LCB_ERRTYPE_SRVGEN|LCB_ERRTYPE_SUBDOC, \
546
+ "According to the spec all xattr commands should come first, followed by the commands for the document body")
517
547
 
518
548
  /** Error codes returned by the library. */
519
549
  typedef enum {
@@ -584,10 +614,16 @@ const char *lcb_strerror(lcb_t instance, lcb_error_t error);
584
614
  LCB_INTERNAL_API
585
615
  const char *lcb_strerror_short(lcb_error_t error);
586
616
 
617
+ /**
618
+ * Get a longer textual description of an error message.
619
+ */
620
+ LCB_INTERNAL_API
621
+ const char *lcb_strerror_long(lcb_error_t error);
622
+
587
623
  /**
588
624
  * This may be used in conjunction with the errmap callback if it wishes
589
625
  * to fallback for default behavior for the given code.
590
- * @uncomitted
626
+ * @uncommitted
591
627
  */
592
628
  LIBCOUCHBASE_API
593
629
  lcb_error_t lcb_errmap_default(lcb_t instance, lcb_U16 code);
@@ -43,7 +43,12 @@ typedef enum {
43
43
  * The buffers are not contiguous (multi-part buffers) but should be
44
44
  * copied. This avoids having to make the buffers contiguous before
45
45
  * passing it into the library (only to have the library copy it again) */
46
- LCB_KV_IOVCOPY
46
+ LCB_KV_IOVCOPY,
47
+
48
+ /**
49
+ * For use within the hashkey field, indicates that the _pointer to bytes_
50
+ * of the hashkey is the tracing span, rather than an actual hashkey */
51
+ LCB_KV_TRACESPAN
47
52
  } lcb_KVBUFTYPE;
48
53
 
49
54
  #define LCB_KV_HEADER_AND_KEY LCB_KV_CONTIG
@@ -0,0 +1,79 @@
1
+ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2017 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
+ #ifndef LCB_METRICS_H
19
+ #define LCB_METRICS_H
20
+
21
+ #ifdef __cplusplus
22
+ extern "C" {
23
+ #endif
24
+
25
+ struct lcb_METRICS_st;
26
+
27
+ typedef struct lcb_IOMETRICS_st {
28
+ const char *hostport;
29
+ lcb_SIZE io_close;
30
+ lcb_SIZE io_error;
31
+ lcb_SIZE bytes_sent;
32
+ lcb_SIZE bytes_received;
33
+ } lcb_IOMETRICS;
34
+
35
+ typedef struct lcb_SERVERMETRICS_st {
36
+ /** IO Metrics for the underlying socket */
37
+ lcb_IOMETRICS iometrics;
38
+
39
+ /** Number of packets sent on this server */
40
+ lcb_SIZE packets_sent;
41
+
42
+ /** Number of packets read on this server */
43
+ lcb_SIZE packets_read;
44
+
45
+ /** Total number of packets placed in send queue */
46
+ lcb_SIZE packets_queued;
47
+
48
+ /** Total number of bytes placed in send queue */
49
+ lcb_SIZE bytes_queued;
50
+
51
+ /**
52
+ * Number of packets which failed on this server (i.e. as a result
53
+ * of a timeout/network error or similar)
54
+ */
55
+ lcb_SIZE packets_errored;
56
+
57
+ /** Number of packets which timed out. Subset of packets_errored */
58
+ lcb_SIZE packets_timeout;
59
+
60
+ /** Number of packets received which were timed out or otherwise cancelled */
61
+ lcb_SIZE packets_ownerless;
62
+
63
+ /** Number of NOT_MY_VBUCKET replies received */
64
+ lcb_SIZE packets_nmv;
65
+ } lcb_SERVERMETRICS;
66
+
67
+ typedef struct lcb_METRICS_st {
68
+ lcb_SIZE nservers;
69
+ const lcb_SERVERMETRICS **servers;
70
+
71
+ /** Number of times a packet entered the retry queue */
72
+ lcb_SIZE packets_retried;
73
+ } lcb_METRICS;
74
+
75
+ #ifdef __cplusplus
76
+ }
77
+ #endif
78
+
79
+ #endif
@@ -446,6 +446,15 @@ lcb_n1ql_query(lcb_t instance, const void *cookie, const lcb_CMDN1QL *cmd);
446
446
  LIBCOUCHBASE_API
447
447
  void
448
448
  lcb_n1ql_cancel(lcb_t instance, lcb_N1QLHANDLE handle);
449
+
450
+ #ifdef LCB_TRACING
451
+ /**
452
+ * @uncommitted
453
+ */
454
+ LIBCOUCHBASE_API
455
+ void lcb_n1ql_set_parent_span(lcb_t instance, lcb_N1QLHANDLE handle, lcbtrace_SPAN *span);
456
+ #endif
457
+
449
458
  /**@}*/
450
459
 
451
460
  /**@}*/
@@ -0,0 +1,319 @@
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
+
18
+ #if !defined(LCB_TRACING_H) && defined(LCB_TRACING)
19
+ #define LCB_TRACING_H
20
+
21
+ /**
22
+ * @file
23
+ * End to end tracing
24
+ *
25
+ * @uncommitted
26
+ */
27
+
28
+ #ifdef __cplusplus
29
+ namespace lcb
30
+ {
31
+ namespace trace
32
+ {
33
+ class Span;
34
+ class Tracer;
35
+ } // namespace trace
36
+ } // namespace lcb
37
+ typedef lcb::trace::Span lcbtrace_SPAN;
38
+ extern "C" {
39
+ #else /* C only! */
40
+ typedef struct lcbtrace_SPAN_Cdummy lcbtrace_SPAN;
41
+ #endif
42
+
43
+ #define LCBTRACE_F_THRESHOLD 0x01
44
+
45
+ struct lcbtrace_TRACER;
46
+ typedef struct lcbtrace_TRACER {
47
+ lcb_U16 version;
48
+ lcb_U64 flags;
49
+ void *cookie;
50
+ void (*destructor)(struct lcbtrace_TRACER *tracer);
51
+ union {
52
+ struct {
53
+ void (*report)(struct lcbtrace_TRACER *tracer, lcbtrace_SPAN *span);
54
+ } v0;
55
+ } v;
56
+ } lcbtrace_TRACER;
57
+
58
+ /**
59
+ * @uncommitted
60
+ * @return tracer
61
+ */
62
+ LIBCOUCHBASE_API lcbtrace_TRACER *lcb_get_tracer(lcb_t instance);
63
+
64
+ /**
65
+ * @uncommitted
66
+ * @return tracer
67
+ */
68
+ LIBCOUCHBASE_API void lcb_set_tracer(lcb_t instance, lcbtrace_TRACER *tracer);
69
+
70
+ /**
71
+ * @uncommitted
72
+ */
73
+ LIBCOUCHBASE_API lcbtrace_TRACER *lcbtrace_new(lcb_t instance, lcb_U64 flags);
74
+
75
+ /**
76
+ * @uncommitted
77
+ */
78
+ LIBCOUCHBASE_API void lcbtrace_destroy(lcbtrace_TRACER *tracer);
79
+
80
+ typedef enum {
81
+ LCBTRACE_REF_NONE = 0,
82
+ LCBTRACE_REF_CHILD_OF = 1,
83
+ LCBTRACE_REF_FOLLOWS_FROM,
84
+ LCBTRACE_REF__MAX
85
+ } lcbtrace_REF_TYPE;
86
+
87
+ typedef struct {
88
+ lcbtrace_REF_TYPE type;
89
+ lcbtrace_SPAN *span;
90
+ } lcbtrace_REF;
91
+
92
+ #define LCBTRACE_OP_GET "get"
93
+
94
+ /** zero means the library will trigger timestamp automatically */
95
+ #define LCBTRACE_NOW 0
96
+
97
+ /**
98
+ * @return time in microseconds
99
+ */
100
+ LIBCOUCHBASE_API
101
+ lcb_U64 lcbtrace_now(void);
102
+
103
+ /**
104
+ * @uncommitted
105
+ * @param tracer
106
+ * @param operation
107
+ * @param now
108
+ * @param ctx
109
+ */
110
+ LIBCOUCHBASE_API
111
+ lcbtrace_SPAN *lcbtrace_span_start(lcbtrace_TRACER *tracer, const char *operation, lcb_U64 now, lcbtrace_REF *ref);
112
+
113
+ /**
114
+ * @uncommitted
115
+ * @param span
116
+ * @param now
117
+ */
118
+ LIBCOUCHBASE_API
119
+ void lcbtrace_span_finish(lcbtrace_SPAN *span, lcb_U64 now);
120
+
121
+ /**
122
+ * @uncommitted
123
+ */
124
+ LIBCOUCHBASE_API
125
+ lcb_U64 lcbtrace_span_get_start_ts(lcbtrace_SPAN *span);
126
+
127
+ /**
128
+ * @uncommitted
129
+ */
130
+ LIBCOUCHBASE_API
131
+ lcb_U64 lcbtrace_span_get_finish_ts(lcbtrace_SPAN *span);
132
+
133
+ /**
134
+ * @uncommitted
135
+ */
136
+ LIBCOUCHBASE_API
137
+ int lcbtrace_span_is_orphaned(lcbtrace_SPAN *span);
138
+
139
+ /**
140
+ * @uncomitted
141
+ */
142
+ LIBCOUCHBASE_API
143
+ const char *lcbtrace_span_get_operation(lcbtrace_SPAN *span);
144
+
145
+ #define LCBTRACE_OP_REQUEST_ENCODING "request_encoding"
146
+ #define LCBTRACE_OP_DISPATCH_TO_SERVER "dispatch_to_server"
147
+ #define LCBTRACE_OP_RESPONSE_DECODING "response_decoding"
148
+
149
+ #define LCBTRACE_OP_ADD "add"
150
+ #define LCBTRACE_OP_APPEND "append"
151
+ #define LCBTRACE_OP_COUNTER "counter"
152
+ #define LCBTRACE_OP_GET "get"
153
+ #define LCBTRACE_OP_GET_FROM_REPLICA "get_from_replica"
154
+ #define LCBTRACE_OP_INSERT "insert"
155
+ #define LCBTRACE_OP_OBSERVE_CAS "observe_cas"
156
+ #define LCBTRACE_OP_OBSERVE_CAS_ROUND "observe_cas_round"
157
+ #define LCBTRACE_OP_OBSERVE_SEQNO "observe_seqno"
158
+ #define LCBTRACE_OP_PREPEND "prepend"
159
+ #define LCBTRACE_OP_REMOVE "remove"
160
+ #define LCBTRACE_OP_REPLACE "replace"
161
+ #define LCBTRACE_OP_TOUCH "touch"
162
+ #define LCBTRACE_OP_UNLOCK "unlock"
163
+ #define LCBTRACE_OP_UPSERT "upsert"
164
+ #define LCBTRACE_OP_UPSERT "upsert"
165
+
166
+ #define LCBTRACE_OP_STORE2NAME(code) \
167
+ (code == LCB_ADD) ? LCBTRACE_OP_ADD : \
168
+ (code == LCB_PREPEND) ? LCBTRACE_OP_PREPEND : \
169
+ (code == LCB_APPEND) ? LCBTRACE_OP_APPEND : \
170
+ LCBTRACE_OP_UPSERT
171
+
172
+ #define LCBTRACE_TAG_DB_TYPE "db.type"
173
+ #define LCBTRACE_TAG_SPAN_KIND "span.kind"
174
+ /**
175
+ * Bucket name
176
+ */
177
+ #define LCBTRACE_TAG_DB_INSTANCE "db.instance"
178
+ /**
179
+ * The client's identifier string (the 'u' property in the updated HELLO request),
180
+ * the same one that is shared with the server to identify the SDK.
181
+ */
182
+ #define LCBTRACE_TAG_COMPONENT "component"
183
+ /**
184
+ * The unique ID of the operation
185
+ */
186
+ #define LCBTRACE_TAG_OPERATION_ID "couchbase.operation_id"
187
+ /**
188
+ * The service type, one of the following:
189
+ * kv, view, n1ql, search, analytics
190
+ */
191
+ #define LCBTRACE_TAG_SERVICE "couchbase.service"
192
+ #define LCBTRACE_TAG_SERVICE_KV "kv"
193
+ #define LCBTRACE_TAG_SERVICE_VIEW "view"
194
+ #define LCBTRACE_TAG_SERVICE_N1QL "n1ql"
195
+ #define LCBTRACE_TAG_SERVICE_SEARCH "search"
196
+ #define LCBTRACE_TAG_SERVICE_ANALYTICS "analytics"
197
+
198
+ #define LCBTRACE_TAG_LOCAL_ID "couchbase.local_id"
199
+ /**
200
+ * The local socket hostname / IP and port, in the format: {hostname}:{port}
201
+ * To be added to dispatch spans when the local socket is available.
202
+ */
203
+ #define LCBTRACE_TAG_LOCAL_ADDRESS "local.address"
204
+ /**
205
+ * The remote socket hostname / IP and port, in the format: {hostname}:{port}
206
+ * To be added to dispatch spans when the local socket is available.
207
+ */
208
+ #define LCBTRACE_TAG_PEER_ADDRESS "peer.address"
209
+ /**
210
+ * The server duration with precision suffix. The suffix is required to indicate
211
+ * precision because KV is recorded in microseconds and N1QL query metrics
212
+ * use milliseconds.
213
+ * For example: 123us, 32.12ms
214
+ */
215
+ #define LCBTRACE_TAG_PEER_LATENCY "peer.latency"
216
+
217
+ /**
218
+ * @uncommitted
219
+ */
220
+ LIBCOUCHBASE_API
221
+ lcb_U64 lcbtrace_span_get_span_id(lcbtrace_SPAN *span);
222
+
223
+ /**
224
+ * @uncommitted
225
+ */
226
+ LIBCOUCHBASE_API
227
+ lcb_U64 lcbtrace_span_get_trace_id(lcbtrace_SPAN *span);
228
+
229
+ /**
230
+ * @uncommitted
231
+ */
232
+ LIBCOUCHBASE_API
233
+ lcbtrace_SPAN *lcbtrace_span_get_parent(lcbtrace_SPAN *span);
234
+
235
+ /**
236
+ * @uncommitted
237
+ */
238
+ LIBCOUCHBASE_API
239
+ lcb_error_t lcbtrace_span_get_tag_str(lcbtrace_SPAN *span, const char *name, char **value, size_t *nvalue);
240
+
241
+ /**
242
+ * @uncommitted
243
+ */
244
+ LIBCOUCHBASE_API
245
+ lcb_error_t lcbtrace_span_get_tag_uint64(lcbtrace_SPAN *span, const char *name, lcb_U64 *value);
246
+
247
+ /**
248
+ * @uncommitted
249
+ */
250
+ LIBCOUCHBASE_API
251
+ lcb_error_t lcbtrace_span_get_tag_double(lcbtrace_SPAN *span, const char *name, double *value);
252
+
253
+ /**
254
+ * @uncommitted
255
+ */
256
+ LIBCOUCHBASE_API
257
+ lcb_error_t lcbtrace_span_get_tag_bool(lcbtrace_SPAN *span, const char *name, int value);
258
+
259
+ /**
260
+ * @uncommitted
261
+ * @param span
262
+ * @param name
263
+ * @param value
264
+ */
265
+ LIBCOUCHBASE_API
266
+ void lcbtrace_span_add_tag_str(lcbtrace_SPAN *span, const char *name, const char *value);
267
+
268
+ /**
269
+ * @uncommitted
270
+ * @param span
271
+ * @param name
272
+ * @param value
273
+ */
274
+ LIBCOUCHBASE_API
275
+ void lcbtrace_span_add_tag_uint64(lcbtrace_SPAN *span, const char *name, lcb_U64 value);
276
+
277
+ /**
278
+ * @uncommitted
279
+ * @param span
280
+ * @param name
281
+ * @param value
282
+ */
283
+ LIBCOUCHBASE_API
284
+ void lcbtrace_span_add_tag_double(lcbtrace_SPAN *span, const char *name, double value);
285
+
286
+ /**
287
+ * @uncommitted
288
+ * @param span
289
+ * @param name
290
+ * @param value
291
+ */
292
+ LIBCOUCHBASE_API
293
+ void lcbtrace_span_add_tag_bool(lcbtrace_SPAN *span, const char *name, int value);
294
+
295
+ /**
296
+ * Sets the tracing context for the command.
297
+ *
298
+ * @param cmd the command structure
299
+ * @param ctx the lcbtrace_SPAN pointer
300
+ * @uncommitted
301
+ */
302
+ #define LCB_CMD_SET_TRACESPAN(cmd, span) \
303
+ do { \
304
+ (cmd)->_hashkey.type = LCB_KV_TRACESPAN; \
305
+ (cmd)->_hashkey.contig.bytes = span; \
306
+ } while (0);
307
+
308
+ /**
309
+ * @uncommitted
310
+ */
311
+ typedef struct {
312
+ void *state;
313
+ void (*report)(void *state, lcbtrace_SPAN *span);
314
+ } ldcptrace_REPORTER;
315
+
316
+ #ifdef __cplusplus
317
+ }
318
+ #endif
319
+ #endif /* LCB_TRACING_H */