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
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>
| public static readonly GEN_AI_CALLER_AGENT_UPN_KEY = 'gen_ai.caller.agent.upn'; | ||
| public static readonly GEN_AI_CALLER_AGENT_TENANT_ID_KEY = 'gen_ai.caller.agent.tenantid'; | ||
| public static readonly GEN_AI_CALLER_AGENT_NAME_KEY = 'gen_ai.caller.agent.name'; | ||
| public static readonly GEN_AI_CALLER_AGENT_ID_KEY = 'gen_ai.caller.agent.id'; | ||
| public static readonly GEN_AI_CALLER_AGENT_TYPE_KEY = 'gen_ai.caller.agent.type'; | ||
| public static readonly GEN_AI_CALLER_AGENT_APPLICATION_ID_KEY = 'gen_ai.caller.agent.applicationid'; | ||
| public static readonly GEN_AI_CALLER_AGENT_NAME_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.caller.agent.name' : 'gen_ai.caller.agent.name'; | ||
| public static readonly GEN_AI_CALLER_AGENT_ID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.caller.agent.id' : 'gen_ai.caller.agent.id'; | ||
| public static readonly GEN_AI_CALLER_AGENT_TYPE_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.caller.agent.type' : 'gen_ai.caller.agent.type'; | ||
| public static readonly GEN_AI_CALLER_AGENT_APPLICATION_ID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.caller.agent.blueprint.id' : 'gen_ai.caller.agent.applicationid'; | ||
| public static readonly GEN_AI_CALLER_AGENT_CLIENT_IP_KEY = 'gen_ai.caller.agent.user.client.ip'; |
There was a problem hiding this comment.
The caller agent attributes GEN_AI_CALLER_AGENT_UPN_KEY, GEN_AI_CALLER_AGENT_TENANT_ID_KEY, and GEN_AI_CALLER_AGENT_CLIENT_IP_KEY are not updated to use the new microsoft.* namespace when isNewTelemetrySchemaEnabled is true, unlike other caller agent dimensions (name, id, type, application_id, platform_id). This creates inconsistency where some caller agent attributes use the new schema while others remain in the old gen_ai.* namespace. Consider adding conditional mappings for these attributes to maintain consistency across the schema.
| @@ -0,0 +1 @@ | |||
| export const LIB_VERSION = "0.0.0-placeholder"; | |||
There was a problem hiding this comment.
The generated version.ts file is missing the required Microsoft copyright header. All TypeScript source files in the repository should include the copyright header even if they are generated during prebuild. Consider adding the copyright header to the prebuild script output or to a template.
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>
| public static readonly GEN_AI_CALLER_AGENT_ID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.caller.agent.id' : 'gen_ai.caller.agent.id'; | ||
| public static readonly GEN_AI_CALLER_AGENT_TYPE_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.caller.agent.type' : 'gen_ai.caller.agent.type'; | ||
| public static readonly GEN_AI_CALLER_AGENT_APPLICATION_ID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.caller.agent.blueprint.id' : 'gen_ai.caller.agent.applicationid'; | ||
| public static readonly GEN_AI_CALLER_AGENT_CLIENT_IP_KEY = 'gen_ai.caller.agent.user.client.ip'; |
There was a problem hiding this comment.
GEN_AI_CALLER_AGENT_CLIENT_IP_KEY is not schema-switched to the new namespace when isNewTelemetrySchemaEnabled is true, unlike other caller agent attributes. For consistency with the regular caller's client IP mapping (line 84: gen_ai.caller.client.ip → client.address), this should also be mapped to the appropriate new schema attribute name.
| public static readonly GEN_AI_CALLER_AGENT_CLIENT_IP_KEY = 'gen_ai.caller.agent.user.client.ip'; | |
| public static readonly GEN_AI_CALLER_AGENT_CLIENT_IP_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'client.address' : 'gen_ai.caller.agent.user.client.ip'; |
| "module": "dist/esm/index.js", | ||
| "types": "dist/esm/index.d.ts", | ||
| "scripts": { | ||
| "prebuild": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts", |
There was a problem hiding this comment.
The prebuild script generates version.ts without a copyright header. Since the generated file is checked into the repository, the generator should include the Microsoft copyright header. Update the script to prepend the copyright comment before the export statement.
| public static readonly GEN_AI_CALLER_AGENT_UPN_KEY = 'gen_ai.caller.agent.upn'; | ||
| public static readonly GEN_AI_CALLER_AGENT_TENANT_ID_KEY = 'gen_ai.caller.agent.tenantid'; |
There was a problem hiding this comment.
GEN_AI_CALLER_AGENT_UPN_KEY and GEN_AI_CALLER_AGENT_TENANT_ID_KEY are not schema-switched to the new microsoft.* namespace when isNewTelemetrySchemaEnabled is true, unlike other caller agent attributes (GEN_AI_CALLER_AGENT_ID_KEY, GEN_AI_CALLER_AGENT_NAME_KEY, etc.). This creates inconsistent attribute naming when the new schema is enabled. Consider adding conditional mapping for these keys similar to lines 88, 91-94, and 96.
| public static readonly GEN_AI_CALLER_AGENT_UPN_KEY = 'gen_ai.caller.agent.upn'; | |
| public static readonly GEN_AI_CALLER_AGENT_TENANT_ID_KEY = 'gen_ai.caller.agent.tenantid'; | |
| public static readonly GEN_AI_CALLER_AGENT_UPN_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.caller.agent.upn' : 'gen_ai.caller.agent.upn'; | |
| public static readonly GEN_AI_CALLER_AGENT_TENANT_ID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.caller.agent.tenant.id' : 'gen_ai.caller.agent.tenantid'; |
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>
Summary
A365_USE_NEW_TELEMETRY_SCHEMAenv vargen_ai.*attributes tomicrosoft.*namespace when new schema is enabledgen_ai.agent.type,gen_ai.execution.type,correlation.id,hiring.manager.idfrom non-InvokeAgent spans in new schemaoperation.sourcewithtelemetry.sdk.*attributes in new schemagen_ai.agent.thought.processsupport on InferenceScopeCallerDetailsto base scope class (matching .NET SDK pattern)Test plan
A365_USE_NEW_TELEMETRY_SCHEMA=trueto verify new attribute names🤖 Generated with Claude Code