Adding Activity.name to AppOnTurn span - #516
Conversation
There was a problem hiding this comment.
🟡 Not ready to approve
Multiple updated tests import/expect an Unset sentinel that is not defined/exported by microsoft_agents.activity, and the current models still default these fields to None, so the test suite will fail.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR extends the hosting-core telemetry for AppOnTurn spans to include the incoming Activity.name as a span attribute, improving trace correlation for invoke/event-style activities.
Changes:
- Add
activity.name(attributes.ACTIVITY_NAME) to theAppOnTurnspan attributes. - Extend
tests/hosting_core/telemetry/test_app_spans.pyto validate the new span attribute and its default-to-unknownbehavior. - Update several activity-layer tests to use an
Unsetsentinel for missing values.
File summaries
| File | Description |
|---|---|
| tests/hosting_core/telemetry/test_app_spans.py | Adds assertions verifying ACTIVITY_NAME is emitted on the AppOnTurn span. |
| tests/activity/test_conversation_reference.py | Changes continuation-activity behavior expectations when user is missing (currently uses Unset). |
| tests/activity/test_activity.py | Updates multiple assertions to expect Unset for missing optional Activity fields. |
| tests/activity/test_activity_builders.py | Updates fluent builder tests to expect Unset when value_type is omitted. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/telemetry/attributes.py | Defines new telemetry key constant ACTIVITY_NAME. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/telemetry/spans.py | Adds Activity.name to the AppOnTurn span attribute map. |
Review details
Suppressed comments (6)
tests/activity/test_conversation_reference.py:60
ConversationReference.get_continuation_activity()currently passesfrom_property=self.user(which can beNone), so the resulting activity’sfrom_propertywill beNonerather than an undefinedUnsetsentinel. This assertion will fail even if the import issue is fixed.
def test_get_continuation_activity_uses_unset_when_user_is_missing():
conversation_reference = _create_conversation_reference(user=None)
conversation_reference.user = None
continuation_activity = conversation_reference.get_continuation_activity()
assert continuation_activity.from_property is Unset
tests/activity/test_activity.py:255
Activity.create_trace()usesSkipNone(...)which omits fields when the inputs areNone, and the Activity model defaults those fields toNone. The test currently expects anUnsetsentinel that doesn’t exist in the activity models, so these assertions will fail.
if value_type:
assert trace.value_type == value_type
elif value:
assert trace.value_type == type(value).__name__
else:
assert trace.value_type is Unset
assert trace.label == (label if label is not None else Unset)
assert trace.name == "test"
tests/activity/test_activity.py:282
Activity.create_message_activity()returns an Activity withattachments/entitiesdefaulting toNone(per the Activity model). ExpectingUnsethere will fail.
if expected_activity_type == ActivityTypes.message:
assert activity.attachments is Unset
assert activity.entities is Unset
tests/activity/test_activity.py:297
Activity.create_trace_activity(...)omitsvalue/labelwhen they’reNone, and the model defaults those attributes toNone. Comparing toUnsetwill fail.
assert activity.value_type == type(value).__name__
assert activity.value == (value if value is not None else Unset)
assert activity.label == (label if label is not None else Unset)
tests/activity/test_activity.py:331
create_reply()leaveslocale,from_property, andrecipientasNonewhen the corresponding values are absent (fields are omitted viaSkipNoneand default toNone). The test currently expects anUnsetsentinel. Also, the locale assertion should be parenthesized to avoid Python’s==/orprecedence pitfalls.
assert reply.locale == (create_reply_locale or activity_locale or Unset)
if create_recipient:
assert reply.from_property.id == "ChannelAccount_Id_2"
assert reply.from_property.name == "ChannelAccount_Name_2"
else:
assert reply.from_property is Unset
if create_from:
assert reply.recipient.id == "ChannelAccount_Id_1"
assert reply.recipient.name == "ChannelAccount_Name_1"
else:
assert reply.recipient is Unset
tests/activity/test_activity_builders.py:55
Activity.with_value("theValue")does not setvalue_typewhen it’s omitted, sovalue_typeremains the model default (None). Expecting anUnsetsentinel will fail.
def test_with_value_without_value_type(self):
activity = Activity.create_message_activity().with_value("theValue")
assert activity.value == "theValue"
assert activity.value_type is Unset
- Files reviewed: 6/6 changed files
- Comments generated: 3
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
There was a problem hiding this comment.
🟢 Ready to approve
The change is small, self-contained, and includes test updates that cover both present and missing activity.name cases.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
There was a problem hiding this comment.
🟢 Ready to approve
The change is small, consistent with existing span attribute patterns, and is covered by updated unit tests validating both present and missing activity.name cases.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
There was a problem hiding this comment.
🟢 Ready to approve
The change is small, consistent with existing telemetry patterns (including UNKNOWN fallbacks), and is covered by updated unit tests.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
No description provided.