Commit eaa2136
Add OutputScope for output message tracing with parent span linking (#164)
* Initial plan
* Add OutputScope for output message tracing
- Add Response model class for agent execution response details
- Add spans_scopes directory with OutputScope implementation
- Add unit tests for OutputScope functionality
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
* Improve Response.messages field documentation
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
* Add parent_id parameter to OutputScope
Similar to the .NET ExecuteToolScope, the OutputScope now accepts an optional
parent_id parameter to link spans to upstream operations.
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
* Add parent_id to base OpenTelemetryScope class
Similar to the .NET implementation, the base OpenTelemetryScope class now
accepts an optional parent_id parameter that sets the CUSTOM_PARENT_SPAN_ID_KEY
attribute on the span. This allows all scope subclasses to support parent
span linking consistently.
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
* Make record_output_messages append messages instead of replacing
Changed the behavior of record_output_messages to append new messages to
the accumulated list rather than replacing all messages. This allows
collecting output messages over multiple calls during the scope's lifetime.
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
* Fix parent_id to set on span context instead of span attribute
Changed the parent_id implementation to properly link spans by parsing the
W3C Trace Context format parent ID and using it to create a proper span
context. This aligns with the .NET implementation which calls
`activity?.SetParentId(parentId!)`.
Added validation for W3C Trace Context version and trace_id/span_id lengths.
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
* Move parse_parent_id_to_context to utils.py
Refactored W3C Trace Context parsing:
- Added W3C Trace Context validation constants
- Added validate_w3c_trace_context_version() helper
- Added validate_trace_id() helper with hex validation
- Added validate_span_id() helper with hex validation
- Moved parse_parent_id_to_context() from opentelemetry_scope.py
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
* Clean up test_output_scope.py - remove redundant tests and aggregate similar ones
Reduced from 10 tests to 4 focused tests:
- test_output_scope_creates_span_with_messages (merged span name and messages tests)
- test_record_output_messages_appends (merged multiple append tests)
- test_output_scope_with_parent_id (parent linking)
- test_output_scope_dispose (manual dispose)
All tests use real spans via InMemorySpanExporter (no mocks).
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
* address PR comments
---------
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>
Co-authored-by: Nikhil Chitlur Navakiran (from Dev Box) <nikhilc@microsoft.com>1 parent 358a1dd commit eaa2136
File tree
6 files changed
+382
-7
lines changed- libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core
- models
- spans_scopes
- tests/observability/core
6 files changed
+382
-7
lines changedLines changed: 12 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 | + | |
Lines changed: 18 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
14 | 21 | | |
15 | 22 | | |
16 | 23 | | |
| |||
32 | 39 | | |
33 | 40 | | |
34 | 41 | | |
| 42 | + | |
35 | 43 | | |
36 | 44 | | |
37 | 45 | | |
| |||
71 | 79 | | |
72 | 80 | | |
73 | 81 | | |
| 82 | + | |
74 | 83 | | |
75 | 84 | | |
76 | 85 | | |
| |||
80 | 89 | | |
81 | 90 | | |
82 | 91 | | |
| 92 | + | |
| 93 | + | |
83 | 94 | | |
84 | 95 | | |
85 | 96 | | |
| |||
102 | 113 | | |
103 | 114 | | |
104 | 115 | | |
105 | | - | |
106 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
107 | 121 | | |
108 | | - | |
109 | | - | |
110 | | - | |
| 122 | + | |
111 | 123 | | |
112 | 124 | | |
113 | 125 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
Lines changed: 78 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 | + | |
Lines changed: 124 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | | - | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
27 | 28 | | |
28 | 29 | | |
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 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
30 | 153 | | |
31 | 154 | | |
32 | 155 | | |
| |||
0 commit comments