1b68c7c8dSSergey Avseyev/* -*- mode: systemtap; -*-
2b68c7c8dSSergey Avseyev *
3b68c7c8dSSergey Avseyev *     Copyright 2017 Couchbase, Inc.
4b68c7c8dSSergey Avseyev *
5b68c7c8dSSergey Avseyev *   Licensed under the Apache License, Version 2.0 (the "License");
6b68c7c8dSSergey Avseyev *   you may not use this file except in compliance with the License.
7b68c7c8dSSergey Avseyev *   You may obtain a copy of the License at
8b68c7c8dSSergey Avseyev *
9b68c7c8dSSergey Avseyev *       http://www.apache.org/licenses/LICENSE-2.0
10b68c7c8dSSergey Avseyev *
11b68c7c8dSSergey Avseyev *   Unless required by applicable law or agreed to in writing, software
12b68c7c8dSSergey Avseyev *   distributed under the License is distributed on an "AS IS" BASIS,
13b68c7c8dSSergey Avseyev *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14b68c7c8dSSergey Avseyev *   See the License for the specific language governing permissions and
15b68c7c8dSSergey Avseyev *   limitations under the License.
16b68c7c8dSSergey Avseyev */
17b68c7c8dSSergey Avseyev
18b68c7c8dSSergey Avseyev/*
19b68c7c8dSSergey Avseyev * SystemTap tapset to make it easier to trace libcouchbase
20b68c7c8dSSergey Avseyev *
21b68c7c8dSSergey Avseyev * All probes provided by libcouchbase can be listed using following command:
22b68c7c8dSSergey Avseyev *
23b68c7c8dSSergey Avseyev * stap -L 'process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("*")'
24b68c7c8dSSergey Avseyev */
25b68c7c8dSSergey Avseyev
26b68c7c8dSSergey Avseyev
27b68c7c8dSSergey Avseyev/**
28b68c7c8dSSergey Avseyev * Convert opcode from couchbase KV protocol to string representation
29b68c7c8dSSergey Avseyev */
30b68c7c8dSSergey Avseyevfunction libcouchbase_opcode:string(opcode:long)
31b68c7c8dSSergey Avseyev{
32b68c7c8dSSergey Avseyev    if (opcode == 0x00) return "GET"
33b68c7c8dSSergey Avseyev    else if (opcode == 0x01) return "SET"
34b68c7c8dSSergey Avseyev    else if (opcode == 0x02) return "ADD"
35b68c7c8dSSergey Avseyev    else if (opcode == 0x03) return "REPLACE"
36b68c7c8dSSergey Avseyev    else if (opcode == 0x04) return "DELETE"
37b68c7c8dSSergey Avseyev    else if (opcode == 0x05) return "INCREMENT"
38b68c7c8dSSergey Avseyev    else if (opcode == 0x06) return "DECREMENT"
39b68c7c8dSSergey Avseyev    else if (opcode == 0x08) return "FLUSH"
40b68c7c8dSSergey Avseyev    else if (opcode == 0x09) return "GETQ"
41b68c7c8dSSergey Avseyev    else if (opcode == 0x0a) return "NOOP"
42b68c7c8dSSergey Avseyev    else if (opcode == 0x0b) return "VERSION"
43b68c7c8dSSergey Avseyev    else if (opcode == 0x0e) return "APPEND"
44b68c7c8dSSergey Avseyev    else if (opcode == 0x0f) return "PREPEND"
45b68c7c8dSSergey Avseyev    else if (opcode == 0x10) return "STAT"
46b68c7c8dSSergey Avseyev    else if (opcode == 0x1b) return "VERBOSITY"
47b68c7c8dSSergey Avseyev    else if (opcode == 0x1c) return "TOUCH"
48b68c7c8dSSergey Avseyev    else if (opcode == 0x1d) return "GAT"
49b68c7c8dSSergey Avseyev    else if (opcode == 0x1f) return "HELLO"
50b68c7c8dSSergey Avseyev    else if (opcode == 0x20) return "SASL_LIST_MECHS"
51b68c7c8dSSergey Avseyev    else if (opcode == 0x21) return "SASL_AUTH"
52b68c7c8dSSergey Avseyev    else if (opcode == 0x22) return "SASL_STEP"
53b68c7c8dSSergey Avseyev    else if (opcode == 0x83) return "GET_REPLICA"
54b68c7c8dSSergey Avseyev    else if (opcode == 0x89) return "SELECT_BUCKET"
55b68c7c8dSSergey Avseyev    else if (opcode == 0x91) return "OBSERVE_SEQNO"
56b68c7c8dSSergey Avseyev    else if (opcode == 0x92) return "OBSERVE"
57b68c7c8dSSergey Avseyev    else if (opcode == 0x94) return "GET_LOCKED"
58b68c7c8dSSergey Avseyev    else if (opcode == 0x95) return "UNLOCK_KEY"
59b68c7c8dSSergey Avseyev    else if (opcode == 0xb5) return "GET_CLUSTER_CONFIG"
60b68c7c8dSSergey Avseyev    else if (opcode == 0xc5) return "SUBDOC_GET"
61b68c7c8dSSergey Avseyev    else if (opcode == 0xc6) return "SUBDOC_EXISTS"
62b68c7c8dSSergey Avseyev    else if (opcode == 0xc7) return "SUBDOC_DICT_ADD"
63b68c7c8dSSergey Avseyev    else if (opcode == 0xc8) return "SUBDOC_DICT_UPSERT"
64b68c7c8dSSergey Avseyev    else if (opcode == 0xc9) return "SUBDOC_DELETE"
65b68c7c8dSSergey Avseyev    else if (opcode == 0xca) return "SUBDOC_REPLACE"
66b68c7c8dSSergey Avseyev    else if (opcode == 0xcb) return "SUBDOC_ARRAY_PUSH_LAST"
67b68c7c8dSSergey Avseyev    else if (opcode == 0xcc) return "SUBDOC_ARRAY_PUSH_FIRST"
68b68c7c8dSSergey Avseyev    else if (opcode == 0xcd) return "SUBDOC_ARRAY_INSERT"
69b68c7c8dSSergey Avseyev    else if (opcode == 0xce) return "SUBDOC_ARRAY_ADD_UNIQUE"
70b68c7c8dSSergey Avseyev    else if (opcode == 0xcf) return "SUBDOC_COUNTER"
71b68c7c8dSSergey Avseyev    else if (opcode == 0xd0) return "SUBDOC_MULTI_LOOKUP"
72b68c7c8dSSergey Avseyev    else if (opcode == 0xd1) return "SUBDOC_MULTI_MUTATION"
73b68c7c8dSSergey Avseyev    else if (opcode == 0xd2) return "SUBDOC_GET_COUNT"
74b68c7c8dSSergey Avseyev    else if (opcode == 0xfe) return "GET_ERROR_MAP"
75b68c7c8dSSergey Avseyev    else return "UNKNOWN"
76b68c7c8dSSergey Avseyev}
77b68c7c8dSSergey Avseyev
78b68c7c8dSSergey Avseyev/**
79b68c7c8dSSergey Avseyev * Convert HTTP request type to string representation
80b68c7c8dSSergey Avseyev */
81b68c7c8dSSergey Avseyevfunction libcouchbase_http_type:string(type:long)
82b68c7c8dSSergey Avseyev{
83b68c7c8dSSergey Avseyev    if (type == 0) return "VIEW"
84b68c7c8dSSergey Avseyev    else if (type == 1) return "MANAGEMENT"
85b68c7c8dSSergey Avseyev    else if (type == 2) return "RAW"
86b68c7c8dSSergey Avseyev    else if (type == 3) return "N1QL"
87b68c7c8dSSergey Avseyev    else if (type == 4) return "FTS"
88b68c7c8dSSergey Avseyev    else if (type == 5) return "CBAS"
89b68c7c8dSSergey Avseyev    else return "UNKNOWN"
90b68c7c8dSSergey Avseyev}
91b68c7c8dSSergey Avseyev
92b68c7c8dSSergey Avseyev/**
93b68c7c8dSSergey Avseyev * Convert HTTP request method to string representation
94b68c7c8dSSergey Avseyev */
95b68c7c8dSSergey Avseyevfunction libcouchbase_http_method:string(method:long)
96b68c7c8dSSergey Avseyev{
97b68c7c8dSSergey Avseyev    if (method == 0) return "GET"
98b68c7c8dSSergey Avseyev    else if (method == 1) return "POST"
99b68c7c8dSSergey Avseyev    else if (method == 2) return "PUT"
100b68c7c8dSSergey Avseyev    else if (method == 3) return "DELETE"
101b68c7c8dSSergey Avseyev    else return "UNKNOWN"
102b68c7c8dSSergey Avseyev}
103b68c7c8dSSergey Avseyev
104b68c7c8dSSergey Avseyev/**
105b68c7c8dSSergey Avseyev * probe libcouchbase.kv.get.begin - start of GET/GETL/GAT operation
106b68c7c8dSSergey Avseyev *
107b68c7c8dSSergey Avseyev * @lcb: client instance
108b68c7c8dSSergey Avseyev * @opaque: unique number for this request (visible on network, returned by server back)
109b68c7c8dSSergey Avseyev * @vbucket: number of partition
110b68c7c8dSSergey Avseyev * @opcode: opcode, see memcached/protocol_binary.h
111b68c7c8dSSergey Avseyev * @key: document id
112b68c7c8dSSergey Avseyev * @expiration: document expiration (0 when should not expire)
113b68c7c8dSSergey Avseyev *
114b68c7c8dSSergey Avseyev * Example:
115b68c7c8dSSergey Avseyev *
116b68c7c8dSSergey Avseyev *   probe libcouchbase.kv.get.begin {
117b68c7c8dSSergey Avseyev *     printf("[%p] opcode: %s, vbucket: %d, key: %s\n",
118b68c7c8dSSergey Avseyev *         lcb, libcouchbase_opcode(opcode), vbucket, key)
119b68c7c8dSSergey Avseyev *   }
120b68c7c8dSSergey Avseyev *
121b68c7c8dSSergey Avseyev *
122b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc get foo"
123b68c7c8dSSergey Avseyev *   foo                  CAS=0x150268ca90610000, Flags=0x0, Size=13, Datatype=0x01(JSON)
124b68c7c8dSSergey Avseyev *   {"foo":"bar"}
125b68c7c8dSSergey Avseyev *   [0xf20d90] opcode: GET, vbucket: 115, key: foo
126b68c7c8dSSergey Avseyev */
127b68c7c8dSSergey Avseyevprobe libcouchbase.kv.get.begin =
128b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("get_begin")
129b68c7c8dSSergey Avseyev{
130b68c7c8dSSergey Avseyev    lcb = $arg1
131b68c7c8dSSergey Avseyev    opaque = $arg2
132b68c7c8dSSergey Avseyev    vbucket = $arg3
133b68c7c8dSSergey Avseyev    opcode = $arg4
134b68c7c8dSSergey Avseyev    key = user_string_n($arg5, $arg6)
135b68c7c8dSSergey Avseyev    expiration = $arg7
136b68c7c8dSSergey Avseyev}
137b68c7c8dSSergey Avseyev
138b68c7c8dSSergey Avseyev/**
139b68c7c8dSSergey Avseyev * probe libcouchbase.kv.get.end - end of GET/GETL/GAT operation
140b68c7c8dSSergey Avseyev *
141b68c7c8dSSergey Avseyev * @lcb: client instance
142b68c7c8dSSergey Avseyev * @opaque: unique number for this request (visible on network, returned by server back)
143b68c7c8dSSergey Avseyev * @opcode: opcode, see memcached/protocol_binary.h
144b68c7c8dSSergey Avseyev * @latency_ns: time from schedule to dispatch of the command
145b68c7c8dSSergey Avseyev * @rc: return code from the library see libcouchbase/error.h
146b68c7c8dSSergey Avseyev * @key: document id
147b68c7c8dSSergey Avseyev * @bytes: document body
148b68c7c8dSSergey Avseyev * @flags: document flags
149b68c7c8dSSergey Avseyev * @cas: document CAS
150b68c7c8dSSergey Avseyev * @datatype: document datatype, see memcached/protocol_binary.h
151b68c7c8dSSergey Avseyev *
152b68c7c8dSSergey Avseyev * Example:
153b68c7c8dSSergey Avseyev *
154b68c7c8dSSergey Avseyev *   probe libcouchbase.kv.get.end {
155b68c7c8dSSergey Avseyev *     printf("[%p] opcode: %s, rc: %d, cas: 0x%x, key: %s, value: %s\n",
156b68c7c8dSSergey Avseyev *         lcb, libcouchbase_opcode(opcode), rc, cas, key, bytes)
157b68c7c8dSSergey Avseyev *   }
158b68c7c8dSSergey Avseyev *
159b68c7c8dSSergey Avseyev *
160b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc get foo"
161b68c7c8dSSergey Avseyev *   foo                  CAS=0x150268ca90610000, Flags=0x0, Size=13, Datatype=0x01(JSON)
162b68c7c8dSSergey Avseyev *   {"foo":"bar"}
163b68c7c8dSSergey Avseyev *   [0x1b58dd0] opcode: GET, rc: 0, cas: 0x150268ca90610000, key: foo, value: {"foo":"bar"}
164b68c7c8dSSergey Avseyev */
165b68c7c8dSSergey Avseyevprobe libcouchbase.kv.get.end =
166b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("get_end")
167b68c7c8dSSergey Avseyev{
168b68c7c8dSSergey Avseyev    lcb = $arg1
169b68c7c8dSSergey Avseyev    opaque = $arg2
170b68c7c8dSSergey Avseyev    opcode = $arg3
171b68c7c8dSSergey Avseyev    latency_ns = $arg4
172b68c7c8dSSergey Avseyev    rc = $arg5
173b68c7c8dSSergey Avseyev    key = user_string_n($arg6, $arg7)
174b68c7c8dSSergey Avseyev    bytes = user_string_n($arg8, $arg9)
175b68c7c8dSSergey Avseyev    flags = $arg10
176b68c7c8dSSergey Avseyev    cas = $arg11
177b68c7c8dSSergey Avseyev    datatype = $arg12
178b68c7c8dSSergey Avseyev}
179b68c7c8dSSergey Avseyev
180b68c7c8dSSergey Avseyev/**
181b68c7c8dSSergey Avseyev * probe libcouchbase.kv.arithmetic.begin - start of INCR/DECR operation
182b68c7c8dSSergey Avseyev *
183b68c7c8dSSergey Avseyev * @lcb: client instance
184b68c7c8dSSergey Avseyev * @opaque: unique number for this request (visible on network, returned by server back)
185b68c7c8dSSergey Avseyev * @vbucket: number of partition
186b68c7c8dSSergey Avseyev * @opcode: opcode, see memcached/protocol_binary.h
187b68c7c8dSSergey Avseyev * @key: document id
188b68c7c8dSSergey Avseyev * @delta: the 64 bit value to change the counter
189b68c7c8dSSergey Avseyev * @initial: the value to use, when document is not exist
190b68c7c8dSSergey Avseyev * @expiration: document expiration (0 when should not expire)
191b68c7c8dSSergey Avseyev *
192b68c7c8dSSergey Avseyev * Example:
193b68c7c8dSSergey Avseyev *
194b68c7c8dSSergey Avseyev *   probe libcouchbase.kv.arithmetic.begin {
195b68c7c8dSSergey Avseyev *     printf("[%p] opcode: %s, delta: %d, initial: %d, key: %s\n",
196b68c7c8dSSergey Avseyev *         lcb, libcouchbase_opcode(opcode), delta, initial, key)
197b68c7c8dSSergey Avseyev *   }
198b68c7c8dSSergey Avseyev *
199b68c7c8dSSergey Avseyev *
200b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc incr --initial 42 --delta 3 cnt"
201b68c7c8dSSergey Avseyev *   cnt                 Current value is 42. CAS=0x15026eea18850000
202b68c7c8dSSergey Avseyev *   [0x117bdd0] opcode: INCREMENT, delta: 3, initial: 42, key: cnt
203b68c7c8dSSergey Avseyev */
204b68c7c8dSSergey Avseyevprobe libcouchbase.kv.arithmetic.begin =
205b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("arithmetic_begin")
206b68c7c8dSSergey Avseyev{
207b68c7c8dSSergey Avseyev    lcb = $arg1
208b68c7c8dSSergey Avseyev    opaque = $arg2
209b68c7c8dSSergey Avseyev    vbucket = $arg3
210b68c7c8dSSergey Avseyev    opcode = $arg4
211b68c7c8dSSergey Avseyev    key = user_string_n($arg5, $arg6)
212b68c7c8dSSergey Avseyev    delta = $arg7
213b68c7c8dSSergey Avseyev    initial = $arg8
214b68c7c8dSSergey Avseyev    expiration = $arg9
215b68c7c8dSSergey Avseyev}
216b68c7c8dSSergey Avseyev
217b68c7c8dSSergey Avseyev/**
218b68c7c8dSSergey Avseyev * probe libcouchbase.kv.arithmetic.end - end of INCR/DECR operation
219b68c7c8dSSergey Avseyev *
220b68c7c8dSSergey Avseyev * @lcb: client instance
221b68c7c8dSSergey Avseyev * @opaque: unique number for this request (visible on network, returned by server back)
222b68c7c8dSSergey Avseyev * @opcode: opcode, see memcached/protocol_binary.h
223b68c7c8dSSergey Avseyev * @latency_ns: time from schedule to dispatch of the command
224b68c7c8dSSergey Avseyev * @rc: return code from the library see libcouchbase/error.h
225b68c7c8dSSergey Avseyev * @key: document id
226b68c7c8dSSergey Avseyev * @value: current value of the counter (as 64bit number)
227b68c7c8dSSergey Avseyev * @cas: document CAS
228b68c7c8dSSergey Avseyev *
229b68c7c8dSSergey Avseyev * Example:
230b68c7c8dSSergey Avseyev *
231b68c7c8dSSergey Avseyev *   probe libcouchbase.kv.arithmetic.end {
232b68c7c8dSSergey Avseyev *     printf("[%p] opcode: %s, rc: %d, cas: 0x%x, key: %s, value: %d\n",
233b68c7c8dSSergey Avseyev *         lcb, libcouchbase_opcode(opcode), rc, cas, key, value)
234b68c7c8dSSergey Avseyev *   }
235b68c7c8dSSergey Avseyev *
236b68c7c8dSSergey Avseyev *
237b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc decr --delta 3 cnt"
238b68c7c8dSSergey Avseyev *   cnt                 Current value is 42. CAS=0x15026f100ece0000
239b68c7c8dSSergey Avseyev *   [0x6cf0b0] opcode: DECREMENT, rc: 0, cas: 0x15026f100ece0000, key: cnt, value: 42
240b68c7c8dSSergey Avseyev */
241b68c7c8dSSergey Avseyevprobe libcouchbase.kv.arithmetic.end =
242b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("arithmetic_end")
243b68c7c8dSSergey Avseyev{
244b68c7c8dSSergey Avseyev    lcb = $arg1
245b68c7c8dSSergey Avseyev    opaque = $arg2
246b68c7c8dSSergey Avseyev    opcode = $arg3
247b68c7c8dSSergey Avseyev    latency_ns = $arg4
248b68c7c8dSSergey Avseyev    rc = $arg5
249b68c7c8dSSergey Avseyev    key = user_string_n($arg6, $arg7)
250b68c7c8dSSergey Avseyev    value = $arg8
251b68c7c8dSSergey Avseyev    cas = $arg9
252b68c7c8dSSergey Avseyev}
253b68c7c8dSSergey Avseyev
254b68c7c8dSSergey Avseyev/**
255b68c7c8dSSergey Avseyev * probe libcouchbase.kv.remove.begin - start of DELETE operation
256b68c7c8dSSergey Avseyev *
257b68c7c8dSSergey Avseyev * @lcb: client instance
258b68c7c8dSSergey Avseyev * @opaque: unique number for this request (visible on network, returned by server back)
259b68c7c8dSSergey Avseyev * @vbucket: number of partition
260b68c7c8dSSergey Avseyev * @opcode: opcode, see memcached/protocol_binary.h
261b68c7c8dSSergey Avseyev * @key: document id
262b68c7c8dSSergey Avseyev *
263b68c7c8dSSergey Avseyev * Example:
264b68c7c8dSSergey Avseyev *
265b68c7c8dSSergey Avseyev *   probe libcouchbase.kv.remove.begin {
266b68c7c8dSSergey Avseyev *     printf("[%p] opcode: %s, key: %s\n",
267b68c7c8dSSergey Avseyev *         lcb, libcouchbase_opcode(opcode), key)
268b68c7c8dSSergey Avseyev *   }
269b68c7c8dSSergey Avseyev *
270b68c7c8dSSergey Avseyev *
271b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc rm cnt"
272b68c7c8dSSergey Avseyev *   cnt                 Deleted. CAS=0x15026f2ec2c90000
273b68c7c8dSSergey Avseyev *   [0x9280c0] opcode: DELETE, key: cnt
274b68c7c8dSSergey Avseyev */
275b68c7c8dSSergey Avseyevprobe libcouchbase.kv.remove.begin =
276b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("remove_begin")
277b68c7c8dSSergey Avseyev{
278b68c7c8dSSergey Avseyev    lcb = $arg1
279b68c7c8dSSergey Avseyev    opaque = $arg2
280b68c7c8dSSergey Avseyev    vbucket = $arg3
281b68c7c8dSSergey Avseyev    opcode = $arg4
282b68c7c8dSSergey Avseyev    key = user_string_n($arg5, $arg6)
283b68c7c8dSSergey Avseyev}
284b68c7c8dSSergey Avseyev
285b68c7c8dSSergey Avseyev/**
286b68c7c8dSSergey Avseyev * probe libcouchbase.kv.remove.end - end of DELETE operation
287b68c7c8dSSergey Avseyev *
288b68c7c8dSSergey Avseyev * @lcb: client instance
289b68c7c8dSSergey Avseyev * @opaque: unique number for this request (visible on network, returned by server back)
290b68c7c8dSSergey Avseyev * @opcode: opcode, see memcached/protocol_binary.h
291b68c7c8dSSergey Avseyev * @latency_ns: time from schedule to dispatch of the command
292b68c7c8dSSergey Avseyev * @rc: return code from the library see libcouchbase/error.h
293b68c7c8dSSergey Avseyev * @key: document id
294b68c7c8dSSergey Avseyev * @cas: document CAS
295b68c7c8dSSergey Avseyev *
296b68c7c8dSSergey Avseyev * Example:
297b68c7c8dSSergey Avseyev *
298b68c7c8dSSergey Avseyev *   probe libcouchbase.kv.remove.end {
299b68c7c8dSSergey Avseyev *     printf("[%p] opcode: %s, rc: %d, cas: 0x%x, key: %s\n",
300b68c7c8dSSergey Avseyev *         lcb, libcouchbase_opcode(opcode), rc, cas, key)
301b68c7c8dSSergey Avseyev *   }
302b68c7c8dSSergey Avseyev
303b68c7c8dSSergey Avseyev *
304b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc rm cnt"
305b68c7c8dSSergey Avseyev *   cnt                 Deleted. CAS=0x15026f2ec2c90000
306b68c7c8dSSergey Avseyev *   [0x9280c0] opcode: DELETE, rc: 0, cas: 0x15026f2ec2c90000, key: cnt
307b68c7c8dSSergey Avseyev */
308b68c7c8dSSergey Avseyevprobe libcouchbase.kv.remove.end =
309b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("remove_end")
310b68c7c8dSSergey Avseyev{
311b68c7c8dSSergey Avseyev    lcb = $arg1
312b68c7c8dSSergey Avseyev    opaque = $arg2
313b68c7c8dSSergey Avseyev    opcode = $arg3
314b68c7c8dSSergey Avseyev    latency_ns = $arg4
315b68c7c8dSSergey Avseyev    rc = $arg5
316b68c7c8dSSergey Avseyev    key = user_string_n($arg6, $arg7)
317b68c7c8dSSergey Avseyev    cas = $arg8
318b68c7c8dSSergey Avseyev}
319b68c7c8dSSergey Avseyev
320b68c7c8dSSergey Avseyev/**
321b68c7c8dSSergey Avseyev * probe libcouchbase.kv.store.begin - start of SET/ADD/REPLACE/APPEND/PREPEND operation
322b68c7c8dSSergey Avseyev *
323b68c7c8dSSergey Avseyev * @lcb: client instance
324b68c7c8dSSergey Avseyev * @opaque: unique number for this request (visible on network, returned by server back)
325b68c7c8dSSergey Avseyev * @vbucket: number of partition
326b68c7c8dSSergey Avseyev * @opcode: opcode, see memcached/protocol_binary.h
327b68c7c8dSSergey Avseyev * @key: document id
328b68c7c8dSSergey Avseyev * @bytes: document body
329b68c7c8dSSergey Avseyev * @flags: document flags
330b68c7c8dSSergey Avseyev * @cas: document CAS
331b68c7c8dSSergey Avseyev * @datatype: document datatype, see memcached/protocol_binary.h
332b68c7c8dSSergey Avseyev * @expiration: document expiration (0 when should not expire)
333b68c7c8dSSergey Avseyev *
334b68c7c8dSSergey Avseyev * Example:
335b68c7c8dSSergey Avseyev *
336b68c7c8dSSergey Avseyev *   probe libcouchbase.kv.store.begin {
337b68c7c8dSSergey Avseyev *     printf("[%p] opcode: %s, key: %s, value: %s, expiration: %d\n",
338b68c7c8dSSergey Avseyev *         lcb, libcouchbase_opcode(opcode), key, bytes, expiration)
339b68c7c8dSSergey Avseyev *   }
340b68c7c8dSSergey Avseyev *
341b68c7c8dSSergey Avseyev *
342b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc cp -e 30 foo"
343b68c7c8dSSergey Avseyev *   foo                 Stored. CAS=0x15026f8450790000
344b68c7c8dSSergey Avseyev *   [0x7e0070] opcode: SET, key: foo, value: {"foo":"bar"}, expiration: 30
345b68c7c8dSSergey Avseyev */
346b68c7c8dSSergey Avseyevprobe libcouchbase.kv.store.begin =
347b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("store_begin")
348b68c7c8dSSergey Avseyev{
349b68c7c8dSSergey Avseyev    lcb = $arg1
350b68c7c8dSSergey Avseyev    opaque = $arg2
351b68c7c8dSSergey Avseyev    vbucket = $arg3
352b68c7c8dSSergey Avseyev    opcode = $arg4
353b68c7c8dSSergey Avseyev    key = user_string_n($arg5, $arg6)
354b68c7c8dSSergey Avseyev    bytes = user_string_n($arg7, $arg8)
355b68c7c8dSSergey Avseyev    flags = $arg9
356b68c7c8dSSergey Avseyev    cas = $arg10
357b68c7c8dSSergey Avseyev    datatype = $arg11
358b68c7c8dSSergey Avseyev    expiration = $arg12
359b68c7c8dSSergey Avseyev}
360b68c7c8dSSergey Avseyev
361b68c7c8dSSergey Avseyev/**
362b68c7c8dSSergey Avseyev * probe libcouchbase.kv.store.end - end of SET/ADD/REPLACE/APPEND/PREPEND operation
363b68c7c8dSSergey Avseyev *
364b68c7c8dSSergey Avseyev * @lcb: client instance
365b68c7c8dSSergey Avseyev * @opaque: unique number for this request (visible on network, returned by server back)
366b68c7c8dSSergey Avseyev * @opcode: opcode, see memcached/protocol_binary.h
367b68c7c8dSSergey Avseyev * @latency_ns: time from schedule to dispatch of the command
368b68c7c8dSSergey Avseyev * @rc: return code from the library see libcouchbase/error.h
369b68c7c8dSSergey Avseyev * @key: document id
370b68c7c8dSSergey Avseyev * @cas: document CAS
371b68c7c8dSSergey Avseyev *
372b68c7c8dSSergey Avseyev * Example:
373b68c7c8dSSergey Avseyev *
374b68c7c8dSSergey Avseyev *   probe libcouchbase.kv.store.end {
375b68c7c8dSSergey Avseyev *     printf("[%p] opcode: %s, rc: %d, cas: 0x%x, key: %s\n",
376b68c7c8dSSergey Avseyev *         lcb, libcouchbase_opcode(opcode), rc, cas, key)
377b68c7c8dSSergey Avseyev *   }
378b68c7c8dSSergey Avseyev *
379b68c7c8dSSergey Avseyev *
380b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc cp -e 30 foo"
381b68c7c8dSSergey Avseyev *   foo                 Stored. CAS=0x15026f8450790000
382b68c7c8dSSergey Avseyev *   [0x7e0070] opcode: SET, rc: 0, cas: 0x15026f8450790000, key: foo
383b68c7c8dSSergey Avseyev */
384b68c7c8dSSergey Avseyevprobe libcouchbase.kv.store.end =
385b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("store_end")
386b68c7c8dSSergey Avseyev{
387b68c7c8dSSergey Avseyev    lcb = $arg1
388b68c7c8dSSergey Avseyev    opaque = $arg2
389b68c7c8dSSergey Avseyev    opcode = $arg3
390b68c7c8dSSergey Avseyev    latency_ns = $arg4
391b68c7c8dSSergey Avseyev    rc = $arg5
392b68c7c8dSSergey Avseyev    key = user_string_n($arg6, $arg7)
393b68c7c8dSSergey Avseyev    cas = $arg8
394b68c7c8dSSergey Avseyev}
395b68c7c8dSSergey Avseyev
396b68c7c8dSSergey Avseyev/**
397b68c7c8dSSergey Avseyev * probe libcouchbase.kv.unlock.begin - start of UNLOCK operation
398b68c7c8dSSergey Avseyev *
399b68c7c8dSSergey Avseyev * @lcb: client instance
400b68c7c8dSSergey Avseyev * @opaque: unique number for this request (visible on network, returned by server back)
401b68c7c8dSSergey Avseyev * @vbucket: number of partition
402b68c7c8dSSergey Avseyev * @opcode: opcode, see memcached/protocol_binary.h
403b68c7c8dSSergey Avseyev * @key: document id
404b68c7c8dSSergey Avseyev *
405b68c7c8dSSergey Avseyev * Example:
406b68c7c8dSSergey Avseyev *
407b68c7c8dSSergey Avseyev *   probe libcouchbase.kv.unlock.begin {
408b68c7c8dSSergey Avseyev *     printf("[%p] opcode: %s, key: %s\n",
409b68c7c8dSSergey Avseyev *         lcb, libcouchbase_opcode(opcode), key)
410b68c7c8dSSergey Avseyev *   }
411b68c7c8dSSergey Avseyev *
412b68c7c8dSSergey Avseyev *
413b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc unlock foo 0x15028f7bafc20000"
414b68c7c8dSSergey Avseyev *   foo                  Unlocked
415b68c7c8dSSergey Avseyev *   [0x20d7100] opcode: UNLOCK_KEY, key: foo
416b68c7c8dSSergey Avseyev */
417b68c7c8dSSergey Avseyevprobe libcouchbase.kv.unlock.begin =
418b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("unlock_begin")
419b68c7c8dSSergey Avseyev{
420b68c7c8dSSergey Avseyev    lcb = $arg1
421b68c7c8dSSergey Avseyev    opaque = $arg2
422b68c7c8dSSergey Avseyev    vbucket = $arg3
423b68c7c8dSSergey Avseyev    opcode = $arg4
424b68c7c8dSSergey Avseyev    key = user_string_n($arg5, $arg6)
425b68c7c8dSSergey Avseyev}
426b68c7c8dSSergey Avseyev
427b68c7c8dSSergey Avseyev/**
428b68c7c8dSSergey Avseyev * probe libcouchbase.kv.unlock.end - end of UNLOCK operation
429b68c7c8dSSergey Avseyev *
430b68c7c8dSSergey Avseyev * @lcb: client instance
431b68c7c8dSSergey Avseyev * @opaque: unique number for this request (visible on network, returned by server back)
432b68c7c8dSSergey Avseyev * @opcode: opcode, see memcached/protocol_binary.h
433b68c7c8dSSergey Avseyev * @latency_ns: time from schedule to dispatch of the command
434b68c7c8dSSergey Avseyev * @rc: return code from the library see libcouchbase/error.h
435b68c7c8dSSergey Avseyev * @key: document id
436b68c7c8dSSergey Avseyev *
437b68c7c8dSSergey Avseyev * Example:
438b68c7c8dSSergey Avseyev *
439b68c7c8dSSergey Avseyev *   probe libcouchbase.kv.unlock.end {
440b68c7c8dSSergey Avseyev *     printf("[%p] opcode: %s, rc: %d, key: %s\n",
441b68c7c8dSSergey Avseyev *         lcb, libcouchbase_opcode(opcode), rc, key)
442b68c7c8dSSergey Avseyev *   }
443b68c7c8dSSergey Avseyev *
444b68c7c8dSSergey Avseyev *
445b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc unlock foo 0x15028f7bafc20000"
446b68c7c8dSSergey Avseyev *   foo                  Unlocked
447b68c7c8dSSergey Avseyev *   [0x20d7100] opcode: UNLOCK_KEY, rc: 0, key: foo
448b68c7c8dSSergey Avseyev */
449b68c7c8dSSergey Avseyevprobe libcouchbase.kv.unlock.end =
450b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("unlock_end")
451b68c7c8dSSergey Avseyev{
452b68c7c8dSSergey Avseyev    lcb = $arg1
453b68c7c8dSSergey Avseyev    opaque = $arg2
454b68c7c8dSSergey Avseyev    opcode = $arg3
455b68c7c8dSSergey Avseyev    latency_ns = $arg4
456b68c7c8dSSergey Avseyev    rc = $arg5
457b68c7c8dSSergey Avseyev    key = user_string_n($arg6, $arg7)
458b68c7c8dSSergey Avseyev}
459b68c7c8dSSergey Avseyev
460b68c7c8dSSergey Avseyev/**
461b68c7c8dSSergey Avseyev * probe libcouchbase.kv.touch.begin - start of TOUCH operation
462b68c7c8dSSergey Avseyev *
463b68c7c8dSSergey Avseyev * @lcb: client instance
464b68c7c8dSSergey Avseyev * @opaque: unique number for this request (visible on network, returned by server back)
465b68c7c8dSSergey Avseyev * @vbucket: number of partition
466b68c7c8dSSergey Avseyev * @opcode: opcode, see memcached/protocol_binary.h
467b68c7c8dSSergey Avseyev * @key: document id
468b68c7c8dSSergey Avseyev * @expiration: document expiration (0 when should not expire)
469b68c7c8dSSergey Avseyev *
470b68c7c8dSSergey Avseyev * Example:
471b68c7c8dSSergey Avseyev *
472b68c7c8dSSergey Avseyev *   probe libcouchbase.kv.touch.begin {
473b68c7c8dSSergey Avseyev *     printf("[%p] opcode: %s, key: %s, expiration: %d\n",
474b68c7c8dSSergey Avseyev *         lcb, libcouchbase_opcode(opcode), key, expiration)
475b68c7c8dSSergey Avseyev *   }
476b68c7c8dSSergey Avseyev *
477b68c7c8dSSergey Avseyev *
478b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc touch -e 10 foo"
479b68c7c8dSSergey Avseyev *   foo                 Touched. CAS=0x150290b309ad0000
480b68c7c8dSSergey Avseyev *   [0x141edb0] opcode: TOUCH, rc: 0, cas: 0x150290b309ad0000, key: foo
481b68c7c8dSSergey Avseyev */
482b68c7c8dSSergey Avseyevprobe libcouchbase.kv.touch.begin =
483b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("touch_begin")
484b68c7c8dSSergey Avseyev{
485b68c7c8dSSergey Avseyev    lcb = $arg1
486b68c7c8dSSergey Avseyev    opaque = $arg2
487b68c7c8dSSergey Avseyev    vbucket = $arg3
488b68c7c8dSSergey Avseyev    opcode = $arg4
489b68c7c8dSSergey Avseyev    key = user_string_n($arg5, $arg6)
490b68c7c8dSSergey Avseyev    expiration = $arg7
491b68c7c8dSSergey Avseyev}
492b68c7c8dSSergey Avseyev
493b68c7c8dSSergey Avseyev/**
494b68c7c8dSSergey Avseyev * probe libcouchbase.kv.touch.end - end of TOUCH operation
495b68c7c8dSSergey Avseyev *
496b68c7c8dSSergey Avseyev * @lcb: client instance
497b68c7c8dSSergey Avseyev * @opaque: unique number for this request (visible on network, returned by server back)
498b68c7c8dSSergey Avseyev * @opcode: opcode, see memcached/protocol_binary.h
499b68c7c8dSSergey Avseyev * @latency_ns: time from schedule to dispatch of the command
500b68c7c8dSSergey Avseyev * @rc: return code from the library see libcouchbase/error.h
501b68c7c8dSSergey Avseyev * @key: document id
502b68c7c8dSSergey Avseyev * @cas: document CAS
503b68c7c8dSSergey Avseyev *
504b68c7c8dSSergey Avseyev * Example:
505b68c7c8dSSergey Avseyev *
506b68c7c8dSSergey Avseyev *   probe libcouchbase.kv.touch.end {
507b68c7c8dSSergey Avseyev *     printf("[%p] opcode: %s, rc: %d, cas: 0x%x, key: %s\n",
508b68c7c8dSSergey Avseyev *         lcb, libcouchbase_opcode(opcode), rc, cas, key)
509b68c7c8dSSergey Avseyev *   }
510b68c7c8dSSergey Avseyev *
511b68c7c8dSSergey Avseyev *
512b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc touch -e 10 foo"
513b68c7c8dSSergey Avseyev *   foo                 Touched. CAS=0x150290b309ad0000
514b68c7c8dSSergey Avseyev *   [0x141edb0] opcode: TOUCH, rc: 0, cas: 0x150290b309ad0000, key: foo
515b68c7c8dSSergey Avseyev */
516b68c7c8dSSergey Avseyevprobe libcouchbase.kv.touch.end =
517b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("touch_end")
518b68c7c8dSSergey Avseyev{
519b68c7c8dSSergey Avseyev    lcb = $arg1
520b68c7c8dSSergey Avseyev    opaque = $arg2
521b68c7c8dSSergey Avseyev    opcode = $arg3
522b68c7c8dSSergey Avseyev    latency_ns = $arg4
523b68c7c8dSSergey Avseyev    rc = $arg5
524b68c7c8dSSergey Avseyev    key = user_string_n($arg6, $arg7)
525b68c7c8dSSergey Avseyev    cas = $arg8
526b68c7c8dSSergey Avseyev}
527b68c7c8dSSergey Avseyev
528b68c7c8dSSergey Avseyev/*
529b68c7c8dSSergey Avseyev * probe libcouchbase.kv.observe.begin - start of OBSERVE operation
530b68c7c8dSSergey Avseyev *
531b68c7c8dSSergey Avseyev * @lcb: client instance
532b68c7c8dSSergey Avseyev * @opaque: unique number for this request (visible on network, returned by server back)
533b68c7c8dSSergey Avseyev * @opcode: opcode, see memcached/protocol_binary.h
534b68c7c8dSSergey Avseyev * @bytes: pointer to payload (as long)
535b68c7c8dSSergey Avseyev * @nbytes: size of payload
536b68c7c8dSSergey Avseyev *
537b68c7c8dSSergey Avseyev * libcouchbase.observe.begin probe intended to be parsed in the handler.
538b68c7c8dSSergey Avseyev * the bytes argument is a blob with nbytes length:
539b68c7c8dSSergey Avseyev *
540b68c7c8dSSergey Avseyev * +---------+---------+------------+----
541b68c7c8dSSergey Avseyev * | 16 bits | 16 bits | nkey bytes | ...
542b68c7c8dSSergey Avseyev * +---------+---------+------------+----
543b68c7c8dSSergey Avseyev * | vbucket |   nkey  |    key     | ...
544b68c7c8dSSergey Avseyev * +---------+---------+------------+----
545b68c7c8dSSergey Avseyev *
546b68c7c8dSSergey Avseyev * Example:
547b68c7c8dSSergey Avseyev *
548b68c7c8dSSergey Avseyev *   probe libcouchbase.kv.observe.begin {
549b68c7c8dSSergey Avseyev *     printf("[%p] opcode: %d, opaque: %d\n", lcb, libcouchbase_opcode(opcode), opaque)
550b68c7c8dSSergey Avseyev *     while (nbytes > 0) {
551b68c7c8dSSergey Avseyev *       vbucket = ntohs(user_uint16(bytes))
552b68c7c8dSSergey Avseyev *       nbytes -= 2
553b68c7c8dSSergey Avseyev *       bytes += 2
554b68c7c8dSSergey Avseyev *       nkey = ntohs(user_uint16(bytes))
555b68c7c8dSSergey Avseyev *       nbytes -= 2
556b68c7c8dSSergey Avseyev *       bytes += 2
557b68c7c8dSSergey Avseyev *       key = user_string_n(bytes, nkey)
558b68c7c8dSSergey Avseyev *       nbytes -= nkey
559b68c7c8dSSergey Avseyev *       bytes += nkey
560b68c7c8dSSergey Avseyev *       printf("    vbucket: %d, nkey: %d, key: %s\n", vbucket, nkey, key)
561b68c7c8dSSergey Avseyev *     }
562b68c7c8dSSergey Avseyev *   }
563b68c7c8dSSergey Avseyev *
564b68c7c8dSSergey Avseyev *
565b68c7c8dSSergey Avseyev * The following command executed on cluster with 4 nodes, and replication factor 3.
566b68c7c8dSSergey Avseyev *
567b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc observe foo bar"
568b68c7c8dSSergey Avseyev *   foo                  [Replica] Status=0x1, CAS=0x1502952004ed0000
569b68c7c8dSSergey Avseyev *   bar                  [Replica] Status=0x1, CAS=0x1502951fe0040000
570b68c7c8dSSergey Avseyev *   foo                  [Replica] Status=0x1, CAS=0x1502952004ed0000
571b68c7c8dSSergey Avseyev *   bar                  [Master] Status=0x1, CAS=0x1502951fe0040000
572b68c7c8dSSergey Avseyev *   foo                  [Replica] Status=0x1, CAS=0x1502952004ed0000
573b68c7c8dSSergey Avseyev *   bar                  [Replica] Status=0x1, CAS=0x1502951fe0040000
574b68c7c8dSSergey Avseyev *   foo                  [Master] Status=0x1, CAS=0x1502952004ed0000
575b68c7c8dSSergey Avseyev *   bar                  [Replica] Status=0x1, CAS=0x1502951fe0040000
576b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 0
577b68c7c8dSSergey Avseyev *      vbucket: 115, nkey: 3, key: foo
578b68c7c8dSSergey Avseyev *      vbucket: 767, nkey: 3, key: bar
579b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 1
580b68c7c8dSSergey Avseyev *      vbucket: 115, nkey: 3, key: foo
581b68c7c8dSSergey Avseyev *      vbucket: 767, nkey: 3, key: bar
582b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 2
583b68c7c8dSSergey Avseyev *      vbucket: 115, nkey: 3, key: foo
584b68c7c8dSSergey Avseyev *      vbucket: 767, nkey: 3, key: bar
585b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 3
586b68c7c8dSSergey Avseyev *      vbucket: 115, nkey: 3, key: foo
587b68c7c8dSSergey Avseyev *      vbucket: 767, nkey: 3, key: bar
588b68c7c8dSSergey Avseyev */
589b68c7c8dSSergey Avseyevprobe libcouchbase.kv.observe.begin =
590b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("observe_begin")
591b68c7c8dSSergey Avseyev{
592b68c7c8dSSergey Avseyev    lcb = $arg1
593b68c7c8dSSergey Avseyev    opaque = $arg2
594b68c7c8dSSergey Avseyev    opcode = $arg4
595b68c7c8dSSergey Avseyev    bytes = $arg5
596b68c7c8dSSergey Avseyev    nbytes = $arg6
597b68c7c8dSSergey Avseyev}
598b68c7c8dSSergey Avseyev
599b68c7c8dSSergey Avseyev/**
600b68c7c8dSSergey Avseyev * probe libcouchbase.kv.observe.progress - intermediate response of OBSERVE operation
601b68c7c8dSSergey Avseyev *
602b68c7c8dSSergey Avseyev * @lcb: client instance
603b68c7c8dSSergey Avseyev * @opaque: unique number for this request (visible on network, returned by server back)
604b68c7c8dSSergey Avseyev * @vbucket: number of partition
605b68c7c8dSSergey Avseyev * @opcode: opcode, see memcached/protocol_binary.h
606b68c7c8dSSergey Avseyev * @latency_ns: time from schedule to dispatch of the command
607b68c7c8dSSergey Avseyev * @rc: return code from the library see libcouchbase/error.h
608b68c7c8dSSergey Avseyev * @key: document id
609b68c7c8dSSergey Avseyev * @status: observe status: FOUND = 0x00, PERSISTED = 0x01, NOT_FOUND = 0x80
610b68c7c8dSSergey Avseyev * @master: whether response from master node (zero if from replica)
611b68c7c8dSSergey Avseyev * @ttp: time to persist
612b68c7c8dSSergey Avseyev * @ttr: time to replicate
613b68c7c8dSSergey Avseyev *
614b68c7c8dSSergey Avseyev * Example:
615b68c7c8dSSergey Avseyev *
616b68c7c8dSSergey Avseyev *   probe libcouchbase.kv.observe.progress {
617b68c7c8dSSergey Avseyev *     printf("[%p] opcode: %s, opaque: %d, rc: %d, key: %s, status: %d, master: %s\n",
618b68c7c8dSSergey Avseyev *         lcb, libcouchbase_opcode(opcode), opaque, rc, key, status, master ? "true" : "false")
619b68c7c8dSSergey Avseyev *   }
620b68c7c8dSSergey Avseyev *
621b68c7c8dSSergey Avseyev *
622b68c7c8dSSergey Avseyev * The following command executed on cluster with 4 nodes, and replication factor 3.
623b68c7c8dSSergey Avseyev *
624b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc observe foo bar"
625b68c7c8dSSergey Avseyev *   foo                  [Replica] Status=0x1, CAS=0x1502952004ed0000
626b68c7c8dSSergey Avseyev *   bar                  [Replica] Status=0x1, CAS=0x1502951fe0040000
627b68c7c8dSSergey Avseyev *   foo                  [Replica] Status=0x1, CAS=0x1502952004ed0000
628b68c7c8dSSergey Avseyev *   bar                  [Master] Status=0x1, CAS=0x1502951fe0040000
629b68c7c8dSSergey Avseyev *   foo                  [Replica] Status=0x1, CAS=0x1502952004ed0000
630b68c7c8dSSergey Avseyev *   bar                  [Replica] Status=0x1, CAS=0x1502951fe0040000
631b68c7c8dSSergey Avseyev *   foo                  [Master] Status=0x1, CAS=0x1502952004ed0000
632b68c7c8dSSergey Avseyev *   bar                  [Replica] Status=0x1, CAS=0x1502951fe0040000
633b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 0, rc: 0, key: foo, status: 1, master: false
634b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 0, rc: 0, key: bar, status: 1, master: false
635b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 3, rc: 0, key: foo, status: 1, master: false
636b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 3, rc: 0, key: bar, status: 1, master: true
637b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 1, rc: 0, key: foo, status: 1, master: false
638b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 1, rc: 0, key: bar, status: 1, master: false
639b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 2, rc: 0, key: foo, status: 1, master: true
640b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 2, rc: 0, key: bar, status: 1, master: false
641b68c7c8dSSergey Avseyev */
642b68c7c8dSSergey Avseyevprobe libcouchbase.kv.observe.progress =
643b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("observe_progress")
644b68c7c8dSSergey Avseyev{
645b68c7c8dSSergey Avseyev    lcb = $arg1
646b68c7c8dSSergey Avseyev    opaque = $arg2
647b68c7c8dSSergey Avseyev    opcode = $arg3
648b68c7c8dSSergey Avseyev    latency_ns = $arg4
649b68c7c8dSSergey Avseyev    rc = $arg5
650b68c7c8dSSergey Avseyev    key = user_string_n($arg6, $arg7)
651b68c7c8dSSergey Avseyev    cas = $arg8
652b68c7c8dSSergey Avseyev    status = $arg9
653b68c7c8dSSergey Avseyev    master = $arg10
654b68c7c8dSSergey Avseyev    ttp = $arg11
655b68c7c8dSSergey Avseyev    ttr = $arg12
656b68c7c8dSSergey Avseyev}
657b68c7c8dSSergey Avseyev
658b68c7c8dSSergey Avseyev/**
659b68c7c8dSSergey Avseyev * probe libcouchbase.kv.observe.end - end of OBSERVE operation
660b68c7c8dSSergey Avseyev *
661b68c7c8dSSergey Avseyev * @lcb: client instance
662b68c7c8dSSergey Avseyev * @opaque: unique number for this request (visible on network, returned by server back)
663b68c7c8dSSergey Avseyev * @opcode: opcode, see memcached/protocol_binary.h
664b68c7c8dSSergey Avseyev * @latency_ns: time from schedule to dispatch of the command
665b68c7c8dSSergey Avseyev * @rc: return code from the library see libcouchbase/error.h
666b68c7c8dSSergey Avseyev *
667b68c7c8dSSergey Avseyev * Example:
668b68c7c8dSSergey Avseyev *
669b68c7c8dSSergey Avseyev *   probe libcouchbase.kv.observe.end {
670b68c7c8dSSergey Avseyev *     printf("[%p] opcode: %s, opaque, rc: %d\n",
671b68c7c8dSSergey Avseyev *         lcb, libcouchbase_opcode(opcode), opaque, rc)
672b68c7c8dSSergey Avseyev *   }
673b68c7c8dSSergey Avseyev *
674b68c7c8dSSergey Avseyev *
675b68c7c8dSSergey Avseyev * The following command executed on cluster with 4 nodes, and replication factor 3.
676b68c7c8dSSergey Avseyev *
677b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc observe foo bar"
678b68c7c8dSSergey Avseyev *   foo                  [Replica] Status=0x1, CAS=0x1502952004ed0000
679b68c7c8dSSergey Avseyev *   bar                  [Replica] Status=0x1, CAS=0x1502951fe0040000
680b68c7c8dSSergey Avseyev *   foo                  [Replica] Status=0x1, CAS=0x1502952004ed0000
681b68c7c8dSSergey Avseyev *   bar                  [Master] Status=0x1, CAS=0x1502951fe0040000
682b68c7c8dSSergey Avseyev *   foo                  [Replica] Status=0x1, CAS=0x1502952004ed0000
683b68c7c8dSSergey Avseyev *   bar                  [Replica] Status=0x1, CAS=0x1502951fe0040000
684b68c7c8dSSergey Avseyev *   foo                  [Master] Status=0x1, CAS=0x1502952004ed0000
685b68c7c8dSSergey Avseyev *   bar                  [Replica] Status=0x1, CAS=0x1502951fe0040000
686b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 0, rc: 0
687b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 3, rc: 0
688b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 1, rc: 0
689b68c7c8dSSergey Avseyev *   [0xb33dc0] opcode: OBSERVE, opaque: 2, rc: 0
690b68c7c8dSSergey Avseyev */
691b68c7c8dSSergey Avseyevprobe libcouchbase.kv.observe.end =
692b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("observe_end")
693b68c7c8dSSergey Avseyev{
694b68c7c8dSSergey Avseyev    lcb = $arg1
695b68c7c8dSSergey Avseyev    opaque = $arg2
696b68c7c8dSSergey Avseyev    opcode = $arg3
697b68c7c8dSSergey Avseyev    latency_ns = $arg4
698b68c7c8dSSergey Avseyev    rc = $arg5
699b68c7c8dSSergey Avseyev}
700b68c7c8dSSergey Avseyev
701b68c7c8dSSergey Avseyev/**
702b68c7c8dSSergey Avseyev * probe libcouchbase.http.begin - start of HTTP request
703b68c7c8dSSergey Avseyev *
704b68c7c8dSSergey Avseyev * @lcb: client instance
705b68c7c8dSSergey Avseyev * @req: pointer to request
706b68c7c8dSSergey Avseyev * @type: type of request, see enum lcb_http_type_t in libcouchbase/couchbase.h
707b68c7c8dSSergey Avseyev * @method: HTTP method of request, see enum lcb_http_method_t in libcouchbase/couchbase.h
708b68c7c8dSSergey Avseyev * @url: request URL (including schema, host and port)
709b68c7c8dSSergey Avseyev * @host: target hostname
710b68c7c8dSSergey Avseyev * @port: target port
711b68c7c8dSSergey Avseyev *
712b68c7c8dSSergey Avseyev * Example:
713b68c7c8dSSergey Avseyev *
714b68c7c8dSSergey Avseyev *   probe libcouchbase.http.begin {
715b68c7c8dSSergey Avseyev *     printf("[%p] req: %p, type: %s, url: %s, host: %s, port: %s\n",
716b68c7c8dSSergey Avseyev *         lcb, req, libcouchbase_http_type(type), url, host, port)
717b68c7c8dSSergey Avseyev *   }
718b68c7c8dSSergey Avseyev *
719b68c7c8dSSergey Avseyev *
720b68c7c8dSSergey Avseyev *   $ stap  test.stp  -c "cbc n1ql 'select 1'"
721b68c7c8dSSergey Avseyev *   ---> Encoded query: {"statement":"select 1"}
722b68c7c8dSSergey Avseyev *
723b68c7c8dSSergey Avseyev *   {"$1":1},
724b68c7c8dSSergey Avseyev *   ---> Query response finished
725b68c7c8dSSergey Avseyev *   {
726b68c7c8dSSergey Avseyev *   "requestID": "c36facda-b37e-43b5-a958-7f31afb8468f",
727b68c7c8dSSergey Avseyev *   "signature": {"$1":"number"},
728b68c7c8dSSergey Avseyev *   "results": [
729b68c7c8dSSergey Avseyev *   ],
730b68c7c8dSSergey Avseyev *   "status": "success",
731b68c7c8dSSergey Avseyev *   "metrics": {"elapsedTime": "380.883µs","executionTime": "360.955µs","resultCount": 1,"resultSize": 8}
732b68c7c8dSSergey Avseyev *   }
733b68c7c8dSSergey Avseyev *
734b68c7c8dSSergey Avseyev *   [0x1af6de0] req: 0x1b12250, type: N1QL, url: http://192.168.1.104:8093/query/service, host: 192.168.1.104, port: 8093
735b68c7c8dSSergey Avseyev */
736b68c7c8dSSergey Avseyevprobe libcouchbase.http.begin =
737b68c7c8dSSergey Avseyev    process("${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcouchbase.so.${LCB_SONAME_FULL}").mark("http_begin")
738b68c7c8dSSergey Avseyev{
739b68c7c8dSSergey Avseyev    lcb = $arg1
740b68c7c8dSSergey Avseyev    req = $arg2
741b68c7c8dSSergey Avseyev    type = $arg3
742b68c7c8dSSergey Avseyev    method = $arg4
743b68c7c8d