Repository navigation
Revert PR #45: restore vendored A365 code - #47
Merged
Hector Hernandez (hectorhdzg) merged 4 commits intoApr 21, 2026
Merged
Hector Hernandez (hectorhdzg) merged 4 commits into
Hector Hernandez (hectorhdzg) merged 4 commits into
Conversation
Restore vendored A365 observability core, hosting, and runtime modules to regain full control over span enrichment, batching, and export behavior.
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Restores vendored Agent 365 (A365) observability runtime/hosting/core code into this repo to regain control over span enrichment, batching, and export behavior, while broadening supported Python versions down to 3.10.
Changes:
- Vendored A365 core/runtime/hosting modules and updated distro integration to use in-repo A365 components.
- Expanded Python support to 3.10 (tox/CI/pyproject config updates).
- Added/updated tests and migration docs to reflect new import paths and behavior.
Reviewed changes
Copilot reviewed 90 out of 91 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tox.ini | Expand test matrix to include Python 3.10 and update mypy target version. |
| tests/test_distro.py | Update patch paths and adjust expectations for A365 processor wiring. |
| tests/a365/test_utils.py | Add unit tests for A365 exporter utility helpers. |
| tests/a365/test_span_processor.py | Add tests for A365SpanProcessor identity stamping and baggage propagation. |
| tests/a365/test_handler.py | Add tests for A365 enablement and handler creation from env/flags. |
| tests/a365/test_exporter.py | Add tests for Agent365 exporter partitioning, posting, and request shaping. |
| tests/a365/test_enriching_span_processor.py | Add tests for span enricher registration and batch processor enrichment/suppression. |
| tests/a365/runtime/test_version_utils.py | Add tests for deprecated build_version behavior and warning. |
| tests/a365/runtime/test_power_platform_api_discovery.py | Add tests for Power Platform endpoint discovery logic. |
| tests/a365/runtime/test_operation_result.py | Add tests for OperationResult success/failure and string formatting. |
| tests/a365/runtime/test_operation_error.py | Add tests for OperationError validation and formatting. |
| tests/a365/runtime/test_environment_utils.py | Add tests for scope override and dev-environment detection logic. |
| tests/a365/runtime/init.py | Add package marker for runtime tests. |
| tests/a365/hosting/token_cache_helpers/test_agent_token_cache.py | Add tests for token cache registration, async token exchange, and thread safety. |
| tests/a365/hosting/token_cache_helpers/init.py | Add package marker for token cache helper tests. |
| tests/a365/hosting/scope_helpers/test_scope_helper_utils.py | Add tests for scope helper pair extraction from Activities. |
| tests/a365/hosting/scope_helpers/test_populate_invoke_agent_scope.py | Add test verifying InvokeAgent scope population from TurnContext. |
| tests/a365/hosting/scope_helpers/test_populate_baggage.py | Add test verifying baggage builder population from TurnContext. |
| tests/a365/hosting/scope_helpers/init.py | Add package marker for scope helper tests. |
| tests/a365/hosting/middleware/test_output_logging_middleware.py | Add tests for output logging middleware send handler behavior. |
| tests/a365/hosting/middleware/test_observability_hosting_manager.py | Add tests for singleton hosting manager middleware registration. |
| tests/a365/hosting/middleware/test_baggage_middleware.py | Add tests for baggage middleware propagation and async-reply skip behavior. |
| tests/a365/hosting/middleware/init.py | Add package marker for middleware tests. |
| tests/a365/hosting/init.py | Add package marker for hosting tests. |
| tests/a365/init.py | Add package marker for A365 tests. |
| src/microsoft/opentelemetry/a365/runtime/version_utils.py | Add deprecated build_version helper with deprecation warning. |
| src/microsoft/opentelemetry/a365/runtime/utility.py | Add runtime Utility helpers (token parsing, user-agent, app name discovery). |
| src/microsoft/opentelemetry/a365/runtime/power_platform_api_discovery.py | Add Power Platform API endpoint discovery helper. |
| src/microsoft/opentelemetry/a365/runtime/operation_result.py | Add OperationResult success/failure value type. |
| src/microsoft/opentelemetry/a365/runtime/operation_error.py | Add OperationError wrapper around exceptions. |
| src/microsoft/opentelemetry/a365/runtime/environment_utils.py | Add environment helpers for auth scopes & dev detection. |
| src/microsoft/opentelemetry/a365/runtime/init.py | Export runtime public surface. |
| src/microsoft/opentelemetry/a365/hosting/token_cache_helpers/agent_token_cache.py | Add observability token cache keyed by (agent, tenant) with async token exchange. |
| src/microsoft/opentelemetry/a365/hosting/token_cache_helpers/init.py | Export token cache helpers. |
| src/microsoft/opentelemetry/a365/hosting/scope_helpers/utils.py | Add helpers to extract attribute pairs from Activities. |
| src/microsoft/opentelemetry/a365/hosting/scope_helpers/populate_invoke_agent_scope.py | Populate InvokeAgentScope from TurnContext activity fields. |
| src/microsoft/opentelemetry/a365/hosting/scope_helpers/populate_baggage.py | Populate BaggageBuilder from TurnContext activity fields. |
| src/microsoft/opentelemetry/a365/hosting/scope_helpers/init.py | Add package marker for scope helpers. |
| src/microsoft/opentelemetry/a365/hosting/middleware/output_logging_middleware.py | Add middleware to create OutputScope spans for outgoing messages. |
| src/microsoft/opentelemetry/a365/hosting/middleware/observability_hosting_manager.py | Add singleton manager to register hosting middleware based on options. |
| src/microsoft/opentelemetry/a365/hosting/middleware/baggage_middleware.py | Add middleware to set baggage context from TurnContext. |
| src/microsoft/opentelemetry/a365/hosting/middleware/init.py | Export hosting middleware public surface. |
| src/microsoft/opentelemetry/a365/hosting/init.py | Export hosting library public surface. |
| src/microsoft/opentelemetry/a365/core/utils.py | Add various core utilities (context extraction, flattening, serialization helper, IP normalization). |
| src/microsoft/opentelemetry/a365/core/tool_type.py | Add ToolType enum for tool execution telemetry. |
| src/microsoft/opentelemetry/a365/core/tool_call_details.py | Add ToolCallDetails dataclass. |
| src/microsoft/opentelemetry/a365/core/spans_scopes/output_scope.py | Add OutputScope for output message spans and serialization behavior. |
| src/microsoft/opentelemetry/a365/core/spans_scopes/init.py | Add package marker for spans/scopes package. |
| src/microsoft/opentelemetry/a365/core/span_details.py | Add SpanDetails dataclass to carry span config (parent/kind/times/links). |
| src/microsoft/opentelemetry/a365/core/request.py | Add Request dataclass for scope construction. |
| src/microsoft/opentelemetry/a365/core/opentelemetry_scope.py | Add OpenTelemetryScope base class with span construction and common tagging. |
| src/microsoft/opentelemetry/a365/core/models/user_details.py | Add UserDetails dataclass. |
| src/microsoft/opentelemetry/a365/core/models/service_endpoint.py | Add ServiceEndpoint dataclass. |
| src/microsoft/opentelemetry/a365/core/models/response.py | Add Response dataclass supporting structured tool-result dicts. |
| src/microsoft/opentelemetry/a365/core/models/messages.py | Add OTEL gen-ai message type model definitions and wrappers. |
| src/microsoft/opentelemetry/a365/core/models/caller_details.py | Add CallerDetails dataclass to group user + calling agent info. |
| src/microsoft/opentelemetry/a365/core/models/init.py | Add package marker for models package. |
| src/microsoft/opentelemetry/a365/core/middleware/baggage_builder.py | Add BaggageBuilder fluent API and BaggageScope context manager. |
| src/microsoft/opentelemetry/a365/core/middleware/init.py | Export middleware components. |
| src/microsoft/opentelemetry/a365/core/message_utils.py | Add message normalization + safe serialization helpers. |
| src/microsoft/opentelemetry/a365/core/invoke_agent_scope.py | Add InvokeAgentScope for invoke_agent spans and message recording. |
| src/microsoft/opentelemetry/a365/core/invoke_agent_details.py | Add InvokeAgentScopeDetails dataclass. |
| src/microsoft/opentelemetry/a365/core/inference_scope.py | Add InferenceScope for model inference spans and message recording. |
| src/microsoft/opentelemetry/a365/core/inference_operation_type.py | Add InferenceOperationType enum. |
| src/microsoft/opentelemetry/a365/core/inference_call_details.py | Add InferenceCallDetails dataclass. |
| src/microsoft/opentelemetry/a365/core/exporters/spectra_exporter_options.py | Add Spectra exporter options container (sidecar OTLP). |
| src/microsoft/opentelemetry/a365/core/exporters/span_processor.py | Add A365SpanProcessor stamping identity and propagating baggage to span attrs. |
| src/microsoft/opentelemetry/a365/core/exporters/enriching_span_processor.py | Add span enricher registry and enriching BatchSpanProcessor wrapper. |
| src/microsoft/opentelemetry/a365/core/exporters/enriched_span.py | Add EnrichedReadableSpan wrapper to add/exclude attrs before export. |
| src/microsoft/opentelemetry/a365/core/exporters/agent365_exporter_options.py | Add Agent365 exporter options container. |
| src/microsoft/opentelemetry/a365/core/exporters/agent365_exporter.py | Add HTTP exporter that partitions spans by identity and posts JSON payloads. |
| src/microsoft/opentelemetry/a365/core/exporters/init.py | Add package marker for exporters package. |
| src/microsoft/opentelemetry/a365/core/execute_tool_scope.py | Add ExecuteToolScope for tool execution spans and result recording. |
| src/microsoft/opentelemetry/a365/core/constants.py | Add core constants for operation names and semantic convention keys. |
| src/microsoft/opentelemetry/a365/core/channel.py | Add Channel dataclass. |
| src/microsoft/opentelemetry/a365/core/agent_details.py | Add AgentDetails dataclass. |
| src/microsoft/opentelemetry/a365/core/init.py | Export A365 core public surface (scopes, models, enums). |
| src/microsoft/opentelemetry/a365/constants.py | Add distro-level constants superset (incl env var names). |
| src/microsoft/opentelemetry/a365/init.py | Add A365 package shim exposing handler helpers for backward compat. |
| src/microsoft/opentelemetry/_distro.py | Switch distro A365 integration to use vendored modules and updated processor chain. |
| src/microsoft/opentelemetry/_a365_utils.py | Remove distro token resolver utilities (now sourced from vendored A365 utils). |
| samples/langchain/validate_traces.py | Reformat sample code and update checks formatting. |
| samples/a365/manual_telemetry.py | Update imports to vendored A365 core package path. |
| pyproject.toml | Lower requires-python to 3.10 and replace external A365 core dependency with agent framework deps. |
| docs/MIGRATION_A365.md | Update migration guidance to reflect new microsoft.opentelemetry.* import paths. |
| PLANNING.md | Update plan to converge by migrating A365 code in-repo. |
| .gitignore | Remove duplicate ignore entries. |
| .github/workflows/pr-validation.yml | Run CI on Python 3.10 and add tox env for pytest-py310. |
Comments suppressed due to low confidence (9)
pyproject.toml:1
- New runtime/exporter modules import third-party packages that are not declared as dependencies in pyproject.toml (e.g.,
jwtinruntime/utility.pyandrequestsincore/exporters/agent365_exporter.py). This will cause runtime ImportError for consumers; add the appropriate dependencies (typicallyPyJWTandrequests) or refactor to avoid them.
[build-system]
src/microsoft/opentelemetry/a365/hosting/scope_helpers/utils.py:1
get_tenant_id_pair()assumesactivity.recipientis always present. Ifrecipientis None (which your own middleware tests cover as a possible case), this will raise an AttributeError when scope/baggage population iterates pairs. Guard like the other helpers (return early when recipient is missing) and yield(TENANT_ID_KEY, None)only when the value is available.
src/microsoft/opentelemetry/a365/hosting/middleware/output_logging_middleware.py:1- The
logiccallable is annotated as requiring aTurnContextargument, but the implementation callsawait logic()with no arguments. This mismatch is currently hidden bymypy: disable-error-code=\"call-arg\"but can still mislead implementers and break if a passedlogicexpects the context. Prefer aligning the signature with actual usage (e.g.,Callable[[], Awaitable[None]]) or passcontextintologic(context)consistently.
src/microsoft/opentelemetry/a365/hosting/middleware/baggage_middleware.py:1 - Same issue as OutputLoggingMiddleware:
logicis typed asCallable[[TurnContext], Awaitable]but invoked asawait logic()with no args. Align the type annotation with the actual calling convention (or passcontext). This will make the middleware contract clearer and remove the need for suppressing mypy call-arg errors.
tests/a365/hosting/scope_helpers/test_populate_invoke_agent_scope.py:1 - This fixture sets a global tracer provider but does not restore the previous provider after the module completes. That can leak global state into other tests (order-dependent failures). Capture the current provider before overwriting it and restore it in teardown (and consider resetting any global span processor state if needed).
src/microsoft/opentelemetry/a365/runtime/utility.py:1 - The docstring for
get_app_id_from_token()does not match the implementation: on invalid/malformed tokens it returns an empty string, not the empty GUID, and when no app id claim exists it also returns empty string. Please update the docstring (or adjust the return behavior) so callers have an accurate contract.
src/microsoft/opentelemetry/a365/hosting/scope_helpers/utils.py:1 - There are now two constant sets (
microsoft.opentelemetry.a365.constantsandmicrosoft.opentelemetry.a365.core.constants) that substantially overlap. This helper imports from the non-core constants while many tests and core components import fromcore.constants, increasing the risk of key divergence. Consider consolidating to a single source of truth (or explicitly re-export core constants from the top-level module) and using one consistently.
tests/test_distro.py:1 - This test no longer asserts the behavior described in its docstring (that A365 span processors are appended). It only asserts the tracer provider is not None, which doesn’t validate the integration path. Please add an assertion that
create_a365_components()is called and/or that the returnedspan_processorsare actually attached to the provider (e.g., by inspecting provider span processors or validating a processor’son_startis invoked).
src/microsoft/opentelemetry/a365/runtime/operation_result.py:1 success()relies on_success_instancehaving been initialized and uses a type ignore to satisfy typing. A small change (e.g., refactor/removal of the module-level initializer) could turn this into a runtime None. Prefer makingsuccess()robust by lazily initializing_success_instancewhen it’s None (and returning it without a type ignore), or initializing it at class definition time.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Restore vendored A365 observability core, hosting, and runtime modules to regain full control over span enrichment, batching, and export behavior.
…ctorhdzg/opentelemetry-distro-python into a365/revert-external-packages
Hector Hernandez (hectorhdzg)
enabled auto-merge (squash)
April 21, 2026 22:56
Radhika Gupta (rads-1996)
approved these changes
Apr 21, 2026
Hector Hernandez (hectorhdzg)
merged commit Apr 21, 2026
85fafa2
into
microsoft:main
8 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restore vendored A365 observability core, hosting, and runtime modules to regain full control over span enrichment, batching, and export behavior.