Skip to content

Use Agent365ExporterOptions for exporter and create AgenticTokenCache… - #46

Merged
PengF (fpfp100) merged 30 commits into
mainfrom
users/pefan/exportoption
Nov 19, 2025
Merged

Use Agent365ExporterOptions for exporter and create AgenticTokenCache…#46
PengF (fpfp100) merged 30 commits into
mainfrom
users/pefan/exportoption

Conversation

@fpfp100

@fpfp100 PengF (fpfp100) commented Nov 10, 2025

Copy link
Copy Markdown
Contributor
  1. Refactors exporter to adopt Agent365ExporterOptions for centralized configuration surface.
  2. Introduces AgenticTokenCache and token resolver as default resolver to acquiring, cache, refresh token using for exporter. which supports retry logic, concurrent access, and expiration management.
  3. Update sample to demo default resolver and custom resolver new environment variable Use_Custom_Resolver.

Typical usage pattern for AgenticTokenCache:
(1) Add the RefreshObservabilityToken method in activity handler (non-blocking for rest of logic):

image

(2) Later the exporter will try to retrieve the token from the cache. If the token is not returned, an error will be logger.
image

AgenticTokenCache will not be used if Custom token resolver is configured.

@fpfp100 PengF (fpfp100) changed the title use Agent365ExporterOptions for exporter and create AgenticTokenCache… Use Agent365ExporterOptions for exporter and create AgenticTokenCache… Nov 11, 2025
@fpfp100
PengF (fpfp100) marked this pull request as ready for review November 11, 2025 00:09
@fpfp100
PengF (fpfp100) requested a review from a team as a code owner November 11, 2025 00:09
Copilot AI review requested due to automatic review settings November 11, 2025 00:09

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 refactors the Agent365 exporter to use an options pattern and introduces a token caching mechanism for improved flexibility and maintainability.

Key Changes:

  • Introduced Agent365ExporterOptions class to encapsulate exporter configuration
  • Created AgenticTokenCache utility for caching authentication tokens with TTL support
  • Modified Agent365Exporter constructor to make tokenResolver optional, falling back to the cache when not provided
  • Improved type safety by replacing any types with unknown in OTLP interfaces

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
packages/agents-a365-observability/src/utils/AgenticTokenCache.ts New utility class implementing an in-memory TTL-based token cache with get/set operations and cache key generation
packages/agents-a365-observability/src/tracing/exporter/Agent365ExporterOptions.ts New configuration class defining exporter options including cluster category, token resolver, and batch processing parameters
packages/agents-a365-observability/src/tracing/exporter/Agent365Exporter.ts Refactored to use options pattern, made tokenResolver optional with AgenticTokenCache fallback, improved type safety with unknown instead of any
packages/agents-a365-observability/src/ObservabilityBuilder.ts Removed validation requiring tokenResolver, allowing fallback to cache-based resolution
tests/observability/core/agent365-exporter.test.ts New test suite covering exporter functionality with custom and cache-based token resolution

Comment thread tests/observability/core/agent365-exporter.test.ts Outdated
Comment thread tests/observability/core/agent365-exporter.test.ts Outdated
Comment thread packages/agents-a365-observability/src/utils/AgenticTokenCache.ts Outdated
Comment thread packages/agents-a365-observability/src/utils/AgenticTokenCache.ts Outdated
Comment thread tests/observability/core/agent365-exporter.test.ts Outdated
Comment thread packages/agents-a365-observability/src/tracing/exporter/Agent365Exporter.ts Outdated
Comment thread tests/observability/core/agent365-exporter.test.ts Outdated
Comment thread tests/observability/core/agent365-exporter.test.ts Outdated

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.

Comment thread packages/agents-a365-observability/src/ObservabilityBuilder.ts Outdated
Comment thread packages/agents-a365-observability/src/tracing/exporter/Agent365Exporter.ts Outdated
Comment thread tests/observability/core/agent365-exporter.test.ts Outdated
Comment thread tests/observability/core/agent365-exporter.test.ts Outdated
Comment thread packages/agents-a365-observability/src/utils/AgenticTokenCache.ts Outdated
Comment thread tests/observability/core/agent365-exporter.test.ts Outdated
Comment thread tests/observability/core/agent365-exporter.test.ts Outdated

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 15 comments.

