@@ -729,6 +729,13 @@ def tag(**tags):
729729
730730
731731def set_transaction_name (name , override = True ):
732+ """
733+ Sets the name of the transaction
734+
735+ :param name: the name of the transaction
736+ :param override: if set to False, the name is only set if no name has been set before
737+ :return: None
738+ """
732739 transaction = execution_context .get_transaction ()
733740 if not transaction :
734741 return
@@ -737,13 +744,52 @@ def set_transaction_name(name, override=True):
737744
738745
739746def set_transaction_result (result , override = True ):
747+ """
748+ Sets the result of the transaction. The result could be e.g. the HTTP status class (e.g "HTTP 5xx") for
749+ HTTP requests, or "success"/"fail" for background tasks.
750+
751+ :param name: the name of the transaction
752+ :param override: if set to False, the name is only set if no name has been set before
753+ :return: None
754+ """
755+
740756 transaction = execution_context .get_transaction ()
741757 if not transaction :
742758 return
743759 if transaction .result is None or override :
744760 transaction .result = result
745761
746762
763+ def set_transaction_success ():
764+ """
765+ Marks this transaction as successful. This should only be done at the end of a transaction
766+ when the outcome is determined.
767+
768+ This value is used for error rate calculations.
769+
770+ :return: None
771+ """
772+ transaction = execution_context .get_transaction ()
773+ if not transaction :
774+ return
775+ transaction .set_success ()
776+
777+
778+ def set_transaction_failure ():
779+ """
780+ Marks this transaction as failed. This should only be done at the end of a transaction
781+ when the outcome is determined.
782+
783+ This value is used for error rate calculations.
784+
785+ :return: None
786+ """
787+ transaction = execution_context .get_transaction ()
788+ if not transaction :
789+ return
790+ transaction .set_failure ()
791+
792+
747793def get_transaction_id ():
748794 """
749795 Returns the current transaction ID
0 commit comments