Repository: microsoft/botbuilder-python

Issue:
PORT: The SDK is over-verbose in generating TraceActivity records and it can't be turned off.
Remove extra trace activities: 
https://github.com/microsoft/botbuilder-dotnet/pull/4819

(keeping only the state tarces)


Discussion:

Resolving patch:
diff --git a/libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_extensions.py b/libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_extensions.py
--- a/libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_extensions.py
+++ b/libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_extensions.py
@@ -40,11 +40,6 @@ async def run_dialog(
                     # No dialogs to cancel, just return.
                     return
 
-                remote_cancel_text = "Skill was canceled through an EndOfConversation activity from the parent."
-                await turn_context.send_trace_activity(
-                    f"Extension {Dialog.__name__}.run_dialog", label=remote_cancel_text,
-                )
-
                 # Send cancellation message to the dialog to ensure all the parents are canceled
                 # in the right order.
                 await dialog_context.cancel_all_dialogs()
@@ -73,15 +68,6 @@ async def run_dialog(
             or result.status == DialogTurnStatus.Cancelled
         ):
             if DialogExtensions.__send_eoc_to_parent(turn_context):
-                end_message_text = (
-                    f"Dialog {dialog.id} has **completed**. Sending EndOfConversation."
-                )
-                await turn_context.send_trace_activity(
-                    f"Extension {Dialog.__name__}.run_dialog",
-                    label=end_message_text,
-                    value=result.result,
-                )
-
                 activity = Activity(
                     type=ActivityTypes.end_of_conversation,
                     value=result.result,
diff --git a/libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_manager.py b/libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_manager.py
--- a/libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_manager.py
+++ b/libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_manager.py
@@ -306,12 +306,6 @@ async def handle_skill_on_turn(
             # Handle remote cancellation request from parent.
             active_dialog_context = self.get_active_dialog_context(dialog_context)
 
-            remote_cancel_text = "Skill was canceled through an EndOfConversation activity from the parent."
-            await turn_context.send_trace_activity(
-                f"{self.__class__.__name__}.on_turn_async()",
-                label=f"{remote_cancel_text}",
-            )
-
             # Send cancellation message to the top dialog in the stack to ensure all the parents are canceled in the
             # right order.
             return await active_dialog_context.cancel_all_dialogs(True)
@@ -333,23 +327,11 @@ async def handle_skill_on_turn(
         turn_result = await dialog_context.continue_dialog()
         if turn_result.status == DialogTurnStatus.Empty:
             # restart root dialog
-            start_message_text = f"Starting {self._root_dialog_id}."
-            await turn_context.send_trace_activity(
-                f"{self.__class__.__name__}.handle_skill_on_turn_async()",
-                label=f"{start_message_text}",
-            )
             turn_result = await dialog_context.begin_dialog(self._root_dialog_id)
 
         await DialogManager.send_state_snapshot_trace(dialog_context, "Skill State")
 
         if self.should_send_end_of_conversation_to_parent(turn_context, turn_result):
-            end_message_text = f"Dialog {self._root_dialog_id} has **completed**. Sending EndOfConversation."
-            await turn_context.send_trace_activity(
-                f"{self.__class__.__name__}.handle_skill_on_turn_async()",
-                label=f"{end_message_text}",
-                value=turn_result.result,
-            )
-
             # Send End of conversation at the end.
             activity = Activity(
                 type=ActivityTypes.end_of_conversation,
diff --git a/libraries/botbuilder-dialogs/botbuilder/dialogs/skills/skill_dialog.py b/libraries/botbuilder-dialogs/botbuilder/dialogs/skills/skill_dialog.py
--- a/libraries/botbuilder-dialogs/botbuilder/dialogs/skills/skill_dialog.py
+++ b/libraries/botbuilder-dialogs/botbuilder/dialogs/skills/skill_dialog.py
@@ -49,11 +49,6 @@ async def begin_dialog(self, dialog_context: DialogContext, options: object = No
         """
         dialog_args = self._validate_begin_dialog_args(options)
 
-        await dialog_context.context.send_trace_activity(
-            f"{SkillDialog.__name__}.BeginDialogAsync()",
-            label=f"Using activity of type: {dialog_args.activity.type}",
-        )
-
         # Create deep clone of the original activity to avoid altering it before forwarding it.
         skill_activity: Activity = deepcopy(dialog_args.activity)
 
@@ -90,19 +85,9 @@ async def continue_dialog(self, dialog_context: DialogContext):
         if not self._on_validate_activity(dialog_context.context.activity):
             return self.end_of_turn
 
-        await dialog_context.context.send_trace_activity(
-            f"{SkillDialog.__name__}.continue_dialog()",
-            label=f"ActivityType: {dialog_context.context.activity.type}",
-        )
-
         # Handle EndOfConversation from the skill (this will be sent to the this dialog by the SkillHandler if
         # received from the Skill)
         if dialog_context.context.activity.type == ActivityTypes.end_of_conversation:
-            await dialog_context.context.send_trace_activity(
-                f"{SkillDialog.__name__}.continue_dialog()",
-                label=f"Got {ActivityTypes.end_of_conversation}",
-            )
-
             return await dialog_context.end_dialog(
                 dialog_context.context.activity.value
             )
@@ -156,10 +141,6 @@ async def end_dialog(
     ):
         # Send of of conversation to the skill if the dialog has been cancelled.
         if reason in (DialogReason.CancelCalled, DialogReason.ReplaceCalled):
-            await context.send_trace_activity(
-                f"{SkillDialog.__name__}.end_dialog()",
-                label=f"ActivityType: {context.activity.type}",
-            )
             activity = Activity(type=ActivityTypes.end_of_conversation)
 
             # Apply conversation reference and common properties from incoming activity before sending.


Test patch:
diff --git a/libraries/botbuilder-dialogs/tests/test_dialog_manager.py b/libraries/botbuilder-dialogs/tests/test_dialog_manager.py
--- a/libraries/botbuilder-dialogs/tests/test_dialog_manager.py
+++ b/libraries/botbuilder-dialogs/tests/test_dialog_manager.py
@@ -300,35 +300,6 @@ async def test_skill_should_return_empty_on_reprompt_with_no_dialog(self):
             DialogTurnStatus.Empty,
         )
 
-    async def test_trace_skill_state(self):
-        SimpleComponentDialog.dm_turn_result = None
-        dialog = SimpleComponentDialog()
-
-        def assert_is_trace(activity, description):  # pylint: disable=unused-argument
-            assert activity.type == ActivityTypes.trace
-
-        def assert_is_trace_and_label(activity, description):
-            assert_is_trace(activity, description)
-            assert activity.label == "Skill State"
-
-        test_flow = await SimpleComponentDialog.create_test_flow(
-            dialog, SkillFlowTestCase.leaf_skill, True
-        )
-
-        step1 = await test_flow.send("Hi")
-        step2 = await step1.assert_reply(assert_is_trace)
-        step2 = await step2.assert_reply("Hello, what is your name?")
-        step3 = await step2.assert_reply(assert_is_trace_and_label)
-        step4 = await step3.send("SomeName")
-        step5 = await step4.assert_reply("Hello SomeName, nice to meet you!")
-        step6 = await step5.assert_reply(assert_is_trace_and_label)
-        await step6.assert_reply(assert_is_trace)
-
-        self.assertEqual(
-            SimpleComponentDialog.dm_turn_result.turn_result.status,
-            DialogTurnStatus.Complete,
-        )
-
     async def test_trace_bot_state(self):
         SimpleComponentDialog.dm_turn_result = None
         dialog = SimpleComponentDialog()