1515 * * limitations under the License.
1616 *
1717 */
18-
1918use crate :: clients:: bucket_client:: BucketClient ;
2019use crate :: clients:: collections_mgmt_client:: CollectionsMgmtClient ;
2120use crate :: clients:: diagnostics_client:: DiagnosticsClient ;
21+ use crate :: clients:: tracing_client:: TracingClient ;
2222use crate :: collection:: Collection ;
2323use crate :: error;
2424use crate :: management:: collections:: collection_manager:: CollectionManager ;
2525use crate :: options:: diagnostic_options:: { PingOptions , WaitUntilReadyOptions } ;
2626use crate :: results:: diagnostics:: PingReport ;
2727use crate :: scope:: Scope ;
28+ use crate :: tracing:: Keyspace ;
29+ use couchbase_core:: create_span;
30+ use tracing:: Instrument ;
2831
2932#[ derive( Clone ) ]
3033pub struct Bucket {
3134 client : BucketClient ,
3235 collections_mgmt_client : CollectionsMgmtClient ,
3336 diagnostics_client : DiagnosticsClient ,
37+ tracing_client : TracingClient ,
3438}
3539
3640impl Bucket {
3741 pub ( crate ) fn new ( client : BucketClient ) -> Self {
3842 let collections_mgmt_client = client. collections_management_client ( ) ;
3943 let diagnostics_client = client. diagnostics_client ( ) ;
44+ let tracing_client = client. tracing_client ( ) ;
4045
4146 Self {
4247 client,
4348 collections_mgmt_client,
4449 diagnostics_client,
50+ tracing_client,
51+ }
52+ }
53+
54+ fn keyspace ( & self ) -> Keyspace < ' _ > {
55+ Keyspace :: Bucket {
56+ bucket : self . client . name ( ) ,
4557 }
4658 }
4759
@@ -68,15 +80,35 @@ impl Bucket {
6880 }
6981
7082 pub async fn ping ( & self , opts : impl Into < Option < PingOptions > > ) -> error:: Result < PingReport > {
71- let opts = opts. into ( ) . unwrap_or_default ( ) ;
72- self . diagnostics_client . ping ( opts) . await
83+ let keyspace = self . keyspace ( ) ;
84+ let ctx = self
85+ . tracing_client
86+ . begin_operation ( None , keyspace, create_span ! ( "ping" ) )
87+ . await ;
88+ let result = self
89+ . diagnostics_client
90+ . ping ( opts. into ( ) . unwrap_or_default ( ) )
91+ . instrument ( ctx. span ( ) . clone ( ) )
92+ . await ;
93+ ctx. end_operation ( result. as_ref ( ) . err ( ) ) ;
94+ result
7395 }
7496
7597 pub async fn wait_until_ready (
7698 & self ,
7799 opts : impl Into < Option < WaitUntilReadyOptions > > ,
78100 ) -> error:: Result < ( ) > {
79- let opts = opts. into ( ) . unwrap_or_default ( ) ;
80- self . diagnostics_client . wait_until_ready ( opts) . await
101+ let keyspace = self . keyspace ( ) ;
102+ let ctx = self
103+ . tracing_client
104+ . begin_operation ( None , keyspace, create_span ! ( "wait_until_ready" ) )
105+ . await ;
106+ let result = self
107+ . diagnostics_client
108+ . wait_until_ready ( opts. into ( ) . unwrap_or_default ( ) )
109+ . instrument ( ctx. span ( ) . clone ( ) )
110+ . await ;
111+ ctx. end_operation ( result. as_ref ( ) . err ( ) ) ;
112+ result
81113 }
82114}
0 commit comments