8000 Reduce trace activity in dialogs (#1488) · nickg33/botbuilder-python@1fe7513 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1fe7513

Browse files
Reduce trace activity in dialogs (microsoft#1488)
* Reduce trace activity in dialogs * Removed trace activity test case Co-authored-by: Axel Suárez <axsuarez@microsoft.com>
1 parent 8b02292 commit 1fe7513

File tree

4 files changed

+0
-80
lines changed

4 files changed

+0
-80
lines changed

libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_extensions.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ async def run_dialog(
4040
# No dialogs to cancel, just return.
4141
return
4242

43-
remote_cancel_text = "Skill was canceled through an EndOfConversation activity from the parent."
44-
await turn_context.send_trace_activity(
45-
f"Extension {Dialog.__name__}.run_dialog", label=remote_cancel_text,
46-
)
47-
4843
# Send cancellation message to the dialog to ensure all the parents are canceled
4944
# in the right order.
5045
await dialog_context.cancel_all_dialogs()
@@ -73,15 +68,6 @@ async def run_dialog(
7368
or result.status == DialogTurnStatus.Cancelled
7469
):
7570
if DialogExtensions.__send_eoc_to_parent(turn_context):
76-
end_message_text = (
77-
f"Dialog {dialog.id} has **completed**. Sending EndOfConversation."
78-
)
79-
await turn_context.send_trace_activity(
80-
f"Extension {Dialog.__name__}.run_dialog",
81-
label=end_message_text,
82-
value=result.result,
83-
)
84-
8571
activity = Activity(
8672
type=ActivityTypes.end_of_conversation,
8773
value=result.result,

libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_manager.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,6 @@ async def handle_skill_on_turn(
306306
# Handle remote cancellation request from parent.
307307
active_dialog_context = self.get_active_dialog_context(dialog_context)
308308

309-
remote_cancel_text = "Skill was canceled through an EndOfConversation activity from the parent."
310-
await turn_context.send_trace_activity(
311-
f"{self.__class__.__name__}.on_turn_async()",
312-
label=f"{remote_cancel_text}",
313-
)
314-
315309
# Send cancellation message to the top dialog in the stack to ensure all the parents are canceled in the
316310
# right order.
317311
return await active_dialog_context.cancel_all_dialogs(True)
@@ -333,23 +327,11 @@ async def handle_skill_on_turn(
333327
turn_result = await dialog_context.continue_dialog()
334328
if turn_result.status == DialogTurnStatus.Empty:
335329
# restart root dialog
336-
start_message_text = f"Starting {self._root_dialog_id}."
337-
await turn_context.send_trace_activity(
338-
f"{self.__class__.__name__}.handle_skill_on_turn_async()",
339-
label=f"{start_message_text}",
340-
)
341330
turn_result = await dialog_context.begin_dialog(self._root_dialog_id)
342331

343332
await DialogManager.send_state_snapshot_trace(dialog_context, "Skill State")
344333

345334
if self.should_send_end_of_conversation_to_parent(turn_context, turn_result):
346-
end_message_text = f"Dialog {self._root_dialog_id} has **completed**. Sending EndOfConversation."
347-
await turn_context.send_trace_activity(
348-
f"{self.__class__.__name__}.handle_skill_on_turn_async()",
349-
label=f"{end_message_text}",
350-
value=turn_result.result,
351-
)
352-
353335
# Send End of conversation at the end.
354336
activity = Activity(
355337
type=ActivityTypes.end_of_conversation,

libraries/botbuilder-dialogs/botbuilder/dialogs/skills/skill_dialog.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ async def begin_dialog(self, dialog_context: DialogContext, options: object = No
4949
"""
5050
dialog_args = self._validate_begin_dialog_args(options)
5151

52-
await dialog_context.context.send_trace_activity(
53-
f"{SkillDialog.__name__}.BeginDialogAsync()",
54-
label=f"Using activity of type: {dialog_args.activity.type}",
55-
)
56-
5752
# Create deep clone of the original activity to avoid altering it before forwarding it.
5853
skill_activity: Activity = deepcopy(dialog_args.activity)
5954

@@ -90,19 +85,9 @@ async def continue_dialog(self, dialog_context: DialogContext):
9085
if not self._on_validate_activity(dialog_context.context.activity):
9186
return self.end_of_turn
9287

93-
await dialog_context.context.send_trace_activity(
94-
f"{SkillDialog.__name__}.continue_dialog()",
95-
label=f"ActivityType: {dialog_context.context.activity.type}",
96-
)
97-
9888
# Handle EndOfConversation from the skill (this will be sent to the this dialog by the SkillHandler if
9989
# received from the Skill)
10090
if dialog_context.context.activity.type == ActivityTypes.end_of_conversation:
101-
await dialog_context.context.send_trace_activity(
102-
f"{SkillDialog.__name__}.continue_dialog()",
103-
label=f"Got {ActivityTypes.end_of_conversation}",
104-
)
105-
10691
return await dialog_context.end_dialog(
10792
dialog_context.context.activity.value
10893
)
@@ -156,10 +141,6 @@ async def end_dialog(
156141
):
157142
# Send of of conversation to the skill if the dialog has been cancelled.
158143
if reason in (DialogReason.CancelCalled, DialogReason.ReplaceCalled):
159-
await context.send_trace_activity(
160-
f"{SkillDialog.__name__}.end_dialog()",
161-
label=f"ActivityType: {context.activity.type}",
162-
)
163144
activity = Activity(type=ActivityTypes.end_of_conversation)
164145

165146
# Apply conversation reference and common properties from incoming activity before sending.

libraries/botbuilder-dialogs/tests/test_dialog_manager.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -300,35 +300,6 @@ async def test_skill_should_return_empty_on_reprompt_with_no_dialog(self):
300300
DialogTurnStatus.Empty,
301301
)
302302

303-
async def test_trace_skill_state(self):
304-
SimpleComponentDialog.dm_turn_result = None
305-
dialog = SimpleComponentDialog()
306-
307-
def assert_is_trace(activity, description): # pylint: disable=unused-argument
308-
assert activity.type == ActivityTypes.trace
309-
310-
def assert_is_trace_and_label(activity, description):
311-
assert_is_trace(activity, description)
312-
assert activity.label == "Skill State"
313-
314-
test_flow = await SimpleComponentDialog.create_test_flow(
315-
dialog, SkillFlowTestCase.leaf_skill, True
316-
)
317-
318-
step1 = await test_flow.send("Hi")
319-
step2 = await step1.assert_reply(assert_is_trace)
320-
step2 = await step2.assert_reply("Hello, what is your name?")
321-
step3 = await step2.assert_reply(assert_is_trace_and_label)
322-
step4 = await step3.send("SomeName")
323-
step5 = await step4.assert_reply("Hello SomeName, nice to meet you!")
324-
step6 = await step5.assert_reply(assert_is_trace_and_label)
325-
await step6.assert_reply(assert_is_trace)
326-
327-
self.assertEqual(
328-
SimpleComponentDialog.dm_turn_result.turn_result.status,
329-
DialogTurnStatus.Complete,
330-
)
331-
332303
async def test_trace_bot_state(self):
333304
SimpleComponentDialog.dm_turn_result = None
334305
dialog = SimpleComponentDialog()

0 commit comments

Comments
 (0)
0