couchbase 3.9.0-aarch64-mingw-ucrt
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 +7 -0
- data/LICENSE.txt +202 -0
- data/README.md +154 -0
- data/ext/extconf.rb +0 -0
- data/lib/active_support/cache/couchbase_store.rb +407 -0
- data/lib/couchbase/3.4/libcouchbase.so +0 -0
- data/lib/couchbase/4.0/libcouchbase.so +0 -0
- data/lib/couchbase/analytics_options.rb +109 -0
- data/lib/couchbase/authenticator.rb +80 -0
- data/lib/couchbase/binary_collection.rb +145 -0
- data/lib/couchbase/binary_collection_options.rb +26 -0
- data/lib/couchbase/bucket.rb +173 -0
- data/lib/couchbase/cluster.rb +555 -0
- data/lib/couchbase/cluster_registry.rb +49 -0
- data/lib/couchbase/collection.rb +770 -0
- data/lib/couchbase/collection_options.rb +401 -0
- data/lib/couchbase/config_profiles.rb +57 -0
- data/lib/couchbase/configuration.rb +58 -0
- data/lib/couchbase/datastructures/couchbase_list.rb +192 -0
- data/lib/couchbase/datastructures/couchbase_map.rb +231 -0
- data/lib/couchbase/datastructures/couchbase_queue.rb +161 -0
- data/lib/couchbase/datastructures/couchbase_set.rb +145 -0
- data/lib/couchbase/datastructures.rb +26 -0
- data/lib/couchbase/deprecations.rb +61 -0
- data/lib/couchbase/diagnostics.rb +183 -0
- data/lib/couchbase/errors.rb +438 -0
- data/lib/couchbase/fork_hooks.rb +41 -0
- data/lib/couchbase/get_replica_strategy.rb +89 -0
- data/lib/couchbase/json_transcoder.rb +41 -0
- data/lib/couchbase/key_value_scan.rb +119 -0
- data/lib/couchbase/libcouchbase.rb +6 -0
- data/lib/couchbase/logger.rb +87 -0
- data/lib/couchbase/management/analytics_index_manager.rb +1160 -0
- data/lib/couchbase/management/bucket_manager.rb +479 -0
- data/lib/couchbase/management/collection_manager.rb +515 -0
- data/lib/couchbase/management/collection_query_index_manager.rb +247 -0
- data/lib/couchbase/management/query_index_manager.rb +671 -0
- data/lib/couchbase/management/scope_search_index_manager.rb +267 -0
- data/lib/couchbase/management/search_index_manager.rb +649 -0
- data/lib/couchbase/management/user_manager.rb +639 -0
- data/lib/couchbase/management/view_index_manager.rb +332 -0
- data/lib/couchbase/management.rb +31 -0
- data/lib/couchbase/metrics/logging_meter.rb +108 -0
- data/lib/couchbase/metrics/logging_value_recorder.rb +50 -0
- data/lib/couchbase/metrics/meter.rb +27 -0
- data/lib/couchbase/metrics/noop_meter.rb +30 -0
- data/lib/couchbase/metrics/noop_value_recorder.rb +27 -0
- data/lib/couchbase/metrics/value_recorder.rb +25 -0
- data/lib/couchbase/mutation_state.rb +65 -0
- data/lib/couchbase/options.rb +3097 -0
- data/lib/couchbase/protostellar/binary_collection.rb +55 -0
- data/lib/couchbase/protostellar/bucket.rb +59 -0
- data/lib/couchbase/protostellar/client.rb +97 -0
- data/lib/couchbase/protostellar/cluster.rb +182 -0
- data/lib/couchbase/protostellar/collection.rb +156 -0
- data/lib/couchbase/protostellar/connect_options.rb +63 -0
- data/lib/couchbase/protostellar/error_handling.rb +204 -0
- data/lib/couchbase/protostellar/generated/admin/analytics/v1/analytics_pb.rb +54 -0
- data/lib/couchbase/protostellar/generated/admin/analytics/v1/analytics_services_pb.rb +51 -0
- data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_pb.rb +42 -0
- data/lib/couchbase/protostellar/generated/admin/bucket/v1/bucket_services_pb.rb +51 -0
- data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_pb.rb +38 -0
- data/lib/couchbase/protostellar/generated/admin/collection/v1/collection_services_pb.rb +52 -0
- data/lib/couchbase/protostellar/generated/admin/query/v1/query_pb.rb +42 -0
- data/lib/couchbase/protostellar/generated/admin/query/v1/query_services_pb.rb +55 -0
- data/lib/couchbase/protostellar/generated/admin/search/v1/search_pb.rb +51 -0
- data/lib/couchbase/protostellar/generated/admin/search/v1/search_services_pb.rb +67 -0
- data/lib/couchbase/protostellar/generated/analytics/v1/analytics_pb.rb +31 -0
- data/lib/couchbase/protostellar/generated/analytics/v1/analytics_services_pb.rb +40 -0
- data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_pb.rb +51 -0
- data/lib/couchbase/protostellar/generated/internal/hooks/v1/hooks_services_pb.rb +54 -0
- data/lib/couchbase/protostellar/generated/internal/xdcr/v1/xdcr_pb.rb +46 -0
- data/lib/couchbase/protostellar/generated/internal/xdcr/v1/xdcr_services_pb.rb +56 -0
- data/lib/couchbase/protostellar/generated/kv/v1/kv_pb.rb +74 -0
- data/lib/couchbase/protostellar/generated/kv/v1/kv_services_pb.rb +93 -0
- data/lib/couchbase/protostellar/generated/query/v1/query_pb.rb +35 -0
- data/lib/couchbase/protostellar/generated/query/v1/query_services_pb.rb +40 -0
- data/lib/couchbase/protostellar/generated/routing/v2/routing_pb.rb +26 -0
- data/lib/couchbase/protostellar/generated/routing/v2/routing_services_pb.rb +43 -0
- data/lib/couchbase/protostellar/generated/search/v1/search_pb.rb +78 -0
- data/lib/couchbase/protostellar/generated/search/v1/search_services_pb.rb +41 -0
- data/lib/couchbase/protostellar/generated/transactions/v1/transactions_pb.rb +36 -0
- data/lib/couchbase/protostellar/generated/transactions/v1/transactions_services_pb.rb +66 -0
- data/lib/couchbase/protostellar/generated/view/v1/view_pb.rb +30 -0
- data/lib/couchbase/protostellar/generated/view/v1/view_services_pb.rb +39 -0
- data/lib/couchbase/protostellar/generated.rb +9 -0
- data/lib/couchbase/protostellar/management/bucket_manager.rb +67 -0
- data/lib/couchbase/protostellar/management/collection_manager.rb +94 -0
- data/lib/couchbase/protostellar/management/collection_query_index_manager.rb +124 -0
- data/lib/couchbase/protostellar/management/query_index_manager.rb +112 -0
- data/lib/couchbase/protostellar/management.rb +24 -0
- data/lib/couchbase/protostellar/request.rb +79 -0
- data/lib/couchbase/protostellar/request_behaviour.rb +42 -0
- data/lib/couchbase/protostellar/request_generator/admin/bucket.rb +124 -0
- data/lib/couchbase/protostellar/request_generator/admin/collection.rb +96 -0
- data/lib/couchbase/protostellar/request_generator/admin/query.rb +132 -0
- data/lib/couchbase/protostellar/request_generator/admin.rb +24 -0
- data/lib/couchbase/protostellar/request_generator/kv.rb +488 -0
- data/lib/couchbase/protostellar/request_generator/query.rb +133 -0
- data/lib/couchbase/protostellar/request_generator/search.rb +403 -0
- data/lib/couchbase/protostellar/request_generator.rb +26 -0
- data/lib/couchbase/protostellar/response_converter/admin/bucket.rb +55 -0
- data/lib/couchbase/protostellar/response_converter/admin/collection.rb +42 -0
- data/lib/couchbase/protostellar/response_converter/admin/query.rb +59 -0
- data/lib/couchbase/protostellar/response_converter/admin.rb +24 -0
- data/lib/couchbase/protostellar/response_converter/kv.rb +151 -0
- data/lib/couchbase/protostellar/response_converter/query.rb +84 -0
- data/lib/couchbase/protostellar/response_converter/search.rb +136 -0
- data/lib/couchbase/protostellar/response_converter.rb +26 -0
- data/lib/couchbase/protostellar/retry/action.rb +38 -0
- data/lib/couchbase/protostellar/retry/orchestrator.rb +61 -0
- data/lib/couchbase/protostellar/retry/reason.rb +67 -0
- data/lib/couchbase/protostellar/retry/strategies/best_effort.rb +49 -0
- data/lib/couchbase/protostellar/retry/strategies/fail_fast.rb +33 -0
- data/lib/couchbase/protostellar/retry/strategies.rb +27 -0
- data/lib/couchbase/protostellar/retry.rb +28 -0
- data/lib/couchbase/protostellar/scope.rb +61 -0
- data/lib/couchbase/protostellar/timeout_defaults.rb +30 -0
- data/lib/couchbase/protostellar/timeouts.rb +83 -0
- data/lib/couchbase/protostellar.rb +29 -0
- data/lib/couchbase/query_options.rb +122 -0
- data/lib/couchbase/railtie.rb +47 -0
- data/lib/couchbase/raw_binary_transcoder.rb +39 -0
- data/lib/couchbase/raw_json_transcoder.rb +40 -0
- data/lib/couchbase/raw_string_transcoder.rb +42 -0
- data/lib/couchbase/scope.rb +272 -0
- data/lib/couchbase/search_options.rb +1744 -0
- data/lib/couchbase/subdoc.rb +293 -0
- data/lib/couchbase/tracing/noop_span.rb +29 -0
- data/lib/couchbase/tracing/noop_tracer.rb +29 -0
- data/lib/couchbase/tracing/request_span.rb +34 -0
- data/lib/couchbase/tracing/request_tracer.rb +28 -0
- data/lib/couchbase/tracing/threshold_logging_span.rb +112 -0
- data/lib/couchbase/tracing/threshold_logging_tracer.rb +231 -0
- data/lib/couchbase/transcoder_flags.rb +64 -0
- data/lib/couchbase/utils/generic_logger_adapter.rb +40 -0
- data/lib/couchbase/utils/hdr_histogram.rb +55 -0
- data/lib/couchbase/utils/observability.rb +263 -0
- data/lib/couchbase/utils/observability_constants.rb +200 -0
- data/lib/couchbase/utils/stdlib_logger_adapter.rb +65 -0
- data/lib/couchbase/utils/time.rb +71 -0
- data/lib/couchbase/utils.rb +23 -0
- data/lib/couchbase/version.rb +25 -0
- data/lib/couchbase/view_options.rb +67 -0
- data/lib/couchbase.rb +32 -0
- data/lib/rails/generators/couchbase/config/config_generator.rb +29 -0
- metadata +209 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2020-2021 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
|
+
module Couchbase
|
|
18
|
+
class LookupInSpec
|
|
19
|
+
# Fetches the content from a field (if present) at the given path
|
|
20
|
+
#
|
|
21
|
+
# @param [String, Symbol] path the path identifying where to get the value. When path is a symbol, the library will try to expand it as
|
|
22
|
+
# macro.
|
|
23
|
+
# @return [LookupInSpec]
|
|
24
|
+
def self.get(path)
|
|
25
|
+
case path
|
|
26
|
+
when Symbol
|
|
27
|
+
new(:get, expand_macro(path))
|
|
28
|
+
when ""
|
|
29
|
+
new(:get_doc, "")
|
|
30
|
+
else
|
|
31
|
+
new(:get, path)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Checks if a value at the given path exists in the document
|
|
36
|
+
#
|
|
37
|
+
# @param [String] path the path to check if the field exists
|
|
38
|
+
# @return [LookupInSpec]
|
|
39
|
+
def self.exists(path)
|
|
40
|
+
new(:exists, path)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Counts the number of values at a given path in the document
|
|
44
|
+
#
|
|
45
|
+
# @param [String] path the path identifying where to count the values
|
|
46
|
+
# @return [LookupInSpec]
|
|
47
|
+
def self.count(path)
|
|
48
|
+
new(:count, path)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def xattr
|
|
52
|
+
@xattr = true
|
|
53
|
+
self
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def xattr?
|
|
57
|
+
@xattr
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
attr_reader :type
|
|
61
|
+
attr_reader :path
|
|
62
|
+
|
|
63
|
+
# @api private
|
|
64
|
+
#
|
|
65
|
+
# @param [Symbol] macro
|
|
66
|
+
# @raise [Error::XattrUnknownMacro] if the macro cannot be expanded
|
|
67
|
+
def self.expand_macro(macro)
|
|
68
|
+
case macro
|
|
69
|
+
when :document
|
|
70
|
+
"$document"
|
|
71
|
+
when :expiry_time, :expiration_time
|
|
72
|
+
"$document.exptime"
|
|
73
|
+
when :cas
|
|
74
|
+
"$document.CAS"
|
|
75
|
+
when :seq_no, :sequence_number
|
|
76
|
+
"$document.seqno"
|
|
77
|
+
when :last_modified
|
|
78
|
+
"$document.last_modified"
|
|
79
|
+
when :is_deleted
|
|
80
|
+
"$document.deleted"
|
|
81
|
+
when :value_size_bytes
|
|
82
|
+
"$document.value_bytes"
|
|
83
|
+
when :rev_id, :revision_id
|
|
84
|
+
"$document.revid"
|
|
85
|
+
else
|
|
86
|
+
raise Error::XattrUnknownMacro, "unknown macro #{macro}"
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
private_class_method :expand_macro
|
|
91
|
+
|
|
92
|
+
private
|
|
93
|
+
|
|
94
|
+
# @param [:get_doc, :get, :exists, :count] type of the lookup
|
|
95
|
+
# @param [String] path
|
|
96
|
+
def initialize(type, path)
|
|
97
|
+
@xattr = false
|
|
98
|
+
@type = type
|
|
99
|
+
@path = path
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
class MutateInSpec
|
|
104
|
+
# Creates a command with the intention of replacing an existing value in a JSON document.
|
|
105
|
+
#
|
|
106
|
+
# If the path is empty (""), then the value will be used for the document's full body. Will
|
|
107
|
+
# error if the last element of the path does not exist.
|
|
108
|
+
#
|
|
109
|
+
# @param [String] path the path identifying where to replace the value.
|
|
110
|
+
# @param [Object, Symbol] value the value to replace with.
|
|
111
|
+
# When symbol specified and it is matches to known macro, it will be expanded
|
|
112
|
+
#
|
|
113
|
+
# @return [MutateInSpec]
|
|
114
|
+
def self.replace(path, value)
|
|
115
|
+
new(path.empty? ? :set_doc : :replace, path, value)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Creates a command with the intention of inserting a new value in a JSON object.
|
|
119
|
+
#
|
|
120
|
+
# Will error if the last element of the path already exists.
|
|
121
|
+
#
|
|
122
|
+
# @param [String] path the path identifying where to insert the value.
|
|
123
|
+
# @param [Object, Symbol] value the value to insert.
|
|
124
|
+
# When symbol specified and it is matches to known macro, it will be expanded
|
|
125
|
+
#
|
|
126
|
+
# @return [MutateInSpec]
|
|
127
|
+
def self.insert(path, value)
|
|
128
|
+
new(:dict_add, path, value)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Creates a command with the intention of removing an existing value in a JSON object.
|
|
132
|
+
#
|
|
133
|
+
# Will error if the path does not exist.
|
|
134
|
+
#
|
|
135
|
+
# @param path the path identifying what to remove.
|
|
136
|
+
#
|
|
137
|
+
# @return [MutateInSpec]
|
|
138
|
+
def self.remove(path)
|
|
139
|
+
new(path.empty? ? :remove_doc : :remove, path, nil)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Creates a command with the intention of upserting a value in a JSON object.
|
|
143
|
+
#
|
|
144
|
+
# That is, the value will be replaced if the path already exists, or inserted if not.
|
|
145
|
+
#
|
|
146
|
+
# @param [String] path the path identifying where to upsert the value.
|
|
147
|
+
# @param [Object, Symbol] value the value to upsert.
|
|
148
|
+
# When symbol specified and it is matches to known macro, it will be expanded
|
|
149
|
+
#
|
|
150
|
+
# @return [MutateInSpec]
|
|
151
|
+
def self.upsert(path, value)
|
|
152
|
+
new(:dict_upsert, path, value)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# Creates a command with the intention of appending a value to an existing JSON array.
|
|
156
|
+
#
|
|
157
|
+
# Will error if the last element of the path does not exist or is not an array.
|
|
158
|
+
#
|
|
159
|
+
# @param [String] path the path identifying an array to which to append the value.
|
|
160
|
+
# @param [Array] values the value(s) to append.
|
|
161
|
+
#
|
|
162
|
+
# @return [MutateInSpec]
|
|
163
|
+
def self.array_append(path, values)
|
|
164
|
+
new(:array_push_last, path, values)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# Creates a command with the intention of prepending a value to an existing JSON array.
|
|
168
|
+
#
|
|
169
|
+
# Will error if the last element of the path does not exist or is not an array.
|
|
170
|
+
#
|
|
171
|
+
# @param [String] path the path identifying an array to which to append the value.
|
|
172
|
+
# @param [Array] values the value(s) to prepend.
|
|
173
|
+
#
|
|
174
|
+
# @return [MutateInSpec]
|
|
175
|
+
def self.array_prepend(path, values)
|
|
176
|
+
new(:array_push_first, path, values)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# Creates a command with the intention of inserting a value into an existing JSON array.
|
|
180
|
+
#
|
|
181
|
+
# Will error if the last element of the path does not exist or is not an array.
|
|
182
|
+
#
|
|
183
|
+
# @param [String] path the path identifying an array to which to append the value, and an index. E.g. "foo.bar[3]"
|
|
184
|
+
# @param [Array] values the value(s) to insert.
|
|
185
|
+
#
|
|
186
|
+
# @return [MutateInSpec]
|
|
187
|
+
def self.array_insert(path, values)
|
|
188
|
+
new(:array_insert, path, values)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# Creates a command with the intent of inserting a value into an existing JSON array, but only if the value
|
|
192
|
+
# is not already contained in the array (by way of string comparison).
|
|
193
|
+
#
|
|
194
|
+
# Will error if the last element of the path does not exist or is not an array.
|
|
195
|
+
#
|
|
196
|
+
# @param [String] path the path identifying an array to which to append the value, and an index. E.g. "foo.bar[3]"
|
|
197
|
+
# @param [Object, Symbol] value the value to insert.
|
|
198
|
+
#
|
|
199
|
+
# @return [MutateInSpec]
|
|
200
|
+
def self.array_add_unique(path, value)
|
|
201
|
+
new(:array_add_unique, path, value)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# Creates a command with the intent of incrementing a numerical field in a JSON object.
|
|
205
|
+
#
|
|
206
|
+
# If the field does not exist, then it is created and takes the value of +delta+
|
|
207
|
+
#
|
|
208
|
+
# @param [String] path the path identifying a numerical field to adjust or create
|
|
209
|
+
# @param [Integer] delta the value to increment the field by
|
|
210
|
+
#
|
|
211
|
+
# @return [MutateInSpec]
|
|
212
|
+
def self.increment(path, delta)
|
|
213
|
+
new(:counter, path, delta.abs)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# Creates a command with the intent of decrementing a numerical field in a JSON object.
|
|
217
|
+
#
|
|
218
|
+
# If the field does not exist, then it is created and takes the value of +delta+ * -1
|
|
219
|
+
#
|
|
220
|
+
# @param [String] path the path identifying a numerical field to adjust or create
|
|
221
|
+
# @param [Integer] delta the value to decrement the field by
|
|
222
|
+
#
|
|
223
|
+
# @return [MutateInSpec]
|
|
224
|
+
def self.decrement(path, delta)
|
|
225
|
+
new(:counter, path, -1 * delta.abs)
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
def xattr
|
|
229
|
+
@xattr = true
|
|
230
|
+
self
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def create_path
|
|
234
|
+
@create_path = true
|
|
235
|
+
self
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def xattr?
|
|
239
|
+
@xattr
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
def create_path?
|
|
243
|
+
@create_path
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
def expand_macros?
|
|
247
|
+
@expand_macros
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
CAS = "${Mutation.CAS}"
|
|
251
|
+
SEQ_NO = "${Mutation.seqno}"
|
|
252
|
+
VALUE_CRC32C = "${Mutation.value_crc32c}"
|
|
253
|
+
|
|
254
|
+
attr_reader :type
|
|
255
|
+
attr_reader :path
|
|
256
|
+
attr_reader :param
|
|
257
|
+
|
|
258
|
+
private
|
|
259
|
+
|
|
260
|
+
def initialize(type, path, param)
|
|
261
|
+
@create_path = false
|
|
262
|
+
@param = nil
|
|
263
|
+
@xattr = false
|
|
264
|
+
@type = type
|
|
265
|
+
@path = path
|
|
266
|
+
@param =
|
|
267
|
+
case param
|
|
268
|
+
when :cas
|
|
269
|
+
CAS
|
|
270
|
+
when :seq_no, :sequence_number
|
|
271
|
+
SEQ_NO
|
|
272
|
+
when :value_crc32c, :value_crc
|
|
273
|
+
VALUE_CRC32C
|
|
274
|
+
else
|
|
275
|
+
param
|
|
276
|
+
end
|
|
277
|
+
# Only set expand_macros when a the value is a symbol that matches one of the macros
|
|
278
|
+
@expand_macros = [:cas, :seq_no, :sequence_number, :value_crc, :value_crc32c].include?(param)
|
|
279
|
+
@xattr = true if @expand_macros
|
|
280
|
+
return if @param.nil?
|
|
281
|
+
|
|
282
|
+
@param =
|
|
283
|
+
case type
|
|
284
|
+
when :counter
|
|
285
|
+
@param.to_i
|
|
286
|
+
when :array_push_first, :array_push_last, :array_insert
|
|
287
|
+
@param.map { |entry| JSON.generate(entry) }.join(",")
|
|
288
|
+
else
|
|
289
|
+
JSON.generate(@param)
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2025-Present 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
|
+
require_relative 'request_span'
|
|
18
|
+
|
|
19
|
+
module Couchbase
|
|
20
|
+
module Tracing
|
|
21
|
+
class NoopSpan < RequestSpan
|
|
22
|
+
def set_attribute(*); end
|
|
23
|
+
|
|
24
|
+
def status=(*); end
|
|
25
|
+
|
|
26
|
+
def finish(*); end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2025-Present 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
|
+
require_relative 'noop_span'
|
|
18
|
+
|
|
19
|
+
module Couchbase
|
|
20
|
+
module Tracing
|
|
21
|
+
class NoopTracer < RequestTracer
|
|
22
|
+
def request_span(*)
|
|
23
|
+
SPAN_INSTANCE
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
SPAN_INSTANCE = NoopSpan.new.freeze
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2025-Present 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
|
+
module Couchbase
|
|
18
|
+
module Tracing
|
|
19
|
+
# @!macro volatile
|
|
20
|
+
class RequestSpan
|
|
21
|
+
def set_attribute(key, value)
|
|
22
|
+
raise NotImplementedError, "The RequestSpan does not implement #set_attribute"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def status=(status_code)
|
|
26
|
+
raise NotImplementedError, "The RequestSpan does not implement #status="
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def finish(end_timestamp: nil)
|
|
30
|
+
raise NotImplementedError, "The RequestSpan does not implement #finish"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2025-Present 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
|
+
module Couchbase
|
|
18
|
+
module Tracing
|
|
19
|
+
# @!macro volatile
|
|
20
|
+
class RequestTracer
|
|
21
|
+
def request_span(name, parent: nil, start_timestamp: nil)
|
|
22
|
+
raise NotImplementedError, "The tracer does not implement #request_span"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def close; end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2025-Present 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
|
+
require 'couchbase/tracing/request_span'
|
|
18
|
+
require 'couchbase/utils/observability_constants'
|
|
19
|
+
|
|
20
|
+
module Couchbase
|
|
21
|
+
module Tracing
|
|
22
|
+
class ThresholdLoggingSpan < RequestSpan
|
|
23
|
+
attr_accessor :name
|
|
24
|
+
attr_accessor :should_report
|
|
25
|
+
attr_accessor :service
|
|
26
|
+
attr_accessor :encode_duration_us
|
|
27
|
+
attr_accessor :last_dispatch_duration_us
|
|
28
|
+
attr_accessor :total_dispatch_duration_us
|
|
29
|
+
attr_accessor :last_server_duration_us
|
|
30
|
+
attr_accessor :total_server_duration_us
|
|
31
|
+
attr_accessor :last_local_id
|
|
32
|
+
attr_accessor :operation_id
|
|
33
|
+
attr_accessor :last_peer_address
|
|
34
|
+
attr_accessor :last_peer_port
|
|
35
|
+
|
|
36
|
+
def initialize(name, start_timestamp: nil, parent: nil, tracer: nil)
|
|
37
|
+
super()
|
|
38
|
+
@name = name
|
|
39
|
+
@parent = parent
|
|
40
|
+
@tracer = tracer
|
|
41
|
+
|
|
42
|
+
@start_timestamp = if start_timestamp.nil?
|
|
43
|
+
Time.now
|
|
44
|
+
else
|
|
45
|
+
start_timestamp
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def set_attribute(key, value)
|
|
50
|
+
case key
|
|
51
|
+
when Observability::ATTR_OPERATION_ID
|
|
52
|
+
@operation_id = value
|
|
53
|
+
when Observability::ATTR_LOCAL_ID
|
|
54
|
+
@last_local_id = value
|
|
55
|
+
when Observability::ATTR_PEER_ADDRESS
|
|
56
|
+
@last_peer_address = value
|
|
57
|
+
when Observability::ATTR_PEER_PORT
|
|
58
|
+
@last_peer_port = value
|
|
59
|
+
when Observability::ATTR_SERVICE
|
|
60
|
+
@service = value
|
|
61
|
+
when Observability::ATTR_SERVER_DURATION
|
|
62
|
+
@last_server_duration_us = value
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def status=(*); end
|
|
67
|
+
|
|
68
|
+
def finish(end_timestamp: nil)
|
|
69
|
+
duration_us = (((end_timestamp || Time.now) - @start_timestamp) * 1_000_000).round
|
|
70
|
+
case name
|
|
71
|
+
when Observability::STEP_REQUEST_ENCODING
|
|
72
|
+
return if @parent.nil?
|
|
73
|
+
|
|
74
|
+
@parent.should_report = true
|
|
75
|
+
@parent.encode_duration_us = duration_us
|
|
76
|
+
when Observability::STEP_DISPATCH_TO_SERVER
|
|
77
|
+
return if @parent.nil?
|
|
78
|
+
|
|
79
|
+
@parent.should_report = true
|
|
80
|
+
@parent.last_dispatch_duration_us = duration_us
|
|
81
|
+
@parent.total_dispatch_duration_us = 0 if @parent.total_dispatch_duration_us.nil?
|
|
82
|
+
@parent.total_dispatch_duration_us += duration_us
|
|
83
|
+
unless @last_server_duration_us.nil?
|
|
84
|
+
@parent.last_server_duration_us = @last_server_duration_us
|
|
85
|
+
@parent.total_server_duration_us = 0 if @parent.total_server_duration_us.nil?
|
|
86
|
+
@parent.total_server_duration_us += @last_server_duration_us
|
|
87
|
+
end
|
|
88
|
+
@parent.last_local_id = @last_local_id
|
|
89
|
+
@parent.operation_id = @operation_id
|
|
90
|
+
@parent.last_peer_address = @last_peer_address
|
|
91
|
+
@parent.last_peer_port = @last_peer_port
|
|
92
|
+
else
|
|
93
|
+
@should_report ||= @parent.nil?
|
|
94
|
+
return unless @should_report && !@service.nil?
|
|
95
|
+
|
|
96
|
+
@tracer.record_operation(@service, ThresholdLoggingTracer::Item.new(
|
|
97
|
+
total_duration_us: duration_us,
|
|
98
|
+
encode_duration_us: @encode_duration_us,
|
|
99
|
+
last_dispatch_duration_us: @last_dispatch_duration_us,
|
|
100
|
+
total_dispatch_duration_us: @total_dispatch_duration_us,
|
|
101
|
+
last_server_duration_us: @last_server_duration_us,
|
|
102
|
+
total_server_duration_us: @total_server_duration_us,
|
|
103
|
+
operation_name: @name,
|
|
104
|
+
last_local_id: @last_local_id,
|
|
105
|
+
operation_id: @operation_id,
|
|
106
|
+
last_remote_socket: "#{@last_peer_address}:#{@last_peer_port}",
|
|
107
|
+
))
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|