Skip to content

Add A365 S2S exporter sample#217

Open
nikhilNava wants to merge 1 commit into
mainfrom
nikhilc/add-a365-s2s-sample
Open

Add A365 S2S exporter sample#217
nikhilNava wants to merge 1 commit 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>
Copilot AI review requested due to automatic review settings June 24, 2026 18:09
@github-actions

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 18,779.5 18,868.6 -0.47%
azure_monitor_span yes 154,750.9 154,990.7 -0.15%
otel_log no 22,339.9 22,270.2 +0.31%
otel_span no 33,688.2 33,316.7 +1.12%

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 on lines +213 to +216
def main():
# Load configuration from a local .env file (see .env.example). Real
# environment variables take precedence over the .env file (dotenv default).
load_dotenv()
Comment on lines +133 to +137
def resolve(agent_id: str, request_tenant_id: str) -> Optional[str]:
# The resolver runs on the exporter's worker thread; guard the cache to
# keep token acquisition thread-safe.
cache_key = f"{request_tenant_id}:{agent_id}"

Comment on lines +204 to +211
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("%(levelname)s %(name)s: %(message)s"))
exporter_logger = logging.getLogger(
"microsoft.opentelemetry.a365.core.exporters.agent365_exporter"
)
exporter_logger.setLevel(logging.DEBUG)
exporter_logger.addHandler(handler)

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