Comment thread packages/agents-a365-observability/src/utils/AgenticTokenCache.ts Outdated
Comment thread packages/agents-a365-observability/src/utils/AgenticTokenCache.ts Outdated
Comment thread packages/agents-a365-observability/src/tracing/exporter/Agent365Exporter.ts Outdated
Comment thread tests/observability/core/agent365-exporter.test.ts Outdated
Comment thread packages/agents-a365-observability/src/utils/AgenticTokenCache.ts Outdated
Comment thread packages/agents-a365-observability/src/utils/AgenticTokenCache.ts Outdated
Comment thread tests-agent/basic-agent-sdk-sample/src/telemetry.ts Outdated
Comment thread tests-agent/basic-agent-sdk-sample/src/index.ts Outdated
Comment thread tests-agent/basic-agent-sdk-sample/src/index.ts Outdated

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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 12 comments.

Comment thread packages/agents-a365-observability/src/tracing/exporter/Agent365Exporter.ts Outdated
Comment thread tests-agent/basic-agent-sdk-sample/src/index.ts
Comment thread packages/agents-a365-observability/src/utils/AgenticTokenCache.ts Outdated
Comment thread packages/agents-a365-observability/src/utils/AgenticTokenCache.ts Outdated
Comment thread tests/observability/core/agentic-token-cache.test.ts Outdated
Comment thread packages/agents-a365-observability/src/utils/AgenticTokenCache.ts Outdated
Comment thread tests/observability/core/agentic-token-cache.test.ts Outdated
Comment thread packages/agents-a365-observability/src/utils/AgenticTokenCache.ts Outdated
Comment thread packages/agents-a365-observability/src/utils/AgenticTokenCache.ts Outdated
Comment thread tests-agent/basic-agent-sdk-sample/src/index.ts Outdated

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

Copilot reviewed 22 out of 23 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/agents-a365-observability-tokenCache/src/AgenticTokenCache.ts Outdated
Comment thread tests-agent/basic-agent-sdk-sample/package.json Outdated
Comment thread packages/agents-a365-observability-tokenCache/src/AgenticTokenCache.ts Outdated

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

Copilot reviewed 24 out of 25 changed files in this pull request and generated 6 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/agents-a365-observability-tokenCache/README.md Outdated
Comment thread tests-agent/basic-agent-sdk-sample/src/telemetry.ts Outdated
Comment thread tests/observability/core/observabilityBuilder-options.test.ts Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can we lower case the folder name? tokenCache should be tokencache. Same with observabilityBuilder-options.test.ts, let's Not mix naming conventions.

Comment thread packages/agents-a365-observability-tokenCache/README.md Outdated
Comment thread packages/agents-a365-observability-tokenCache/src/AgenticTokenCache.ts Outdated
Comment thread packages/agents-a365-observability-tokenCache/src/AgenticTokenCache.ts Outdated
Comment thread tests-agent/basic-agent-sdk-sample/.env.example
Comment thread tests/observability/core/observabilityBuilder-options.test.ts Outdated

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

Copilot reviewed 24 out of 25 changed files in this pull request and generated 9 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/agents-a365-observability-tokencache/package.json Outdated
Comment thread tests/observability/core/observabilityBuilder-options.test.ts
Comment thread packages/agents-a365-observability-tokencache/README.md
Comment thread tests/observability/core/observabilityBuilder-options.test.ts
Comment thread tests-agent/basic-agent-sdk-sample/src/index.ts
Comment thread packages/agents-a365-observability-tokencache/src/AgenticTokenCache.ts Outdated
Comment thread tests/observability/extension/tokencache/agentic-token-cache.test.ts Outdated
Comment thread pnpm-lock.yaml

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

Copilot reviewed 24 out of 25 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread tests-agent/basic-agent-sdk-sample/src/agent.ts
@fpfp100
PengF (fpfp100) enabled auto-merge (squash) November 19, 2025 20:58
@fpfp100
PengF (fpfp100) merged commit 6b01e02 into main Nov 19, 2025
7 checks passed
@pontemonti
Johan Broberg (pontemonti) deleted the users/pefan/exportoption branch December 5, 2025 17:09
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.

5 participants