You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4565a80
Browse filesBrowse the repository at this point in the historyBrowse files
|`invoke_agent`|`InvokeAgentScope` (one per user turn) | (root or app) |`invoke_agent <agent_name>` when set, else `invoke_agent`||
96
-
|(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. |
96
+
|`chat` / `text_completion` / `generate_content`|`InferenceScope` (one per LLM call) |`invoke_agent`|`<operation> <model>`| Manual inference scopes use canonical lowercase [OTel GenAI operation names](https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/), matching auto-instrumentation for the corresponding operation. |
97
97
|`execute_tool`|`ExecuteToolScope` (one per tool invocation) |`invoke_agent`|`execute_tool <tool_name>` (always includes the tool name) | Records tool name, args, and result. |
98
98
99
-
Filter your backend by the `gen_ai.operation.name` attribute or by span name. Note that `inference` is *not* the literal attribute value — manual instrumentation produces `Chat` / `TextCompletion` / `GenerateContent` (the `InferenceOperationType.value`), while auto-instrumentation extension packages produce the lowercase OTel-spec form (e.g. `chat`). This casing discrepancy is tracked as an SDK issue.
99
+
Filter your backend by the `gen_ai.operation.name` attribute or by span name.
100
+
`InferenceScope` emits `chat`, `text_completion`, or `generate_content` according
101
+
to the selected `InferenceOperationType`, with span names such as `chat gpt-4`.
102
+
`inference` is not a literal operation value. When upgrading, update case-sensitive
103
+
filters that matched the previous `Chat`, `TextCompletion`, or `GenerateContent`
104
+
values and span-name prefixes, or compare case-insensitively.
100
105
101
106
## Verifying the integration
102
107
@@ -110,7 +115,11 @@ from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExport
Run a single turn. If you see `invoke_agent` / `Chat` (or `chat`) / `execute_tool` JSON dumps on stdout, the SDK is producing spans correctly — the issue is in your backend exporter (network, auth, sampling). If you don't see them, the integration itself is wrong; check the pitfalls below.
118
+
Run a single turn. If you see `invoke_agent`, the inference operation
119
+
(`chat`, `text_completion`, or `generate_content`), and any invoked `execute_tool`
120
+
spans as JSON dumps on stdout, the SDK is producing spans correctly - investigate
121
+
your backend exporter (network, auth, sampling). If expected spans are missing
122
+
from stdout too, check the integration pitfalls below.
Copy file name to clipboardExpand all lines: libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/agent_details.py
+10-1Lines changed: 10 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,9 @@
2
2
# Licensed under the MIT License.
3
3
4
4
fromdataclassesimportdataclass
5
-
fromtypingimportOptional
5
+
fromtypingimportOptional, Union
6
+
7
+
from .models.agent_typeimportAgentType
6
8
7
9
8
10
@dataclass
@@ -41,3 +43,10 @@ class AgentDetails:
41
43
42
44
agent_version: Optional[str] =None
43
45
"""Optional version of the agent (e.g., "1.0.0", "2025-05-01")."""
46
+
47
+
# NOTE: Appended after all pre-existing fields (rather than inserted in the
48
+
# middle) to preserve positional-argument compatibility for existing callers.
49
+
agent_type: Optional[Union[AgentType, str]] =None
50
+
"""Type classification for the agent. Accepts an `AgentType` enum member or
51
+
a raw string; enum members are normalized to their string `.value` when
Copy file name to clipboardExpand all lines: libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/exporters/utils.py
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,12 @@
34
34
# Operation names that identify a span as eligible for export to the Agent 365
35
35
# observability ingest service. Only spans whose gen_ai.operation.name matches
36
36
# one of these values are included; all other spans are filtered out.
37
+
#
38
+
# Inference spans now emit the canonical lowercase operation name for their
Copy file name to clipboardExpand all lines: libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/inference_call_details.py
+21-1Lines changed: 21 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -12,10 +12,30 @@ class InferenceCallDetails:
12
12
"""Details of an inference call for generative AI operations."""
13
13
14
14
operationName: InferenceOperationType
15
-
model: str
15
+
model: str|None
16
16
providerName: str
17
17
inputTokens: int|None=None
18
18
outputTokens: int|None=None
19
19
finishReasons: list[str] |None=None
20
20
thoughtProcess: str|None=None
21
21
endpoint: ServiceEndpoint|None=None
22
+
# NOTE: Appended after all pre-existing fields (rather than inserted in the
23
+
# middle) to preserve positional-argument compatibility for existing callers.
24
+
responseModel: str|None=None
25
+
cacheReadInputTokens: int|None=None
26
+
cacheWriteInputTokens: int|None=None
27
+
28
+
def__post_init__(self) ->None:
29
+
"""Normalize and validate required model identity.
30
+
31
+
Whitespace-only `model`/`responseModel` values are normalized to
32
+
`None` so that validation and downstream consumers (e.g.
33
+
`InferenceScope`) never treat a blank string as a present model.
Copy file name to clipboardExpand all lines: libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/inference_operation_type.py
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -10,3 +10,12 @@ class InferenceOperationType(Enum):
10
10
CHAT="Chat"
11
11
TEXT_COMPLETION="TextCompletion"
12
12
GENERATE_CONTENT="GenerateContent"
13
+
14
+
@property
15
+
defcanonical_name(self) ->str:
16
+
"""The canonical lowercase operation name per the OpenTelemetry GenAI
0 commit comments