Skip to content

Add A365 S2S exporter sample - #217

Merged
Nikhil Navakiran (nikhilNava) merged 26 commits into
mainfrom
nikhilc/add-a365-s2s-sample
Sep 28, 2026
Merged

Nikhil Navakiran (nikhilNava) merged 26 commits into
mainfrom
nikhilc/add-a365-s2s-sample

Conversation

@nikhilNava

Copy link
Copy Markdown
Collaborator

What

Adds a self-contained sample under samples/a365_s2s/ demonstrating how to export Agent 365 (A365) telemetry using the S2S (service-to-service) flow.

Why

The existing samples/a365 samples cover the AI-teammate flow (with an agentic user). This adds the missing S2S scenario, where a service authenticates on its own behalf using its app-registration credentials — there is no agentic user.

What's in it

  • S2S token resolver that mirrors the SDK's _create_fic_token_resolver (app -> instance token exchange via MSAL), excluding the agentic-user (user_fic) step, combined with a365_use_s2s_endpoint=True.
  • Manual A365 scope classes (InvokeAgent / Inference / ExecuteTool), so the sample needs no LLM.
  • uv-managed project (pyproject.toml), .env via python-dotenv (with .env.example), and a placeholder/empty-value guard with friendly errors.
  • DEBUG logging scoped to the exporter so developers see the export HTTP status and correlation id, e.g. HTTP 200 success ... Correlation ID: <id> ... "status":"sent".

Testing

Verified end-to-end against the live S2S endpoint: token acquired and HTTP 200 with all sinks reporting sent. The placeholder guard and missing-credential paths were also exercised.

Note: .env (real credentials) and .venv are gitignored and intentionally excluded from this PR.

Add a self-contained sample under samples/a365_s2s/ demonstrating A365
telemetry export using the S2S (service-to-service) flow:

- Custom a365_token_resolver mirroring the SDK FIC flow (app -> instance
  token exchange via MSAL) minus the agentic-user step, plus
  a365_use_s2s_endpoint=True.
- Manual A365 scope classes (InvokeAgent/Inference/ExecuteTool), so the
  sample needs no LLM.
- uv-managed project (pyproject.toml), .env via python-dotenv, and DEBUG
  logging so developers can see the export HTTP status and correlation id.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 24, 2026 •

Copy link
Copy Markdown

Performance comparison

Threshold: regressions >15.0% on gating scenarios fail the build. Higher ops/s is better; positive Δ means the PR is slower.

Scenario Gating Baseline (ops/s) Candidate (ops/s) Δ % Status
azure_monitor_log yes 36,655.5 38,301.0 -4.30% ✅
azure_monitor_span yes 277,354.0 277,739.2 -0.14% ✅
otel_log no 44,875.2 45,886.3 -2.20% ✅
otel_span no 84,118.4 84,189.3 -0.08% ✅

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

Adds a new self-contained sample under samples/a365_s2s/ that demonstrates exporting Agent 365 (A365) telemetry via the service-to-service (S2S) authentication flow, including a custom MSAL-based token resolver and manual scope instrumentation.

Changes:

  • Introduces an S2S sample script that configures the A365 exporter for the S2S ingest endpoint and emits representative spans using manual A365 scope classes.
  • Adds sample documentation + .env template describing required credentials, runtime toggles, and expected DEBUG exporter output.
  • Adds an uv-managed sample project (with lockfile) to make the sample runnable without manual venv setup.

Reviewed changes

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

Show a summary per file
File Description
samples/a365_s2s/s2s_exporter.py Implements the S2S token resolver and a runnable manual-telemetry scenario configured for the S2S exporter endpoint.
samples/a365_s2s/README.md Documents prerequisites, setup, execution, and required environment variables for the S2S scenario.
samples/a365_s2s/pyproject.toml Defines a small uv project with runtime dependencies for the sample.
samples/a365_s2s/.env.example Provides a template for required env vars and exporter toggles.
samples/a365_s2s/uv.lock Locks the sample’s dependency set for reproducible installs via uv.

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

Comment thread samples/a365/s2s/s2s_exporter.py Outdated
Comment thread samples/a365/s2s/s2s_exporter.py Outdated
Comment thread samples/a365_s2s/s2s_exporter.py Outdated
Comment thread samples/a365/s2s/.env.example Outdated
nikhilc-microsoft and others added 3 commits July 9, 2026 15:09
- Use request_tenant_id for the MSAL authority and fail fast when it
  diverges from the configured credential tenant, so tokens are acquired
  for the same tenant they are cached under.
- Guard _configure_export_logging against duplicate StreamHandlers and
  disable propagation to avoid double-logging on repeated runs.
- Move the sample under samples/a365/s2s and update README references.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516a9ff0-9d67-4aae-87af-e7e6395a66e1
The inline pragma was not recognized by the CI-pinned pylint (3.2.7)
because it followed the vestigial ruff noqa in the same comment. Ruff is
not configured in this repo, so drop the noqa and lead the comment with
the pylint disable pragma.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516a9ff0-9d67-4aae-87af-e7e6395a66e1
openai 2.45.0 made InputTokensDetails.cache_write_tokens a required
field. openai-agents (pulled transitively via the agent-framework and
openai-agents extras) still constructs InputTokensDetails(cached_tokens=0)
in agents/usage.py, which now raises pydantic ValidationError and breaks
the tests/a365/integration/openai suite.

Constrain openai to >=2.36.0,<2.45.0 in both extras. This satisfies
openai-agents 0.18.0 (openai<3,>=2.36.0) and agent-framework-openai
1.10.0 (openai<3,>=1.99.0), resolving to openai 2.44.0. Verified that
InputTokensDetails(cached_tokens=0) succeeds on 2.44.0 and fails on 2.45.0.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516a9ff0-9d67-4aae-87af-e7e6395a66e1

@rads-1996 Radhika Gupta (rads-1996) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we need to add the .env.example, py.project and uv.lock files, whatever pre-requisites are required should be added to the README. If you look at the other samples, that is how they have been structured,

nikhilc-microsoft and others added 11 commits September 25, 2026 13:45
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nikhilNava

Copy link
Copy Markdown
Collaborator Author

Superseded by #276. The original PR head is an organization-owned branch that the authenticated author account cannot update (push returns HTTP 403). #276 contains the merged-main, Store-ready all-scope implementation, tests, documentation, and the review fixes discussed here.

auto-merge was automatically disabled September 25, 2026 21:04

Pull request was closed

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f508abed-7ca3-48f8-b257-094c94a5e4ad
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f508abed-7ca3-48f8-b257-094c94a5e4ad
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f508abed-7ca3-48f8-b257-094c94a5e4ad
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f508abed-7ca3-48f8-b257-094c94a5e4ad
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f508abed-7ca3-48f8-b257-094c94a5e4ad
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f508abed-7ca3-48f8-b257-094c94a5e4ad
@nikhilNava Nikhil Navakiran (nikhilNava) added the skip-changelog Not required for changes to test files, github actions, etc. label Sep 28, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f508abed-7ca3-48f8-b257-094c94a5e4ad
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f508abed-7ca3-48f8-b257-094c94a5e4ad
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f508abed-7ca3-48f8-b257-094c94a5e4ad
@nikhilNava
Nikhil Navakiran (nikhilNava) merged commit 8687a67 into main Sep 28, 2026
12 checks passed
@nikhilNava
Nikhil Navakiran (nikhilNava) deleted the nikhilc/add-a365-s2s-sample branch September 28, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Not required for changes to test files, github actions, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants