Skip to content

Replace vendored a365 with npm packages direct dependencies - #25

Merged
Hector Hernandez (hectorhdzg) merged 8 commits into
microsoft:mainfrom
hectorhdzg:hectorhdzg/replace-vendored-a365-with-npm-packages
Apr 20, 2026
Merged

Hector Hernandez (hectorhdzg) merged 8 commits into
microsoft:mainfrom
hectorhdzg:hectorhdzg/replace-vendored-a365-with-npm-packages

Conversation

@hectorhdzg

Copy link
Copy Markdown
Member

No description provided.

Restructure src/ to match the Python distro layout:
- azureMonitorSetup.ts, loader.ts -> src/azureMonitor/
- browserSdkLoader/ -> src/azureMonitor/browserSdkLoader/
- generated/ -> src/azureMonitor/generated/
- logs/ -> src/azureMonitor/logs/
- metrics/ -> src/azureMonitor/metrics/
- traces/ -> src/azureMonitor/traces/

Update all import paths in moved files and test files accordingly.
No functional changes.
- Moved connectionStringParser, types, statsbeat, logUtils, and
  opentelemetryInstrumentationPatcher from src/utils/ to src/azureMonitor/utils/
- Split common.ts: AzMon-specific functions (ignoreOutgoingRequestHook,
  getOsPrefix, getResourceProvider, msToTimeSpan) moved to azureMonitor/utils/,
  general functions (parseResourceDetectorsFromEnvVar, isFunctionApp) kept in utils/
- Renamed azureMonitorSetup.ts to azureMonitor/index.ts
- Updated all import paths accordingly
…npm package

Remove 35 vendored source files under src/a365/ and 8 corresponding unit tests.
The distro now depends on the published npm packages instead:

- @microsoft/agents-a365-observability: scopes, constants, contracts, baggage,
  context propagation, ObservabilityManager/Builder, exporter, span processors
- @microsoft/agents-a365-runtime: ClusterCategory enum, IConfigurationProvider

Key changes:
- src/distro/distro.ts: Replace manual A365 setup (A365Configuration +
  Agent365Exporter + processors) with ObservabilityManager.start() called
  after sdk.start() so it detects the existing global TracerProvider
- src/types.ts: Define A365Options inline, import ClusterCategory from npm
- src/index.ts: Re-export public A365 API from npm packages instead of
  vendored ./a365/index.js
- PLANNING.md: Update Phase 6 to reflect npm dependency approach

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the distro’s A365 implementation from in-repo vendored code under src/a365/ to direct npm dependencies (@microsoft/agents-a365-observability and @microsoft/agents-a365-runtime), wiring A365 startup through ObservabilityManager.start() after the NodeSDK is started.

Changes:

  • Replace in-repo A365 exporter/scopes/processors/configuration with @microsoft/agents-a365-observability re-exports and runtime types.
  • Update distro initialization to attach A365 processors via ObservabilityManager.start() (with env-var bridging).
  • Remove the vendored A365 unit test suite and update planning docs to reflect the new dependency model.

Reviewed changes

