@@ -159,13 +159,11 @@ def path(self):
159
159
160
160
161
161
class Transaction (object ):
162
-
163
162
STATE_PENDING = 0
164
163
STATE_RUNNING = 1
165
164
STATE_STOPPED = 2
166
165
167
166
def __init__ (self , application , enabled = None , source = None ):
168
-
169
167
self ._application = application
170
168
171
169
self ._source = source
@@ -343,7 +341,6 @@ def __del__(self):
343
341
self .__exit__ (None , None , None )
344
342
345
343
def __enter__ (self ):
346
-
347
344
assert self ._state == self .STATE_PENDING
348
345
349
346
# Bail out if the transaction is not enabled.
@@ -403,7 +400,6 @@ def __enter__(self):
403
400
return self
404
401
405
402
def __exit__ (self , exc , value , tb ):
406
-
407
403
# Bail out if the transaction is not enabled.
408
404
409
405
if not self .enabled :
@@ -636,7 +632,6 @@ def __exit__(self, exc, value, tb):
636
632
# new samples can cause an error.
637
633
638
634
if not self .ignore_transaction :
639
-
640
635
self ._application .record_transaction (node )
641
636
642
637
@property
@@ -929,9 +924,7 @@ def filter_request_parameters(self, params):
929
924
@property
930
925
def request_parameters (self ):
931
926
if (self .capture_params is None ) or self .capture_params :
932
-
933
927
if self ._request_params :
934
-
935
928
r_attrs = {}
936
929
937
930
for k , v in self ._request_params .items ():
@@ -1095,7 +1088,6 @@ def _generate_distributed_trace_headers(self, data=None):
1095
1088
try :
1096
1089
data = data or self ._create_distributed_trace_data ()
1097
1090
if data :
1098
-
1099
1091
traceparent = W3CTraceParent (data ).text ()
1100
1092
yield ("traceparent" , traceparent )
1101
1093
@@ -1192,11 +1184,10 @@ def _accept_distributed_trace_payload(self, payload, transport_type="HTTP"):
1192
1184
except :
1193
1185
return False
1194
1186
1195
- if "pr" in data :
1196
- try :
1197
- data ["pr" ] = float (data ["pr" ])
1198
- except :
1199
- data ["pr" ] = None
1187
+ try :
1188
+ data ["pr" ] = float (data ["pr" ])
1189
+ except Exception :
1190
+ data ["pr" ] = None
1200
1191
1201
1192
self ._accept_distributed_trace_data (data , transport_type )
1202
1193
self ._record_supportability ("Supportability/DistributedTrace/AcceptPayload/Success" )
@@ -1382,7 +1373,6 @@ def _generate_response_headers(self, read_length=None):
1382
1373
# process web external calls.
1383
1374
1384
1375
if self .client_cross_process_id is not None :
1385
-
1386
1376
# Need to work out queueing time and duration up to this
1387
1377
# point for inclusion in metrics and response header. If the
1388
1378
# recording of the transaction had been prematurely stopped
@@ -1426,11 +1416,17 @@ def _generate_response_headers(self, read_length=None):
1426
1416
1427
1417
return nr_headers
1428
1418
1429
- def get_response_metadata (self ):
1419
+ # This function is CAT related and has been deprecated.
1420
+ # Eventually, this will be removed. Until then, coverage
1421
+ # does not need to factor this function into its analysis.
1422
+ def get_response_metadata (self ): # pragma: no cover
1430
1423
nr_headers = dict (self ._generate_response_headers ())
1431
1424
return convert_to_cat_metadata_value (nr_headers )
1432
1425
1433
- def process_request_metadata (self , cat_linking_value ):
1426
+ # This function is CAT related and has been deprecated.
1427
+ # Eventually, this will be removed. Until then, coverage
1428
+ # does not need to factor this function into its analysis.
1429
+ def process_request_metadata (self , cat_linking_value ): # pragma: no cover
1434
1430
try :
1435
1431
payload = base64_decode (cat_linking_value )
1436
1432
except :
@@ -1447,7 +1443,6 @@ def process_request_metadata(self, cat_linking_value):
1447
1443
return self ._process_incoming_cat_headers (encoded_cross_process_id , encoded_txn_header )
1448
1444
1449
1445
def set_transaction_name (self , name , group = None , priority = None ):
1450
-
1451
1446
# Always perform this operation even if the transaction
1452
1447
# is not active at the time as will be called from
1453
1448
# constructor. If path has been frozen do not allow
@@ -1517,7 +1512,9 @@ def record_log_event(self, message, level=None, timestamp=None, priority=None):
1517
1512
1518
1513
self ._log_events .add (event , priority = priority )
1519
1514
1520
- def record_exception (self , exc = None , value = None , tb = None , params = None , ignore_errors = None ):
1515
+ # This function has been deprecated (and will be removed eventually)
1516
+ # and therefore does not need to be included in coverage analysis
1517
+ def record_exception (self , exc = None , value = None , tb = None , params = None , ignore_errors = None ): # pragma: no cover
1521
1518
# Deprecation Warning
1522
1519
warnings .warn (
1523
1520
("The record_exception function is deprecated. Please use the new api named notice_error instead." ),
@@ -1684,15 +1681,19 @@ def add_custom_attributes(self, items):
1684
1681
1685
1682
return result
1686
1683
1687
- def add_custom_parameter (self , name , value ):
1684
+ # This function has been deprecated (and will be removed eventually)
1685
+ # and therefore does not need to be included in coverage analysis
1686
+ def add_custom_parameter (self , name , value ): # pragma: no cover
1688
1687
# Deprecation warning
1689
1688
warnings .warn (
1690
1689
("The add_custom_parameter API has been deprecated. " "Please use the add_custom_attribute API." ),
1691
1690
DeprecationWarning ,
1692
1691
)
1693
1692
return self .add_custom_attribute (name , value )
1694
1693
1695
- def add_custom_parameters (self , items ):
1694
+ # This function has been deprecated (and will be removed eventually)
1695
+ # and therefore does not need to be included in coverage analysis
1696
+ def add_custom_parameters (self , items ): # pragma: no cover
1696
1697
# Deprecation warning
1697
1698
warnings .warn (
1698
1699
("The add_custom_parameters API has been deprecated. " "Please use the add_custom_attributes API." ),
@@ -1796,19 +1797,23 @@ def add_custom_attributes(items):
1796
1797
return False
1797
1798
1798
1799
1799
- def add_custom_parameter (key , value ):
1800
+ # This function has been deprecated (and will be removed eventually)
1801
+ # and therefore does not need to be included in coverage analysis
1802
+ def add_custom_parameter (key , value ): # pragma: no cover
1800
1803
# Deprecation warning
1801
1804
warnings .warn (
1802
- ("The add_custom_parameter API has been deprecated. " " Please use the add_custom_attribute API." ),
1805
+ ("The add_custom_parameter API has been deprecated. Please use the add_custom_attribute API." ),
1803
1806
DeprecationWarning ,
1804
1807
)
1805
1808
return add_custom_attribute (key , value )
1806
1809
1807
1810
1808
- def add_custom_parameters (items ):
1811
+ # This function has been deprecated (and will be removed eventually)
1812
+ # and therefore does not need to be included in coverage analysis
1813
+ def add_custom_parameters (items ): # pragma: no cover
1809
1814
# Deprecation warning
1810
1815
warnings .warn (
1811
- ("The add_custom_parameters API has been deprecated. " " Please use the add_custom_attributes API." ),
1816
+ ("The add_custom_parameters API has been deprecated. Please use the add_custom_attributes API." ),
1812
1817
DeprecationWarning ,
1813
1818
)
1814
1819
return add_custom_attributes (items )
0 commit comments