couchbase 3.6.0-aarch64-linux → 3.8.0-aarch64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/active_support/cache/couchbase_store.rb +6 -6
- data/lib/couchbase/3.2/libcouchbase.so +0 -0
- data/lib/couchbase/3.3/libcouchbase.so +0 -0
- data/lib/couchbase/3.4/libcouchbase.so +0 -0
- data/lib/couchbase/{3.1 → 4.0}/libcouchbase.so +0 -0
- data/lib/couchbase/authenticator.rb +14 -0
- data/lib/couchbase/binary_collection.rb +37 -22
- data/lib/couchbase/bucket.rb +46 -31
- data/lib/couchbase/cluster.rb +146 -61
- data/lib/couchbase/collection.rb +257 -186
- data/lib/couchbase/datastructures/couchbase_list.rb +81 -50
- data/lib/couchbase/datastructures/couchbase_map.rb +86 -50
- data/lib/couchbase/datastructures/couchbase_queue.rb +64 -38
- data/lib/couchbase/datastructures/couchbase_set.rb +57 -41
- data/lib/couchbase/deprecations.rb +1 -1
- data/lib/couchbase/diagnostics.rb +8 -8
- data/lib/couchbase/errors.rb +6 -0
- data/lib/couchbase/libcouchbase.rb +1 -1
- data/lib/couchbase/management/analytics_index_manager.rb +90 -59
- data/lib/couchbase/management/bucket_manager.rb +73 -45
- data/lib/couchbase/management/collection_manager.rb +86 -43
- data/lib/couchbase/management/collection_query_index_manager.rb +56 -33
- data/lib/couchbase/management/query_index_manager.rb +88 -36
- data/lib/couchbase/management/scope_search_index_manager.rb +119 -52
- data/lib/couchbase/management/search_index_manager.rb +401 -178
- data/lib/couchbase/management/user_manager.rb +343 -174
- data/lib/couchbase/management/view_index_manager.rb +166 -73
- 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/options.rb +69 -3
- data/lib/couchbase/protostellar/cluster.rb +3 -0
- data/lib/couchbase/protostellar/response_converter/search.rb +1 -1
- data/lib/couchbase/scope.rb +62 -48
- data/lib/couchbase/search_options.rb +25 -20
- 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/utils/hdr_histogram.rb +55 -0
- data/lib/couchbase/utils/observability.rb +257 -0
- data/lib/couchbase/utils/observability_constants.rb +200 -0
- data/lib/couchbase/utils/stdlib_logger_adapter.rb +1 -3
- data/lib/couchbase/version.rb +1 -1
- data/lib/couchbase.rb +2 -2
- metadata +37 -8
data/lib/couchbase/options.rb
CHANGED
|
@@ -1672,7 +1672,7 @@ module Couchbase
|
|
|
1672
1672
|
# @see .Cluster
|
|
1673
1673
|
#
|
|
1674
1674
|
class Cluster
|
|
1675
|
-
attr_accessor :authenticator # @return [PasswordAuthenticator, CertificateAuthenticator]
|
|
1675
|
+
attr_accessor :authenticator # @return [PasswordAuthenticator, CertificateAuthenticator, JWTAuthenticator]
|
|
1676
1676
|
|
|
1677
1677
|
attr_accessor :preferred_server_group # @return [String]
|
|
1678
1678
|
|
|
@@ -1706,6 +1706,13 @@ module Couchbase
|
|
|
1706
1706
|
attr_accessor :config_idle_redial_timeout # @return [nil, Integer, #in_milliseconds]
|
|
1707
1707
|
attr_accessor :idle_http_connection_timeout # @return [nil, Integer, #in_milliseconds]
|
|
1708
1708
|
|
|
1709
|
+
# @return [ApplicationTelemetry]
|
|
1710
|
+
# @!macro volatile
|
|
1711
|
+
attr_accessor :application_telemetry
|
|
1712
|
+
|
|
1713
|
+
attr_accessor :tracer # @return [nil, Tracing::RequestTracer]
|
|
1714
|
+
attr_accessor :meter # @return [nil, Metrics::Meter]
|
|
1715
|
+
|
|
1709
1716
|
# Creates an instance of options for {Couchbase::Cluster.connect}
|
|
1710
1717
|
#
|
|
1711
1718
|
# @param [PasswordAuthenticator, CertificateAuthenticator] authenticator
|
|
@@ -1720,7 +1727,7 @@ module Couchbase
|
|
|
1720
1727
|
# @see .Cluster
|
|
1721
1728
|
#
|
|
1722
1729
|
# @yieldparam [Cluster] self
|
|
1723
|
-
def initialize(authenticator: nil,
|
|
1730
|
+
def initialize(authenticator: nil, # rubocop:disable Metrics/ParameterLists
|
|
1724
1731
|
preferred_server_group: nil,
|
|
1725
1732
|
enable_metrics: nil,
|
|
1726
1733
|
metrics_emit_interval: nil,
|
|
@@ -1749,7 +1756,10 @@ module Couchbase
|
|
|
1749
1756
|
config_poll_interval: nil,
|
|
1750
1757
|
config_poll_floor: nil,
|
|
1751
1758
|
config_idle_redial_timeout: nil,
|
|
1752
|
-
idle_http_connection_timeout: nil
|
|
1759
|
+
idle_http_connection_timeout: nil,
|
|
1760
|
+
tracer: nil,
|
|
1761
|
+
meter: nil,
|
|
1762
|
+
application_telemetry: ApplicationTelemetry.new)
|
|
1753
1763
|
@authenticator = authenticator
|
|
1754
1764
|
@preferred_server_group = preferred_server_group
|
|
1755
1765
|
@enable_metrics = enable_metrics
|
|
@@ -1780,6 +1790,10 @@ module Couchbase
|
|
|
1780
1790
|
@config_poll_floor = config_poll_floor
|
|
1781
1791
|
@config_idle_redial_timeout = config_idle_redial_timeout
|
|
1782
1792
|
@idle_http_connection_timeout = idle_http_connection_timeout
|
|
1793
|
+
@tracer = tracer
|
|
1794
|
+
@meter = meter
|
|
1795
|
+
@application_telemetry = application_telemetry
|
|
1796
|
+
|
|
1783
1797
|
yield self if block_given?
|
|
1784
1798
|
end
|
|
1785
1799
|
|
|
@@ -1826,8 +1840,60 @@ module Couchbase
|
|
|
1826
1840
|
config_poll_floor: Utils::Time.extract_duration(@config_poll_floor),
|
|
1827
1841
|
config_idle_redial_timeout: Utils::Time.extract_duration(@config_idle_redial_timeout),
|
|
1828
1842
|
idle_http_connection_timeout: Utils::Time.extract_duration(@idle_http_connection_timeout),
|
|
1843
|
+
application_telemetry: @application_telemetry.to_backend,
|
|
1829
1844
|
}
|
|
1830
1845
|
end
|
|
1846
|
+
|
|
1847
|
+
# Application Telemetry Options for {Couchbase::Cluster.connect}. Part of {Couchbase::Options::Cluster}
|
|
1848
|
+
#
|
|
1849
|
+
# @see Options::Cluster#application_telemetry
|
|
1850
|
+
#
|
|
1851
|
+
# @!macro volatile
|
|
1852
|
+
class ApplicationTelemetry
|
|
1853
|
+
attr_accessor :enable # @return [nil, Boolean]
|
|
1854
|
+
attr_accessor :override_endpoint # @return [nil, String]
|
|
1855
|
+
attr_accessor :backoff # @return [nil, Integer, #in_milliseconds]
|
|
1856
|
+
attr_accessor :ping_interval # @return [nil, Integer, #in_milliseconds]
|
|
1857
|
+
attr_accessor :ping_timeout # @return [nil, Integer, #in_milliseconds]
|
|
1858
|
+
|
|
1859
|
+
# Creates an instance of app telemetry options for {Couchbase::Cluster.connect}.
|
|
1860
|
+
# Part of {Couchbase::Options::Cluster}.
|
|
1861
|
+
#
|
|
1862
|
+
# @param [nil, Boolean] enable whether to enable application telemetry capture.
|
|
1863
|
+
# Application telemetry is enabled by default.
|
|
1864
|
+
# @param [nil, String] override_endpoint overrides the default endpoint used for application service telemetry
|
|
1865
|
+
# The endpoint must use the WebSocket protocol and the string should start with `ws://`.
|
|
1866
|
+
# @param [nil, Integer, #in_milliseconds] backoff specifies the duration to wait between connection attempts
|
|
1867
|
+
# to an application telemetry endpoint
|
|
1868
|
+
# @param [nil, Integer, #in_milliseconds] ping_interval specifies how often the SDK should ping the application
|
|
1869
|
+
# service telemetry collector
|
|
1870
|
+
# @param [nil, Integer, #in_milliseconds] ping_timeout specifies how long the SDK should wait for a ping
|
|
1871
|
+
# response (pong) from the application service collector, before closing the connection and attempting to reconnect
|
|
1872
|
+
def initialize(enable: nil,
|
|
1873
|
+
override_endpoint: nil,
|
|
1874
|
+
backoff: nil,
|
|
1875
|
+
ping_interval: nil,
|
|
1876
|
+
ping_timeout: nil)
|
|
1877
|
+
@enable = enable
|
|
1878
|
+
@override_endpoint = override_endpoint
|
|
1879
|
+
@backoff = backoff
|
|
1880
|
+
@ping_interval = ping_interval
|
|
1881
|
+
@ping_timeout = ping_timeout
|
|
1882
|
+
|
|
1883
|
+
yield self if block_given?
|
|
1884
|
+
end
|
|
1885
|
+
|
|
1886
|
+
# @api private
|
|
1887
|
+
def to_backend
|
|
1888
|
+
{
|
|
1889
|
+
enable: @enable,
|
|
1890
|
+
override_endpoint: @override_endpoint,
|
|
1891
|
+
backoff: Utils::Time.extract_duration(@backoff),
|
|
1892
|
+
ping_interval: Utils::Time.extract_duration(@ping_interval),
|
|
1893
|
+
ping_timeout: Utils::Time.extract_duration(@ping_timeout),
|
|
1894
|
+
}
|
|
1895
|
+
end
|
|
1896
|
+
end
|
|
1831
1897
|
end
|
|
1832
1898
|
|
|
1833
1899
|
# Options for {Couchbase::Cluster#diagnostics}
|
|
@@ -79,6 +79,9 @@ module Couchbase
|
|
|
79
79
|
when Couchbase::CertificateAuthenticator
|
|
80
80
|
raise Couchbase::Error::FeatureNotAvailable,
|
|
81
81
|
"The #{Couchbase::Protostellar::NAME} protocol does not support the CertificateAuthenticator"
|
|
82
|
+
when Couchbase::JWTAuthenticator
|
|
83
|
+
raise Couchbase::Error::FeatureNotAvailable,
|
|
84
|
+
"The #{Couchbase::Protostellar::NAME} protocol does not support the JWTAuthenticator"
|
|
82
85
|
else
|
|
83
86
|
raise ArgumentError, "options must have authenticator configured"
|
|
84
87
|
end
|
|
@@ -38,7 +38,7 @@ module Couchbase
|
|
|
38
38
|
|
|
39
39
|
def self.convert_search_row(proto_row, options)
|
|
40
40
|
Couchbase::Cluster::SearchRow.new do |r|
|
|
41
|
-
r.instance_variable_set(:@fields,
|
|
41
|
+
r.instance_variable_set(:@fields, proto_row.fields.to_h.transform_values { |v| JSON.parse(v) }.to_json)
|
|
42
42
|
r.transcoder = options.transcoder
|
|
43
43
|
r.index = proto_row.index
|
|
44
44
|
r.id = proto_row.id
|
data/lib/couchbase/scope.rb
CHANGED
|
@@ -29,10 +29,11 @@ module Couchbase
|
|
|
29
29
|
# @param [Couchbase::Backend] backend
|
|
30
30
|
# @param [String] bucket_name name of the bucket
|
|
31
31
|
# @param [String] scope_name name of the scope
|
|
32
|
-
def initialize(backend, bucket_name, scope_name)
|
|
32
|
+
def initialize(backend, bucket_name, scope_name, observability)
|
|
33
33
|
@backend = backend
|
|
34
34
|
@bucket_name = bucket_name
|
|
35
35
|
@name = scope_name
|
|
36
|
+
@observability = observability
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
# Opens the default collection for this scope
|
|
@@ -41,7 +42,7 @@ module Couchbase
|
|
|
41
42
|
#
|
|
42
43
|
# @return [Collection]
|
|
43
44
|
def collection(collection_name)
|
|
44
|
-
Collection.new(@backend, @bucket_name, @name, collection_name)
|
|
45
|
+
Collection.new(@backend, @bucket_name, @name, collection_name, @observability)
|
|
45
46
|
end
|
|
46
47
|
|
|
47
48
|
# Performs a query against the query (N1QL) services.
|
|
@@ -60,30 +61,34 @@ module Couchbase
|
|
|
60
61
|
#
|
|
61
62
|
# @return [QueryResult]
|
|
62
63
|
def query(statement, options = Options::Query::DEFAULT)
|
|
63
|
-
|
|
64
|
+
@observability.record_operation(Observability::OP_QUERY, options.parent_span, self, :query) do |obs_handler|
|
|
65
|
+
obs_handler.add_query_statement(statement, options)
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if resp[:meta][:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
67
|
+
resp = @backend.document_query(statement, options.to_backend(scope_name: @name, bucket_name: @bucket_name), obs_handler)
|
|
68
|
+
|
|
69
|
+
Cluster::QueryResult.new do |res|
|
|
70
|
+
res.meta_data = Cluster::QueryMetaData.new do |meta|
|
|
71
|
+
meta.status = resp[:meta][:status]
|
|
72
|
+
meta.request_id = resp[:meta][:request_id]
|
|
73
|
+
meta.client_context_id = resp[:meta][:client_context_id]
|
|
74
|
+
meta.signature = JSON.parse(resp[:meta][:signature]) if resp[:meta][:signature]
|
|
75
|
+
meta.profile = JSON.parse(resp[:meta][:profile]) if resp[:meta][:profile]
|
|
76
|
+
meta.metrics = Cluster::QueryMetrics.new do |metrics|
|
|
77
|
+
if resp[:meta][:metrics]
|
|
78
|
+
metrics.elapsed_time = resp[:meta][:metrics][:elapsed_time]
|
|
79
|
+
metrics.execution_time = resp[:meta][:metrics][:execution_time]
|
|
80
|
+
metrics.sort_count = resp[:meta][:metrics][:sort_count]
|
|
81
|
+
metrics.result_count = resp[:meta][:metrics][:result_count]
|
|
82
|
+
metrics.result_size = resp[:meta][:metrics][:result_size]
|
|
83
|
+
metrics.mutation_count = resp[:meta][:metrics][:mutation_count]
|
|
84
|
+
metrics.error_count = resp[:meta][:metrics][:error_count]
|
|
85
|
+
metrics.warning_count = resp[:meta][:metrics][:warning_count]
|
|
86
|
+
end
|
|
82
87
|
end
|
|
88
|
+
meta.warnings = resp[:warnings].map { |warn| Cluster::QueryWarning.new(warn[:code], warn[:message]) } if resp[:warnings]
|
|
83
89
|
end
|
|
84
|
-
|
|
90
|
+
res.instance_variable_set(:@rows, resp[:rows])
|
|
85
91
|
end
|
|
86
|
-
res.instance_variable_set(:@rows, resp[:rows])
|
|
87
92
|
end
|
|
88
93
|
end
|
|
89
94
|
|
|
@@ -100,30 +105,34 @@ module Couchbase
|
|
|
100
105
|
#
|
|
101
106
|
# @return [AnalyticsResult]
|
|
102
107
|
def analytics_query(statement, options = Options::Analytics::DEFAULT)
|
|
103
|
-
|
|
108
|
+
@observability.record_operation(Observability::OP_ANALYTICS_QUERY, options.parent_span, self, :analytics) do |obs_handler|
|
|
109
|
+
obs_handler.add_query_statement(statement, options)
|
|
110
|
+
|
|
111
|
+
resp = @backend.document_analytics(statement, options.to_backend(scope_name: @name, bucket_name: @bucket_name))
|
|
104
112
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
113
|
+
Cluster::AnalyticsResult.new do |res|
|
|
114
|
+
res.transcoder = options.transcoder
|
|
115
|
+
res.meta_data = Cluster::AnalyticsMetaData.new do |meta|
|
|
116
|
+
meta.status = resp[:meta][:status]
|
|
117
|
+
meta.request_id = resp[:meta][:request_id]
|
|
118
|
+
meta.client_context_id = resp[:meta][:client_context_id]
|
|
119
|
+
meta.signature = JSON.parse(resp[:meta][:signature]) if resp[:meta][:signature]
|
|
120
|
+
meta.profile = JSON.parse(resp[:meta][:profile]) if resp[:meta][:profile]
|
|
121
|
+
meta.metrics = Cluster::AnalyticsMetrics.new do |metrics|
|
|
122
|
+
if resp[:meta][:metrics]
|
|
123
|
+
metrics.elapsed_time = resp[:meta][:metrics][:elapsed_time]
|
|
124
|
+
metrics.execution_time = resp[:meta][:metrics][:execution_time]
|
|
125
|
+
metrics.result_count = resp[:meta][:metrics][:result_count]
|
|
126
|
+
metrics.result_size = resp[:meta][:metrics][:result_size]
|
|
127
|
+
metrics.error_count = resp[:meta][:metrics][:error_count]
|
|
128
|
+
metrics.warning_count = resp[:meta][:metrics][:warning_count]
|
|
129
|
+
metrics.processed_objects = resp[:meta][:metrics][:processed_objects]
|
|
130
|
+
end
|
|
122
131
|
end
|
|
132
|
+
res[:warnings] = resp[:warnings].map { |warn| Cluster::AnalyticsWarning.new(warn[:code], warn[:message]) } if resp[:warnings]
|
|
123
133
|
end
|
|
124
|
-
res
|
|
134
|
+
res.instance_variable_set(:@rows, resp[:rows])
|
|
125
135
|
end
|
|
126
|
-
res.instance_variable_set(:@rows, resp[:rows])
|
|
127
136
|
end
|
|
128
137
|
end
|
|
129
138
|
|
|
@@ -145,8 +154,10 @@ module Couchbase
|
|
|
145
154
|
#
|
|
146
155
|
# @return [SearchResult]
|
|
147
156
|
def search_query(index_name, query, options = Options::Search::DEFAULT)
|
|
148
|
-
|
|
149
|
-
|
|
157
|
+
@observability.record_operation(Observability::OP_SEARCH_QUERY, options.parent_span, self, :search) do |obs_handler|
|
|
158
|
+
resp = @backend.document_search(@bucket_name, @name, index_name, JSON.generate(query), {}, options.to_backend, obs_handler)
|
|
159
|
+
convert_search_result(resp, options)
|
|
160
|
+
end
|
|
150
161
|
end
|
|
151
162
|
|
|
152
163
|
# Performs a request against the Full Text Search (FTS) service.
|
|
@@ -157,14 +168,17 @@ module Couchbase
|
|
|
157
168
|
#
|
|
158
169
|
# @return [SearchResult]
|
|
159
170
|
def search(index_name, search_request, options = Options::Search::DEFAULT)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
171
|
+
@observability.record_operation(Observability::OP_SEARCH_QUERY, options.parent_span, self, :search) do |obs_handler|
|
|
172
|
+
encoded_query, encoded_req = search_request.to_backend
|
|
173
|
+
resp = @backend.document_search(@bucket_name, @name, index_name, encoded_query, encoded_req,
|
|
174
|
+
options.to_backend(show_request: false), obs_handler)
|
|
175
|
+
convert_search_result(resp, options)
|
|
176
|
+
end
|
|
163
177
|
end
|
|
164
178
|
|
|
165
179
|
# @return [Management::ScopeSearchIndexManager]
|
|
166
180
|
def search_indexes
|
|
167
|
-
Management::ScopeSearchIndexManager.new(@backend, @bucket_name, @name)
|
|
181
|
+
Management::ScopeSearchIndexManager.new(@backend, @bucket_name, @name, @observability)
|
|
168
182
|
end
|
|
169
183
|
|
|
170
184
|
private
|
|
@@ -84,8 +84,8 @@ module Couchbase
|
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
# @return [String]
|
|
87
|
-
def to_json(*
|
|
88
|
-
to_h.to_json(*
|
|
87
|
+
def to_json(*)
|
|
88
|
+
to_h.to_json(*)
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
# Prepare {MatchQuery} body
|
|
@@ -321,8 +321,8 @@ module Couchbase
|
|
|
321
321
|
# @yieldparam [BooleanFieldQuery] query
|
|
322
322
|
#
|
|
323
323
|
# @return [BooleanFieldQuery]
|
|
324
|
-
def self.boolean_field(value)
|
|
325
|
-
BooleanFieldQuery.new(value)
|
|
324
|
+
def self.boolean_field(value, &)
|
|
325
|
+
BooleanFieldQuery.new(value, &)
|
|
326
326
|
end
|
|
327
327
|
|
|
328
328
|
# Allow to match `true`/`false` in a field mapped as boolean.
|
|
@@ -1073,6 +1073,9 @@ module Couchbase
|
|
|
1073
1073
|
# @return [Float, nil]
|
|
1074
1074
|
attr_accessor :boost
|
|
1075
1075
|
|
|
1076
|
+
# @return [SearchQuery, nil]
|
|
1077
|
+
attr_accessor :prefilter
|
|
1078
|
+
|
|
1076
1079
|
# Constructs a +VectorQuery+ instance
|
|
1077
1080
|
#
|
|
1078
1081
|
# @overload initialize(vector_field_name, vector_query)
|
|
@@ -1111,6 +1114,8 @@ module Couchbase
|
|
|
1111
1114
|
boost: boost,
|
|
1112
1115
|
}.compact
|
|
1113
1116
|
|
|
1117
|
+
h[:filter] = prefilter.to_h unless prefilter.nil?
|
|
1118
|
+
|
|
1114
1119
|
raise Error::InvalidArgument, "The vector cannot be nil" if !h.include?(:vector) && !h.include?(:vector_base64)
|
|
1115
1120
|
raise Error::InvalidArgument, "The vector query cannot be an empty array" if h.include?(:vector) && h[:vector].empty?
|
|
1116
1121
|
|
|
@@ -1123,8 +1128,8 @@ module Couchbase
|
|
|
1123
1128
|
end
|
|
1124
1129
|
|
|
1125
1130
|
# @api private
|
|
1126
|
-
def to_json(*
|
|
1127
|
-
to_h.to_json(*
|
|
1131
|
+
def to_json(*)
|
|
1132
|
+
to_h.to_json(*)
|
|
1128
1133
|
end
|
|
1129
1134
|
end
|
|
1130
1135
|
|
|
@@ -1168,8 +1173,8 @@ module Couchbase
|
|
|
1168
1173
|
end
|
|
1169
1174
|
|
|
1170
1175
|
# @api private
|
|
1171
|
-
def to_json(*
|
|
1172
|
-
{by: :score, desc: desc}.to_json(*
|
|
1176
|
+
def to_json(*)
|
|
1177
|
+
{by: :score, desc: desc}.to_json(*)
|
|
1173
1178
|
end
|
|
1174
1179
|
end
|
|
1175
1180
|
|
|
@@ -1184,8 +1189,8 @@ module Couchbase
|
|
|
1184
1189
|
end
|
|
1185
1190
|
|
|
1186
1191
|
# @api private
|
|
1187
|
-
def to_json(*
|
|
1188
|
-
{by: :id, desc: desc}.to_json(*
|
|
1192
|
+
def to_json(*)
|
|
1193
|
+
{by: :id, desc: desc}.to_json(*)
|
|
1189
1194
|
end
|
|
1190
1195
|
end
|
|
1191
1196
|
|
|
@@ -1214,8 +1219,8 @@ module Couchbase
|
|
|
1214
1219
|
end
|
|
1215
1220
|
|
|
1216
1221
|
# @api private
|
|
1217
|
-
def to_json(*
|
|
1218
|
-
{by: :field, field: field, desc: desc, type: type, missing: missing, mode: mode}.to_json(*
|
|
1222
|
+
def to_json(*)
|
|
1223
|
+
{by: :field, field: field, desc: desc, type: type, missing: missing, mode: mode}.to_json(*)
|
|
1219
1224
|
end
|
|
1220
1225
|
end
|
|
1221
1226
|
|
|
@@ -1248,8 +1253,8 @@ module Couchbase
|
|
|
1248
1253
|
end
|
|
1249
1254
|
|
|
1250
1255
|
# @api private
|
|
1251
|
-
def to_json(*
|
|
1252
|
-
{by: :geo_distance, field: field, desc: desc, location: [longitude, latitude], unit: unit}.to_json(*
|
|
1256
|
+
def to_json(*)
|
|
1257
|
+
{by: :geo_distance, field: field, desc: desc, location: [longitude, latitude], unit: unit}.to_json(*)
|
|
1253
1258
|
end
|
|
1254
1259
|
end
|
|
1255
1260
|
end
|
|
@@ -1287,8 +1292,8 @@ module Couchbase
|
|
|
1287
1292
|
end
|
|
1288
1293
|
|
|
1289
1294
|
# @api private
|
|
1290
|
-
def to_json(*
|
|
1291
|
-
{field: field, size: size}.to_json(*
|
|
1295
|
+
def to_json(*)
|
|
1296
|
+
{field: field, size: size}.to_json(*)
|
|
1292
1297
|
end
|
|
1293
1298
|
end
|
|
1294
1299
|
|
|
@@ -1314,8 +1319,8 @@ module Couchbase
|
|
|
1314
1319
|
end
|
|
1315
1320
|
|
|
1316
1321
|
# @api private
|
|
1317
|
-
def to_json(*
|
|
1318
|
-
{field: field, size: size, numeric_ranges: @ranges}.to_json(*
|
|
1322
|
+
def to_json(*)
|
|
1323
|
+
{field: field, size: size, numeric_ranges: @ranges}.to_json(*)
|
|
1319
1324
|
end
|
|
1320
1325
|
end
|
|
1321
1326
|
|
|
@@ -1346,8 +1351,8 @@ module Couchbase
|
|
|
1346
1351
|
end
|
|
1347
1352
|
|
|
1348
1353
|
# @api private
|
|
1349
|
-
def to_json(*
|
|
1350
|
-
{field: field, size: size, date_ranges: @ranges}.to_json(*
|
|
1354
|
+
def to_json(*)
|
|
1355
|
+
{field: field, size: size, date_ranges: @ranges}.to_json(*)
|
|
1351
1356
|
end
|
|
1352
1357
|
end
|
|
1353
1358
|
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
|