docs: add guide for integrating SDK with existing OpenTelemetry#254
Merged
juliomenendez merged 6 commits intoMay 18, 2026
Conversation
New top-level doc that explains the recommended init order, two minimal patterns (Azure Monitor and manual OTel SDK), the auto vs manual instrumentation matrix, expected span types, a verification recipe, three common pitfalls, and an exporter-combination table. Adds a short callout at the top of the observability-core README that links to the new guide so customers landing on PyPI / GitHub discover it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The 'What spans should I expect to see?' table incorrectly listed 'inference' as the gen_ai.operation.name value. InferenceScope actually uses InferenceOperationType.value (e.g. Chat / TextCompletion / GenerateContent) for both the attribute and the span name. Updated the table and the trailing paragraph to reflect actual SDK behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Agent 365 SDK gates scope-driven span creation behind ENABLE_OBSERVABILITY (or ENABLE_A365_OBSERVABILITY) env var. Without it, the user's existing OTel backend works fine but Agent 365 scopes silently produce zero spans — a confusing failure mode that wasn't covered in the original troubleshooting section. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Manual instrumentation produces InferenceOperationType.value (e.g. "Chat", capitalized) while auto-instrumentation extensions produce the lowercase OTel GenAI semconv form (e.g. "chat"). Tracked as an SDK issue; documented here so users can interpret what they see in their backend. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
nikhilNava
previously approved these changes
May 18, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new top-level guide documenting how to integrate microsoft-agents-a365-observability-core into applications that already initialize OpenTelemetry, and links to it from the observability-core README.
Changes:
- Add
docs/integrating-with-existing-opentelemetry.mdwith recommended init order, minimal patterns, span expectations, verification steps, and pitfalls. - Add a README callout in
libraries/microsoft-agents-a365-observability-core/README.mdpointing to the new integration guide.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| libraries/microsoft-agents-a365-observability-core/README.md | Adds a callout + link to the new “existing OTel integration” guide. |
| docs/integrating-with-existing-opentelemetry.md | Introduces the detailed integration guide, examples, and troubleshooting notes. |
Comments suppressed due to low confidence (3)
docs/integrating-with-existing-opentelemetry.md:39
- The Pattern B snippet later references
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"]but the import list doesn’t includeimport os, so the example isn’t runnable as-is. Addimport osto the snippet imports.
```python
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
docs/integrating-with-existing-opentelemetry.md:86
- This table also uses
||at the start of rows, which typically creates an unintended blank first column in Markdown. Switching to a single leading|per row will render the table correctly.
| `gen_ai.operation.name` | Produced by | Typical parent | Span name (default) | Notes |
|-------------------------|---------------------------------------------------|----------------|---------------------|-------|
| `invoke_agent` | `InvokeAgentScope` (one per user turn) | (root or app) | `invoke_agent <agent_name>` when set, else `invoke_agent` | |
| (varies — see notes) | `InferenceScope` (one per LLM call) | `invoke_agent` | `<operation> <model>` | **Manual instrumentation** uses `InferenceOperationType.value` (currently `Chat` / `TextCompletion` / `GenerateContent`, capitalized). **Auto-instrumentation** (e.g. `OpenAIAgentsTraceInstrumentor`) uses lowercase per the [OTel GenAI semconv](https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/) (e.g. `chat`). The two are inconsistent today. |
| `execute_tool` | `ExecuteToolScope` (one per tool invocation) | `invoke_agent` | `execute_tool <tool_name>` when set, else `execute_tool` | Records tool name, args, and result. |
docs/integrating-with-existing-opentelemetry.md:144
- The exporter combinations table rows also start with
||, which typically renders as an extra blank first column. Consider changing these rows to begin with a single|for consistent Markdown table rendering.
| Combination | What's installed | What to call | Gotchas |
|-----------------------------------------|---------------------------------------------------------------------------|---------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
| Azure Monitor only | `azure-monitor-opentelemetry` | `configure_azure_monitor(...)` | Standard Azure Monitor — no Agent 365 spans flow. |
| Azure Monitor + Agent 365 | `azure-monitor-opentelemetry`, `microsoft-agents-a365-observability-core` | `configure_azure_monitor(...)` then `configure(...)` | Order matters (see Pitfall 1). |
| OTLP collector + Agent 365 | `opentelemetry-sdk`, `opentelemetry-exporter-otlp-*`, A365 core | Build provider + `BatchSpanProcessor(OTLPSpanExporter(...))` then `configure(...)` | Set `OTEL_EXPORTER_OTLP_ENDPOINT`; collector must be reachable. |
- Clarify that Agent 365 backend export requires ENABLE_A365_OBSERVABILITY_EXPORTER + token_resolver - Fix processor description: _EnrichingBatchSpanProcessor + SpanProcessor (not baggage) - Add missing 'import os' to both code snippets - Fix ExecuteToolScope span name (always includes tool_name) - Fix verification section: use actual span names (Chat/chat, not 'inference') - Fix Pitfall 4: env var checked at scope construction, not import time Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
nikhilNava
approved these changes
May 18, 2026
gp-singh
approved these changes
May 18, 2026
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.
Companion to microsoft/Agent365-Samples#288 (greenfield samples).
This PR adds a top-level documentation guide that explains how to integrate the Agent 365 SDK into an application that already has OpenTelemetry configured. It covers:
Also adds a short callout at the top of the observability-core README linking to the new guide.
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com