Copilot reviewed 43 out of 44 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/internal/unit/a365/scopes.test.ts Removed unit tests for vendored A365 scopes.
test/internal/unit/a365/perRequestSpanProcessor.test.ts Removed unit tests for vendored per-request span processor.
test/internal/unit/a365/messageUtils.test.ts Removed unit tests for vendored message utils.
test/internal/unit/a365/contextPropagation.test.ts Removed unit tests for vendored context propagation helpers.
test/internal/unit/a365/baggageBuilder.test.ts Removed unit tests for vendored baggage builder/scope.
test/internal/unit/a365/a365SpanProcessor.test.ts Removed unit tests for vendored baggage→span enrichment processor.
test/internal/unit/a365/a365Configuration.test.ts Removed unit tests for vendored A365 configuration parsing/precedence.
src/types.ts Defines distro-owned A365Options and imports ClusterCategory from the runtime package.
src/shared/jsonConfig.ts Switches to A365Options from src/types.ts for JSON config typing.
src/index.ts Re-exports A365 public API surface from @microsoft/agents-a365-observability / runtime.
src/distro/types.ts Re-exports A365Options from src/types.ts instead of vendored A365 module.
src/distro/distro.ts Integrates A365 via ObservabilityManager.start() after NodeSDK.start() and bridges env vars/config provider.
src/a365/utils/utils.ts Removed vendored A365 env helper.
src/a365/scopes/index.ts Removed vendored A365 scopes barrel export.
src/a365/scopes/OutputScope.ts Removed vendored OutputScope.
src/a365/scopes/OpenTelemetryScope.ts Removed vendored base scope implementation.
src/a365/scopes/InvokeAgentScope.ts Removed vendored InvokeAgentScope.
src/a365/scopes/InferenceScope.ts Removed vendored InferenceScope.
src/a365/scopes/ExecuteToolScope.ts Removed vendored ExecuteToolScope.
src/a365/processors/util.ts Removed vendored attribute registry used by A365 span processor.
src/a365/processors/index.ts Removed vendored processors barrel export.
src/a365/processors/PerRequestSpanProcessor.ts Removed vendored per-request buffering processor.
src/a365/processors/A365SpanProcessor.ts Removed vendored baggage→span enrichment processor.
src/a365/middleware/index.ts Removed vendored middleware barrel export.
src/a365/middleware/BaggageBuilder.ts Removed vendored baggage builder/scope.
src/a365/message-utils.ts Removed vendored message normalization/serialization utilities.
src/a365/index.ts Removed vendored A365 public barrel (config/exporter/scopes/processors/etc.).
src/a365/exporter/utils.ts Removed vendored exporter utilities (partitioning/truncation/etc.).
src/a365/exporter/index.ts Removed vendored exporter barrel.
src/a365/exporter/ExporterEventNames.ts Removed vendored exporter event names.
src/a365/exporter/Agent365ExporterOptions.ts Removed vendored exporter options and resolved options.
src/a365/exporter/Agent365Exporter.ts Removed vendored exporter implementation.
src/a365/contracts.ts Removed vendored A365 contracts/types/enums.
src/a365/context/tokenContext.ts Removed vendored per-request export token context helpers.
src/a365/context.ts Removed vendored context propagation helpers (parent span ref + W3C inject/extract).
src/a365/constants.ts Removed vendored A365 OpenTelemetry constants.
src/a365/configuration/index.ts Removed vendored A365 configuration barrel.
src/a365/configuration/A365ConfigurationOptions.ts Removed vendored A365 configuration options/types.
src/a365/configuration/A365Configuration.ts Removed vendored A365 configuration resolution (defaults/json/env precedence).
package.json Adds @microsoft/agents-a365-observability and @microsoft/agents-a365-runtime dependencies.
azure-monitor-opentelemetry/README.md Removes temporary Azure Monitor staging readme.
PLANNING.md Updates plan/docs to reflect A365 as npm dependencies and new integration approach.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/distro/distro.ts
Comment thread src/index.ts Outdated
Comment thread src/distro/distro.ts Outdated
Comment thread src/distro/distro.ts Outdated
@hectorhdzg
Hector Hernandez (hectorhdzg) merged commit 7f986ee into microsoft:main Apr 20, 2026
5 checks passed
Hector Hernandez (hectorhdzg) added a commit that referenced this pull request Apr 21, 2026
#27)

* Revert "Replace vendored a365 with npm packages direct dependencies (#25)"

This reverts commit 7f986ee.

* Update

* Update

* Update test
Hector Hernandez (hectorhdzg) added a commit to hectorhdzg/opentelemetry-distro-javascript that referenced this pull request Apr 21, 2026
Hector Hernandez (hectorhdzg) added a commit that referenced this pull request Apr 22, 2026
* Revert "Replace vendored a365 with npm packages direct dependencies (#25)"

This reverts commit 7f986ee.

* Update

* Update

* Update test

* feat(a365): add hosting observability middleware and utilities

Add hosting-layer middleware adapted from Agent365-nodejs that enables
automatic OpenTelemetry instrumentation for agents-hosting compatible
adapters using structural typing (no direct dependency on
@microsoft/agents-hosting).

Hosting middleware:
- BaggageMiddleware: propagates OTel baggage (tenant, agent, caller,
  channel, conversation) from TurnContext; skips ContinueConversation
- OutputLoggingMiddleware: creates OutputScope spans for outgoing
  messages with parent span linking
- ObservabilityHostingManager: one-call middleware registration

Hosting utilities:
- TurnContextUtils: extract baggage pairs from TurnContext activity
- ScopeUtils: create InferenceScope/InvokeAgentScope/ExecuteToolScope
  pre-populated from TurnContext
- BaggageBuilderUtils: populate BaggageBuilder from TurnContext

Bug fixes (vendored A365 code vs upstream):
- Fix S2S exporter endpoint path (add /otlp/ segment)
- Fix SDK version constant to read from package version
- Add ~15 missing OpenTelemetryConstants from upstream

Also includes:
- Comprehensive unit tests (6 test files, 62 new tests)
- Hosting middleware sample app (a365HostingMiddleware.ts)
- Updated samples README

* Fix ci errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants