Commit ca36cd4
Migrate agentserver tracing from azure-monitor-opentelemetry-exporter… (#46561)
* Migrate agentserver tracing from azure-monitor-opentelemetry-exporter to microsoft-opentelemetry
Replace manual Azure Monitor and OTLP exporter wiring (~100 lines) with a
single use_microsoft_opentelemetry() call via the new microsoft-opentelemetry
distro. The distro auto-detects exporters from environment variables.
Changes:
- core pyproject.toml: swap azure-monitor-opentelemetry-exporter + otlp-grpc
for microsoft-opentelemetry>=0.5.0
- core _tracing.py: refactor _configure_tracing() to delegate to new
_setup_distro_export() wrapper; remove 4 _setup_* functions and guard flags
- Update all test mocks in core and invocations to patch the single
_setup_distro_export target instead of multiple _setup_* functions
- Remove azure-monitor-opentelemetry-exporter from dev_requirements.txt
in both core and invocations packages
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add warning log when OTel resource creation fails
Log a warning in _configure_tracing() when _create_resource() returns None,
making it clear that tracing will not be configured.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address PR review comments
- Fix docstring and inline comment to accurately describe logger suppression
(only Azure Core HTTP logging policy, not generic OTel exporters)
- Make _ensure_trace_provider idempotent via _agentserver_processors_added
guard to prevent duplicate processors on repeated calls
- Rename TestSetupAzureMonitor -> TestSetupDistroExport to match new impl
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: add create=True to _setup_distro_export patches for min-dep compat
The invocations min-dependency CI installs the published core package
from PyPI, which does not yet have _setup_distro_export. Adding
create=True allows the mock to succeed regardless of the installed
core version.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: use valid UUID in fake instrumentation keys for tests
The microsoft-opentelemetry distro validates that the instrumentation
key is a proper UUID. Replace 'InstrumentationKey=test' with
'InstrumentationKey=00000000-0000-0000-0000-000000000000' in all
test files.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix: lower microsoft-opentelemetry version to >=0.1.0b1
The previous requirement >=0.5.0 doesn't exist on PyPI. The latest
available release is 0.1.0b1 (just published).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add INFO log on successful tracing configuration
The previous code logged INFO for each exporter configured (e.g.
'Application Insights trace exporter configured.'). This preserves
that pattern with a single INFO message when the distro setup succeeds.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix: enable Azure Monitor export in distro call
The microsoft-opentelemetry distro has Azure Monitor disabled by
default. Pass enable_azure_monitor=True and the connection string
via azure_monitor_connection_string when a connection string is
provided.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add e2e span parenting test for App Insights
Adds test_span_parenting_in_appinsights which verifies that a child span
created inside request_span is correctly parented in App Insights:
- Captures child span ID locally during handler execution
- Queries dependencies table by child span ID
- Follows operation_ParentId to find the parent invoke_agent span in requests table
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: defer set_tracer_provider to fixture to unblock e2e tests
Move module-level set_tracer_provider() calls in invocations unit tests
into autouse fixtures. When pytest collects tests it imports ALL modules,
even deselected ones. Module-level calls consumed the OTel Once guard
before the e2e test could configure the microsoft-opentelemetry distro,
causing spans to never reach App Insights.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: add microsoft-opentelemetry to shared_requirements.txt
The dependency analyzer requires all package dependencies to be listed
in shared_requirements.txt.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: resolve pylint errors in _tracing.py
- Add :keyword: docstring entries for _setup_distro_export (C4758)
- Use dict literal instead of dict() call (R1735)
- Add :param: docstring entries for _ensure_trace_provider (C4739)
- Suppress protected-access warning on idempotency guard (W0212)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: add param types to _ensure_trace_provider docstring (C4740)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 59e1823 commit ca36cd4
10 files changed
Lines changed: 264 additions & 231 deletions
File tree
- sdk/agentserver
- azure-ai-agentserver-core
- azure/ai/agentserver/core
- tests
- azure-ai-agentserver-invocations
- tests
Lines changed: 91 additions & 140 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | | - | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
133 | | - | |
| 134 | + | |
134 | 135 | | |
135 | | - | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
152 | 154 | | |
153 | | - | |
154 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
155 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
156 | 216 | | |
157 | | - | |
158 | | - | |
159 | | - | |
| 217 | + | |
| 218 | + | |
160 | 219 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
| 220 | + | |
165 | 221 | | |
166 | 222 | | |
167 | 223 | | |
| |||
508 | 564 | | |
509 | 565 | | |
510 | 566 | | |
511 | | - | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
512 | 577 | | |
513 | 578 | | |
514 | 579 | | |
| |||
517 | 582 | | |
518 | 583 | | |
519 | 584 | | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
| 585 | + | |
545 | 586 | | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
642 | | - | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
643 | 594 | | |
644 | 595 | | |
645 | 596 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
| 28 | + | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
73 | 72 | | |
74 | 73 | | |
75 | 74 | | |
76 | | - | |
77 | | - | |
| 75 | + | |
Lines changed: 24 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
146 | 144 | | |
147 | 145 | | |
148 | 146 | | |
| |||
0 commit comments