Commit 5ce0785
Align middleware with Middleware Protocol; consolidate tests (#187)
* Initial plan
* Add BaggageMiddleware, OutputLoggingMiddleware, and ObservabilityHostingManager
Implement Python equivalents of the Node.js PR #210 middleware:
- BaggageMiddleware: propagates OpenTelemetry baggage from TurnContext
- OutputLoggingMiddleware: creates OutputScope spans for outgoing messages
- ObservabilityHostingManager: singleton to configure hosting middleware
- 19 unit tests covering all three middleware components
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
* Update ObservabilityHostingManager.configure to use ChannelAdapter type and require non-None params
- Replace _AdapterLike protocol with actual ChannelAdapter from microsoft_agents.hosting.core
- Make adapter and options required (non-optional) parameters
- Raise TypeError if either is None
- Update tests to match new contract
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
* Use MiddlewareSet type for adapter and Activity helper methods instead of direct attribute access
- Change adapter param type from ChannelAdapter to MiddlewareSet (the actual
middleware registration object)
- Use activity.get_agentic_instance_id() instead of recipient.agentic_app_id
- Use activity.get_agentic_user() instead of recipient.agentic_user_id
- Update test to use agentic role for proper helper method behavior
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
* Fix ObservabilityHostingManager.configure to accept MiddlewareSet instead of ChannelAdapter
ChannelAdapter is an ABC (CloudAdapter extends ChannelServiceAdapter extends
ChannelAdapter). The adapter HAS-A MiddlewareSet (composition) — it is not one.
The configure() method only needs the middleware registration object, so accept
MiddlewareSet directly. Users pass adapter.middleware_set.
Rename parameter from 'adapter' to 'middleware_set' for clarity.
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
* Address review comments: fix logic callback type, gate on is_agentic_request
- Fix `logic` type annotation from `Callable[[TurnContext], Awaitable]` to
`Callable[[], Awaitable]` in both BaggageMiddleware and
OutputLoggingMiddleware. At runtime, MiddlewareSet passes a zero-arg
`call_next_middleware` closure, so the annotation now matches the callsite.
- Gate `_derive_agent_details` on `activity.is_agentic_request()` to avoid
emitting spans with empty agent_id for non-agentic requests.
- Remove unused `logging`/`logger` from baggage_middleware.py.
- Update test recipient role from "assistant" to "agenticAppInstance" to
exercise the intended agentic code path.
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
* Revert logic type to Callable[[TurnContext], Awaitable] to match Middleware Protocol; consolidate tests
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
Co-authored-by: Nikhil Navakiran <nikhil.navakiran@gmail.com>1 parent a4f23f6 commit 5ce0785
File tree
11 files changed
+788
-4
lines changed- libraries/microsoft-agents-a365-observability-hosting/microsoft_agents_a365/observability/hosting
- middleware
- scope_helpers
- tests/observability/hosting
- middleware
- scope_helpers
11 files changed
+788
-4
lines changedLines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 44 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
Lines changed: 101 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
0 commit comments