@@ -119,8 +119,11 @@ async def get(self,
119119 print(f'Document value: {res.content_as[dict]}')
120120
121121 """
122- op_type = KeyValueOperationType .Get
123- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
122+ instruments = self ._impl .observability_instruments
123+ if instruments .is_noop :
124+ req = self ._impl .request_builder .build_get_request (key , None , * opts , ** kwargs )
125+ return await self ._impl .get (req , None )
126+ async with ObservableRequestHandler (KeyValueOperationType .Get , instruments ) as obs_handler :
124127 req = self ._impl .request_builder .build_get_request (key , obs_handler , * opts , ** kwargs )
125128 return await self ._impl .get (req , obs_handler )
126129
@@ -170,8 +173,11 @@ async def get_any_replica(self,
170173 print(f'Document value: {res.content_as[dict]}')
171174
172175 """ # noqa: E501
173- op_type = KeyValueOperationType .GetAnyReplica
174- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
176+ instruments = self ._impl .observability_instruments
177+ if instruments .is_noop :
178+ req = self ._impl .request_builder .build_get_any_replica_request (key , None , * opts , ** kwargs )
179+ return await self ._impl .get_any_replica (req , None )
180+ async with ObservableRequestHandler (KeyValueOperationType .GetAnyReplica , instruments ) as obs_handler :
175181 req = self ._impl .request_builder .build_get_any_replica_request (key , obs_handler , * opts , ** kwargs )
176182 return await self ._impl .get_any_replica (req , obs_handler )
177183
@@ -241,8 +247,11 @@ async def get_all_replicas(self,
241247 break
242248
243249 """
244- op_type = KeyValueOperationType .GetAllReplicas
245- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
250+ instruments = self ._impl .observability_instruments
251+ if instruments .is_noop :
252+ req = self ._impl .request_builder .build_get_all_replicas_request (key , None , * opts , ** kwargs )
253+ return await self ._impl .get_all_replicas (req , None )
254+ async with ObservableRequestHandler (KeyValueOperationType .GetAllReplicas , instruments ) as obs_handler :
246255 req = self ._impl .request_builder .build_get_all_replicas_request (key , obs_handler , * opts , ** kwargs )
247256 return await self ._impl .get_all_replicas (req , obs_handler )
248257
@@ -287,8 +296,11 @@ async def exists(self,
287296 print(f'Document w/ key - {key} {"exists" if res.exists else "does not exist"}')
288297
289298 """
290- op_type = KeyValueOperationType .Exists
291- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
299+ instruments = self ._impl .observability_instruments
300+ if instruments .is_noop :
301+ req = self ._impl .request_builder .build_exists_request (key , None , * opts , ** kwargs )
302+ return await self ._impl .exists (req , None )
303+ async with ObservableRequestHandler (KeyValueOperationType .Exists , instruments ) as obs_handler :
292304 req = self ._impl .request_builder .build_exists_request (key , obs_handler , * opts , ** kwargs )
293305 return await self ._impl .exists (req , obs_handler )
294306
@@ -354,8 +366,11 @@ async def insert(self,
354366 res = await collection.insert(key, doc, InsertOptions(durability=durability))
355367
356368 """
357- op_type = KeyValueOperationType .Insert
358- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
369+ instruments = self ._impl .observability_instruments
370+ if instruments .is_noop :
371+ req = self ._impl .request_builder .build_insert_request (key , value , None , * opts , ** kwargs )
372+ return await self ._impl .insert (req , None )
373+ async with ObservableRequestHandler (KeyValueOperationType .Insert , instruments ) as obs_handler :
359374 req = self ._impl .request_builder .build_insert_request (key , value , obs_handler , * opts , ** kwargs )
360375 return await self ._impl .insert (req , obs_handler )
361376
@@ -417,8 +432,11 @@ async def upsert(self,
417432 res = await collection.upsert(key, doc, InsertOptions(durability=durability))
418433
419434 """
420- op_type = KeyValueOperationType .Upsert
421- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
435+ instruments = self ._impl .observability_instruments
436+ if instruments .is_noop :
437+ req = self ._impl .request_builder .build_upsert_request (key , value , None , * opts , ** kwargs )
438+ return await self ._impl .upsert (req , None )
439+ async with ObservableRequestHandler (KeyValueOperationType .Upsert , instruments ) as obs_handler :
422440 req = self ._impl .request_builder .build_upsert_request (key , value , obs_handler , * opts , ** kwargs )
423441 return await self ._impl .upsert (req , obs_handler )
424442
@@ -474,8 +492,11 @@ async def replace(self,
474492 res = await collection.replace(key, doc, InsertOptions(durability=durability))
475493
476494 """
477- op_type = KeyValueOperationType .Replace
478- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
495+ instruments = self ._impl .observability_instruments
496+ if instruments .is_noop :
497+ req = self ._impl .request_builder .build_replace_request (key , value , None , * opts , ** kwargs )
498+ return await self ._impl .replace (req , None )
499+ async with ObservableRequestHandler (KeyValueOperationType .Replace , instruments ) as obs_handler :
479500 req = self ._impl .request_builder .build_replace_request (key , value , obs_handler , * opts , ** kwargs )
480501 return await self ._impl .replace (req , obs_handler )
481502
@@ -521,8 +542,11 @@ async def remove(self,
521542 res = collection.remove('airline_10', RemoveOptions(durability=durability))
522543
523544 """
524- op_type = KeyValueOperationType .Remove
525- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
545+ instruments = self ._impl .observability_instruments
546+ if instruments .is_noop :
547+ req = self ._impl .request_builder .build_remove_request (key , None , * opts , ** kwargs )
548+ return await self ._impl .remove (req , None )
549+ async with ObservableRequestHandler (KeyValueOperationType .Remove , instruments ) as obs_handler :
526550 req = self ._impl .request_builder .build_remove_request (key , obs_handler , * opts , ** kwargs )
527551 return await self ._impl .remove (req , obs_handler )
528552
@@ -576,8 +600,11 @@ async def touch(self,
576600 TouchOptions(timeout=timedelta(seconds=2)))
577601
578602 """
579- op_type = KeyValueOperationType .Touch
580- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
603+ instruments = self ._impl .observability_instruments
604+ if instruments .is_noop :
605+ req = self ._impl .request_builder .build_touch_request (key , expiry , None , * opts , ** kwargs )
606+ return await self ._impl .touch (req , None )
607+ async with ObservableRequestHandler (KeyValueOperationType .Touch , instruments ) as obs_handler :
581608 req = self ._impl .request_builder .build_touch_request (key , expiry , obs_handler , * opts , ** kwargs )
582609 return await self ._impl .touch (req , obs_handler )
583610
@@ -634,8 +661,11 @@ async def get_and_touch(self,
634661 print(f'Document w/ updated expiry: {res.content_as[dict]}')
635662
636663 """
637- op_type = KeyValueOperationType .GetAndTouch
638- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
664+ instruments = self ._impl .observability_instruments
665+ if instruments .is_noop :
666+ req = self ._impl .request_builder .build_get_and_touch_request (key , expiry , None , * opts , ** kwargs )
667+ return await self ._impl .get_and_touch (req , None )
668+ async with ObservableRequestHandler (KeyValueOperationType .GetAndTouch , instruments ) as obs_handler :
639669 req = self ._impl .request_builder .build_get_and_touch_request (key , expiry , obs_handler , * opts , ** kwargs )
640670 return await self ._impl .get_and_touch (req , obs_handler )
641671
@@ -692,8 +722,11 @@ async def get_and_lock(self,
692722 print(f'Locked document: {res.content_as[dict]}')
693723
694724 """
695- op_type = KeyValueOperationType .GetAndLock
696- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
725+ instruments = self ._impl .observability_instruments
726+ if instruments .is_noop :
727+ req = self ._impl .request_builder .build_get_and_lock_request (key , lock_time , None , * opts , ** kwargs )
728+ return await self ._impl .get_and_lock (req , None )
729+ async with ObservableRequestHandler (KeyValueOperationType .GetAndLock , instruments ) as obs_handler :
697730 req = self ._impl .request_builder .build_get_and_lock_request (key , lock_time , obs_handler , * opts , ** kwargs )
698731 return await self ._impl .get_and_lock (req , obs_handler )
699732
@@ -739,8 +772,11 @@ async def unlock(self,
739772 await collection.upsert(key, res.content_as[dict])
740773
741774 """
742- op_type = KeyValueOperationType .Unlock
743- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
775+ instruments = self ._impl .observability_instruments
776+ if instruments .is_noop :
777+ req = self ._impl .request_builder .build_unlock_request (key , cas , None , * opts , ** kwargs )
778+ return await self ._impl .unlock (req , None )
779+ async with ObservableRequestHandler (KeyValueOperationType .Unlock , instruments ) as obs_handler :
744780 req = self ._impl .request_builder .build_unlock_request (key , cas , obs_handler , * opts , ** kwargs )
745781 await self ._impl .unlock (req , obs_handler )
746782
@@ -801,8 +837,11 @@ async def lookup_in(self,
801837 print(f'Hotel {key} coordinates: {res.content_as[dict](0)}')
802838
803839 """
804- op_type = KeyValueOperationType .LookupIn
805- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
840+ instruments = self ._impl .observability_instruments
841+ if instruments .is_noop :
842+ req = self ._impl .request_builder .build_lookup_in_request (key , spec , None , * opts , ** kwargs )
843+ return await self ._impl .lookup_in (req , None )
844+ async with ObservableRequestHandler (KeyValueOperationType .LookupIn , instruments ) as obs_handler :
806845 req = self ._impl .request_builder .build_lookup_in_request (key , spec , obs_handler , * opts , ** kwargs )
807846 return await self ._impl .lookup_in (req , obs_handler )
808847
@@ -865,8 +904,12 @@ async def lookup_in_any_replica(self,
865904 print(f'Hotel {key} coordinates: {res.content_as[dict](0)}')
866905
867906 """
868- op_type = KeyValueOperationType .LookupInAnyReplica
869- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
907+ instruments = self ._impl .observability_instruments
908+ if instruments .is_noop :
909+ req = self ._impl .request_builder .build_lookup_in_any_replica_request (
910+ key , spec , None , * opts , ** kwargs )
911+ return await self ._impl .lookup_in_any_replica (req , None )
912+ async with ObservableRequestHandler (KeyValueOperationType .LookupInAnyReplica , instruments ) as obs_handler :
870913 req = self ._impl .request_builder .build_lookup_in_any_replica_request (
871914 key , spec , obs_handler , * opts , ** kwargs )
872915 return await self ._impl .lookup_in_any_replica (req , obs_handler )
@@ -953,8 +996,12 @@ async def lookup_in_all_replicas(self,
953996 break
954997
955998 """ # noqa: E501
956- op_type = KeyValueOperationType .LookupInAllReplicas
957- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
999+ instruments = self ._impl .observability_instruments
1000+ if instruments .is_noop :
1001+ req = self ._impl .request_builder .build_lookup_in_all_replicas_request (
1002+ key , spec , None , * opts , ** kwargs )
1003+ return await self ._impl .lookup_in_all_replicas (req , None )
1004+ async with ObservableRequestHandler (KeyValueOperationType .LookupInAllReplicas , instruments ) as obs_handler :
9581005 req = self ._impl .request_builder .build_lookup_in_all_replicas_request (
9591006 key , spec , obs_handler , * opts , ** kwargs )
9601007 return await self ._impl .lookup_in_all_replicas (req , obs_handler )
@@ -1014,8 +1061,11 @@ async def mutate_in(self,
10141061 MutateInOptions(timeout=timedelta(seconds=2)))
10151062
10161063 """
1017- op_type = KeyValueOperationType .MutateIn
1018- async with ObservableRequestHandler (op_type , self ._impl .observability_instruments ) as obs_handler :
1064+ instruments = self ._impl .observability_instruments
1065+ if instruments .is_noop :
1066+ req = self ._impl .request_builder .build_mutate_in_request (key , spec , None , * opts , ** kwargs )
1067+ return await self ._impl .mutate_in (req , None )
1068+ async with ObservableRequestHandler (KeyValueOperationType .MutateIn , instruments ) as obs_handler :
10191069 req = self ._impl .request_builder .build_mutate_in_request (key , spec , obs_handler , * opts , ** kwargs )
10201070 return await self ._impl .mutate_in (req , obs_handler )
10211071
0 commit comments