Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
([#269](https://github.com/microsoft/opentelemetry-distro-python/pull/269))

### Bugs Fixed
- Handle activities without a recipient when extracting Agent365 tenant baggage.
Comment thread
rads-1996 marked this conversation as resolved.
- Restore MOT version propagation after OneSettings initialization order caused the exporter version to take precedence over the Microsoft OpenTelemetry distro version
([#275](https://github.com/microsoft/opentelemetry-distro-python/pull/275))
- Restrict A365 identity and baggage enrichment to recognized GenAI spans while preserving supported span-start signals. ([#265](https://github.com/microsoft/opentelemetry-distro-python/pull/265))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ def get_target_agent_pairs(activity: Activity) -> Iterator[tuple[str, Any]]:


def get_tenant_id_pair(activity: Activity) -> Iterator[tuple[str, Any]]:
yield TENANT_ID_KEY, activity.recipient.tenant_id
rec = activity.recipient
if not rec:
return
yield TENANT_ID_KEY, rec.tenant_id


def get_channel_pairs(activity: Activity) -> Iterator[tuple[str, Any]]:
Expand Down
15 changes: 14 additions & 1 deletion tests/a365/hosting/scope_helpers/test_populate_baggage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from microsoft_agents.activity import Activity, ChannelAccount, ConversationAccount
from microsoft_agents.hosting.core import TurnContext
from microsoft.opentelemetry.a365.core.constants import USER_ID_KEY
from microsoft.opentelemetry.a365.core.constants import TENANT_ID_KEY, USER_ID_KEY
from microsoft.opentelemetry.a365.core.middleware.baggage_builder import BaggageBuilder
from microsoft.opentelemetry.a365.hosting.scope_helpers.populate_baggage import populate

Expand Down Expand Up @@ -45,3 +45,16 @@ def test_populate():
# Verify specific expected baggage keys were set
assert USER_ID_KEY in builder._pairs
assert builder._pairs[USER_ID_KEY] == "caller-id"


def test_populate_without_recipient():
activity = Activity(
type="message",
from_property=ChannelAccount(aad_object_id="caller-id"),
)
turn_context = TurnContext(MagicMock(), activity)
builder = BaggageBuilder()

assert populate(builder, turn_context) is builder
assert builder._pairs[USER_ID_KEY] == "caller-id"
assert TENANT_ID_KEY not in builder._pairs
12 changes: 12 additions & 0 deletions tests/a365/hosting/scope_helpers/test_scope_helper_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ def test_get_tenant_id_pair():
assert (TENANT_ID_KEY, "test-tenant-id") in result


def test_get_tenant_id_pair_without_recipient():
activity = Activity(type="message")

assert not list(get_tenant_id_pair(activity))


def test_get_tenant_id_pair_without_tenant_id():
activity = Activity(type="message", recipient=ChannelAccount())

assert list(get_tenant_id_pair(activity)) == [(TENANT_ID_KEY, None)]


def test_get_channel_pairs():
"""Test get_channel_pairs extracts channel metadata."""
activity = Activity(type="message", channel_id="test-channel")
Expand Down
6 changes: 3 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading