Skip to content

Adding Activity.name to AppOnTurn span - #516

Merged
Rodrigo Brandão (rodrigobr-msft) merged 4 commits into
mainfrom
users/robrandao/app-spans
Aug 3, 2026
Merged

Adding Activity.name to AppOnTurn span#516
Rodrigo Brandão (rodrigobr-msft) merged 4 commits into
mainfrom
users/robrandao/app-spans

Conversation

@rodrigobr-msft

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings August 3, 2026 18:42
@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) marked this pull request as ready for review August 3, 2026 18:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 the AppOnTurn span attributes.
  • Extend tests/hosting_core/telemetry/test_app_spans.py to validate the new span attribute and its default-to-unknown behavior.
  • Update several activity-layer tests to use an Unset sentinel 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 passes from_property=self.user (which can be None), so the resulting activity’s from_property will be None rather than an undefined Unset sentinel. 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() uses SkipNone(...) which omits fields when the inputs are None, and the Activity model defaults those fields to None. The test currently expects an Unset sentinel 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 with attachments/entities defaulting to None (per the Activity model). Expecting Unset here 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(...) omits value/label when they’re None, and the model defaults those attributes to None. Comparing to Unset will 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() leaves locale, from_property, and recipient as None when the corresponding values are absent (fields are omitted via SkipNone and default to None). The test currently expects an Unset sentinel. Also, the locale assertion should be parenthesized to avoid Python’s ==/or precedence 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 set value_type when it’s omitted, so value_type remains the model default (None). Expecting an Unset sentinel 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.

Comment thread tests/activity/test_conversation_reference.py
Comment thread tests/activity/test_activity.py
Comment thread tests/activity/test_activity_builders.py
Copilot AI review requested due to automatic review settings August 3, 2026 18:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

Copilot AI review requested due to automatic review settings August 3, 2026 18:59
Copilot AI previously approved these changes Aug 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

Copilot AI review requested due to automatic review settings August 3, 2026 20:59
Copilot AI dismissed their stale review, a newer Copilot review was requested August 3, 2026 21:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.

@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) merged commit c897f49 into main Aug 3, 2026
10 checks passed
@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) deleted the users/robrandao/app-spans branch August 3, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Activity.name attribute to AgentApplication spans

3 participants