Skip to content

docs: add guide for integrating SDK with existing OpenTelemetry#254

Merged
juliomenendez merged 6 commits into
mainfrom
docs/integrating-with-existing-opentelemetry
May 18, 2026
Merged

docs: add guide for integrating SDK with existing OpenTelemetry#254
juliomenendez merged 6 commits into
mainfrom
docs/integrating-with-existing-opentelemetry

Conversation

@juliomenendez
Copy link
Copy Markdown
Contributor

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:

  • Recommended initialization order (user's TracerProvider → configure() → framework instrumentor)
  • Two minimal patterns: Azure Monitor and manual OTel SDK
  • Auto vs manual instrumentation matrix
  • Expected span types and their gen_ai.operation.name values
  • Verification recipe for confirming traces arrive
  • Common pitfalls (double-init, missing env var, casing discrepancy)
  • Exporter-combination table

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

juliomenendez and others added 4 commits April 28, 2026 17:05
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>
Copilot AI review requested due to automatic review settings May 18, 2026 23:09
@juliomenendez juliomenendez requested review from a team as code owners May 18, 2026 23:09
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 18, 2026

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

nikhilNava
nikhilNava previously approved these changes May 18, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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.md with recommended init order, minimal patterns, span expectations, verification steps, and pitfalls.
  • Add a README callout in libraries/microsoft-agents-a365-observability-core/README.md pointing 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 include import os, so the example isn’t runnable as-is. Add import os to 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.                          |

Comment thread libraries/microsoft-agents-a365-observability-core/README.md Outdated
Comment thread docs/integrating-with-existing-opentelemetry.md Outdated
Comment thread docs/integrating-with-existing-opentelemetry.md Outdated
Comment thread docs/integrating-with-existing-opentelemetry.md
Comment thread docs/integrating-with-existing-opentelemetry.md
Comment thread docs/integrating-with-existing-opentelemetry.md Outdated
Comment thread docs/integrating-with-existing-opentelemetry.md Outdated
Comment thread docs/integrating-with-existing-opentelemetry.md Outdated
- 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>
@juliomenendez juliomenendez disabled auto-merge May 18, 2026 23:50
@juliomenendez juliomenendez enabled auto-merge (squash) May 18, 2026 23:50
@juliomenendez juliomenendez merged commit 41775eb into main May 18, 2026
9 checks passed
@juliomenendez juliomenendez deleted the docs/integrating-with-existing-opentelemetry branch May 18, 2026 23:57
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.

4 participants