Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for a new telemetry attribute schema (gated behind A365_USE_NEW_TELEMETRY_SCHEMA) in the observability SDK by renaming/selectively emitting span/baggage attributes and introducing caller metadata propagation into base scopes.
Changes:
- Add
CallerDetailssupport inOpenTelemetryScopeand plumb it throughExecuteToolScope,InferenceScope, andInvokeAgentScope. - Gate/adjust exported attributes for the new schema (e.g., removing some legacy dimensions; switching to
telemetry.sdk.*attributes). - Extend inference telemetry with
thoughtProcessand add/expand unit tests around caller tagging.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/observability/core/scopes.test.ts | Adds assertions that caller tags are applied for ExecuteTool/Inference scopes. |
| packages/agents-a365-observability/src/tracing/scopes/OpenTelemetryScope.ts | Adds callerDetails param and applies caller tags in the base scope. |
| packages/agents-a365-observability/src/tracing/scopes/InvokeAgentScope.ts | Routes callerDetails into base scope; handles InvokeAgent-only attrs in new schema. |
| packages/agents-a365-observability/src/tracing/scopes/InferenceScope.ts | Plumbs callerDetails; adds gen_ai.agent.thought.process tagging. |
| packages/agents-a365-observability/src/tracing/scopes/ExecuteToolScope.ts | Plumbs callerDetails into scope creation. |
| packages/agents-a365-observability/src/tracing/processors/util.ts | Gates which baggage keys are copied into span attrs depending on schema. |
| packages/agents-a365-observability/src/tracing/processors/SpanProcessor.ts | Switches from operation.source to telemetry.sdk.* attributes under new schema. |
| packages/agents-a365-observability/src/tracing/middleware/BaggageBuilder.ts | Stops emitting correlation/hiring-manager baggage keys in new schema. |
| packages/agents-a365-observability/src/tracing/contracts.ts | Adds InferenceDetails.thoughtProcess. |
| packages/agents-a365-observability/src/tracing/constants.ts | Introduces schema flag and conditional key renames/new constants. |
packages/agents-a365-observability/src/tracing/processors/SpanProcessor.ts
Outdated
Show resolved
Hide resolved
f167507 to
203104a
Compare
203104a to
6eee457
Compare
…LEMETRY_SCHEMA env var Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6eee457 to
7564849
Compare
Add prebuild script to generate src/version.ts from package.json (same pattern as agents-a365-runtime) so the telemetry SDK version stays correct automatically instead of being hardcoded. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use jest.isolateModules to validate raw old/new schema key strings for caller attributes, catching regressions in constant definitions regardless of which schema is active at runtime. Also skip GEN_AI_AGENT_USER_ID_KEY from GENERIC_ATTRIBUTES in new schema to avoid duplicate propagation (collides with GEN_AI_AGENT_AUID_KEY). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… agent keys - Restore GEN_AI_CALLER_TENANT_ID_KEY and wire it through base scope, INVOKE_AGENT_ATTRIBUTES, and TurnContextUtils baggage pairs - Add isolated-module tests validating caller agent key schema mappings - Skip GEN_AI_AGENT_USER_ID_KEY from GENERIC_ATTRIBUTES in new schema to avoid duplicate propagation with GEN_AI_AGENT_AUID_KEY Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This constant duplicated GEN_AI_AGENT_AUID_KEY functionality. The .NET SDK uses gen_ai.agent.userid as GenAiAgentAUIDKey, so only GEN_AI_AGENT_AUID_KEY is needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- TELEMETRY_SDK_NAME_VALUE: Agent365Sdk → A365ObservabilitySDK - GEN_AI_AGENT_AUID_KEY: microsoft.a365.agent.user.id → microsoft.agent.user.id - GEN_AI_AGENT_BLUEPRINT_ID_KEY: microsoft.agent.blueprint.id → microsoft.a365.agent.blueprint.id Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
nikhilNava
left a comment
There was a problem hiding this comment.
Thanks for putting this together, can you post the generated post body by the SDK for easy review?
Also please share the post body with Akhil and Jason to help with service implementation
packages/agents-a365-observability/src/tracing/middleware/BaggageBuilder.ts
Outdated
Show resolved
Hide resolved
packages/agents-a365-observability/src/tracing/processors/SpanProcessor.ts
Outdated
Show resolved
Hide resolved
….call.result, remove GEN_AI_EXECUTION_SOURCE_ID_KEY, add server.address/port to InferenceScope - Remove GEN_AI_RESPONSE_ID_KEY constant and all responseId references from InferenceScope, contracts, extensions-openai, and samples - Rename gen_ai.event.content to gen_ai.tool.call.result for GEN_AI_EVENT_CONTENT and GEN_AI_TOOL_CALL_RESULT_KEY constants - Remove GEN_AI_EXECUTION_SOURCE_ID_KEY from constants, util.ts, InvokeAgentScope, and BaggageBuilder.sourceMetadataId() - Add endpoint (server.address/server.port) support to InferenceScope and InferenceDetails contract - Update capture-post-body sample and agent.ts samples - Update all affected tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
48679f9 to
a083413
Compare
packages/agents-a365-observability/src/tracing/scopes/OpenTelemetryScope.ts
Show resolved
Hide resolved
packages/agents-a365-observability/src/tracing/scopes/OpenTelemetryScope.ts
Show resolved
Hide resolved
packages/agents-a365-observability/src/tracing/scopes/InvokeAgentScope.ts
Show resolved
Hide resolved
packages/agents-a365-observability-hosting/src/utils/TurnContextUtils.ts
Outdated
Show resolved
Hide resolved
packages/agents-a365-observability/src/tracing/scopes/OpenTelemetryScope.ts
Show resolved
Hide resolved
packages/agents-a365-observability/src/tracing/scopes/OpenTelemetryScope.ts
Outdated
Show resolved
Hide resolved
packages/agents-a365-observability/src/tracing/middleware/BaggageBuilder.ts
Show resolved
Hide resolved
| * @param correlationId The correlation ID | ||
| * @returns A context manager that restores the previous baggage on exit | ||
| */ | ||
| static setRequestContext( |
There was a problem hiding this comment.
This method can be removed as it doesnt do much. developer will have to use other setters anyway
There was a problem hiding this comment.
It is also used in dotnet.
packages/agents-a365-observability/src/tracing/scopes/OpenTelemetryScope.ts
Outdated
Show resolved
Hide resolved
…oviderName to AgentDetails Remove hardcoded gen_ai.provider.name from OpenTelemetryScope base class. Set it dynamically in InvokeAgentScope from AgentDetails.providerName, matching InferenceScope which already uses InferenceDetails.providerName. ExecuteTool spans no longer emit gen_ai.provider.name. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
packages/agents-a365-observability/src/tracing/scopes/InvokeAgentScope.ts
Outdated
Show resolved
Hide resolved
packages/agents-a365-observability/src/tracing/scopes/OpenTelemetryScope.ts
Show resolved
Hide resolved
packages/agents-a365-observability/src/tracing/middleware/BaggageBuilder.ts
Show resolved
Hide resolved
packages/agents-a365-observability/src/tracing/processors/SpanProcessor.ts
Show resolved
Hide resolved
- Fix OutputScope: rename old schema constants (GEN_AI_EXECUTION_SOURCE_* to CHANNEL_*, remove GEN_AI_CALLER_TENANT_ID_KEY, remove executionType param) - Fix scope-utils tests: use new schema attribute names, update input message format to match JSON.stringify change from main - Fix output-scope test: adjust for removed executionType parameter - Fix output-logging-middleware and baggage-middleware tests: use CHANNEL_NAME_KEY Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…eneric attributes, add callerDetails JSDoc Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
packages/agents-a365-observability/src/tracing/scopes/OutputScope.ts
Outdated
Show resolved
Hide resolved
packages/agents-a365-observability/src/tracing/scopes/OutputScope.ts
Outdated
Show resolved
Hide resolved
…remove dead code, fix copyright headers and stale JSDoc - OutputScope: pass callerDetails to super() instead of manual caller tagging - OutputScope: fix JSDoc removing stale "tenant" from callerDetails description - OpenTelemetryScope: remove unused finalTags variable and exception field - OpenTelemetryScope: remove unused Attributes import - TurnContextUtils: fix stale JSDoc mentioning tenant in getCallerBaggagePairs - constants.ts: remove misleading "server spans only" comment on SERVICE_NAME_KEY - Fix copyright headers in contracts.ts, BaggageBuilder.ts, OpenAIAgentsTraceProcessor.ts, Utils.ts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 28 out of 28 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
packages/agents-a365-observability-hosting/src/utils/TurnContextUtils.ts:27
if (!turnContext|| !turnContext.activity?.from)is missing whitespace around the||operator (and has a trailing space before{). This is likely to violate the repo's formatting/lint rules and should be fixed to keep CI lint clean.
if (!turnContext|| !turnContext.activity?.from) {
return [];
…hannelLink Address nikhilNava review: rename methods to match schema naming convention. Also update design doc to reflect new method names and attribute keys. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reverting to sourceMetadataName/sourceMetadataDescription — the full sourceMetadata→channel rename will be done in a follow-up PR. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
packages/agents-a365-observability/src/tracing/middleware/BaggageBuilder.ts
Show resolved
Hide resolved
Resolve conflicts by merging both feature branches: - Add both callerDetails (feature) and spanKind (main) parameters to ExecuteToolScope - Fix removed GEN_AI_EVENT_CONTENT constant, replace with GEN_AI_TOOL_CALL_RESULT_KEY - Update ScopeUtils to pass both parameters (callerDetails as undefined for now) - Update all test signatures to match new parameter order All tests passing (1070 tests). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2937802 to
48f26f2
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 30 out of 31 changed files in this pull request and generated 1 comment.
You can also share your feedback on Copilot code review. Take the survey.
packages/agents-a365-observability-hosting/src/utils/TurnContextUtils.ts
Outdated
Show resolved
Hide resolved
Breaking changes: - Migrate human caller attributes to OTel standard (user.*, client.*) - Migrate agent attributes to microsoft.agent.* namespace - Migrate A2A caller attributes to microsoft.a365.caller.agent.* namespace - Fix bug: Use CALLER_AGENT_BLUEPRINT_ID_KEY for caller's blueprint ID - Update CHANGELOG.md with comprehensive breaking changes documentation - Update all tests to use new constant names Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
A365 Telemetry Schema Migration
This PR implements the A365 Observability Schema migration, aligning attribute names with OpenTelemetry semantic conventions and the official Microsoft A365 schema.
Breaking Changes
Human Caller Attributes (Now OTel Standard)
Human caller attributes now use OpenTelemetry standard semantic conventions:
GEN_AI_CALLER_ID_KEY→USER_ID_KEY(user.id)GEN_AI_CALLER_NAME_KEY→USER_NAME_KEY(user.name)GEN_AI_CALLER_UPN_KEY→USER_EMAIL_KEY(user.email)GEN_AI_CALLER_CLIENT_IP_KEY→CLIENT_ADDRESS_KEY(client.address)Agent Identity Attributes
Agent attributes now use the
microsoft.agent.*namespace:GEN_AI_AGENT_AUID_KEY→AGENT_USER_ID_KEY(microsoft.agent.user.id)GEN_AI_AGENT_UPN_KEY→AGENT_EMAIL_KEY(microsoft.agent.user.email)GEN_AI_AGENT_BLUEPRINT_ID_KEY→AGENT_BLUEPRINT_ID_KEY(microsoft.a365.agent.blueprint.id)Agent-to-Agent Caller Attributes
Caller agent attributes now use the
microsoft.a365.caller.agent.*namespace:GEN_AI_CALLER_AGENT_USER_ID_KEY→CALLER_AGENT_USER_ID_KEY(microsoft.a365.caller.agent.user.id)GEN_AI_CALLER_AGENT_UPN_KEY→CALLER_AGENT_EMAIL_KEY(microsoft.a365.caller.agent.user.email)GEN_AI_CALLER_AGENT_NAME_KEY→CALLER_AGENT_NAME_KEY(microsoft.a365.caller.agent.name)GEN_AI_CALLER_AGENT_ID_KEY→CALLER_AGENT_ID_KEY(microsoft.a365.caller.agent.id)GEN_AI_CALLER_AGENT_APPLICATION_ID_KEY→CALLER_AGENT_BLUEPRINT_ID_KEY(microsoft.a365.caller.agent.blueprint.id)GEN_AI_CALLER_AGENT_PLATFORM_ID_KEY→CALLER_AGENT_PLATFORM_ID_KEY(microsoft.a365.caller.agent.platform.id)Migration Impact
All code using the old constant names must be updated to use the new names. The attribute values now follow:
user.*,client.*)microsoft.agent.*,microsoft.a365.*)Example Output
Before (Old Schema)
{ "microsoft.caller.id": "user-123", "microsoft.caller.name": "John Doe", "microsoft.caller.upn": "john@contoso.com", "microsoft.caller.client.ip": "192.168.1.1", "gen_ai.agent.auid": "agent-456", "gen_ai.agent.upn": "agent@contoso.com" }After (New Schema - OTel Standard)
{ "user.id": "user-123", "user.name": "John Doe", "user.email": "john@contoso.com", "client.address": "192.168.1.1", "microsoft.agent.user.id": "agent-456", "microsoft.agent.user.email": "agent@contoso.com", "microsoft.a365.agent.blueprint.id": "blueprint-789" }Testing
CALLER_AGENT_BLUEPRINT_ID_KEY)Related Issues
Aligns with the official A365 Observability Schema and OpenTelemetry semantic conventions.