Skip to content

Commit f167507

Browse files
jsl517claude
andcommitted
Support new telemetry schema attribute names gated by A365_USE_NEW_TELEMETRY_SCHEMA env var
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4a1ba89 commit f167507

10 files changed

Lines changed: 137 additions & 58 deletions

File tree

packages/agents-a365-observability/src/tracing/constants.ts

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
* OpenTelemetry constants for Agent 365
77
*/
88
export class OpenTelemetryConstants {
9+
// New telemetry schema feature flag
10+
public static readonly USE_NEW_TELEMETRY_SCHEMA_ENV = 'A365_USE_NEW_TELEMETRY_SCHEMA';
11+
// eslint-disable-next-line no-restricted-properties
12+
public static readonly isNewTelemetrySchemaEnabled = process.env['A365_USE_NEW_TELEMETRY_SCHEMA'] === 'true';
13+
914
// Span operation names
1015
public static readonly INVOKE_AGENT_OPERATION_NAME = 'invoke_agent';
1116
public static readonly EXECUTE_TOOL_OPERATION_NAME = 'execute_tool';
@@ -46,9 +51,10 @@ export class OpenTelemetryConstants {
4651
public static readonly GEN_AI_AGENT_NAME_KEY = 'gen_ai.agent.name';
4752
public static readonly GEN_AI_AGENT_TYPE_KEY = 'gen_ai.agent.type';
4853
public static readonly GEN_AI_AGENT_DESCRIPTION_KEY = 'gen_ai.agent.description';
49-
public static readonly GEN_AI_AGENT_PLATFORM_ID_KEY = 'gen_ai.agent.platformid';
54+
public static readonly GEN_AI_AGENT_PLATFORM_ID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.agent.platform.id' : 'gen_ai.agent.platformid';
55+
public static readonly GEN_AI_AGENT_THOUGHT_PROCESS_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.agent.thought.process' : 'gen_ai.agent.thought.process';
5056
public static readonly GEN_AI_CONVERSATION_ID_KEY = 'gen_ai.conversation.id';
51-
public static readonly GEN_AI_CONVERSATION_ITEM_LINK_KEY = 'gen_ai.conversation.item.link';
57+
public static readonly GEN_AI_CONVERSATION_ITEM_LINK_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.conversation.item.link' : 'gen_ai.conversation.item.link';
5258
public static readonly GEN_AI_TOKEN_TYPE_KEY = 'gen_ai.token.type';
5359
public static readonly GEN_AI_USAGE_INPUT_TOKENS_KEY = 'gen_ai.usage.input_tokens';
5460
public static readonly GEN_AI_USAGE_OUTPUT_TOKENS_KEY = 'gen_ai.usage.output_tokens';
@@ -69,36 +75,36 @@ export class OpenTelemetryConstants {
6975
public static readonly GEN_AI_TOOL_TYPE_KEY = 'gen_ai.tool.type';
7076

7177
// Agent user (user tied to agent instance during creation) or caller dimensions
72-
public static readonly GEN_AI_AGENT_USER_ID_KEY = 'gen_ai.agent.userid';
78+
public static readonly GEN_AI_AGENT_USER_ID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.agent.user.id' : 'gen_ai.agent.userid';
7379
public static readonly GEN_AI_CALLER_TENANT_ID_KEY = 'gen_ai.caller.tenantid';
74-
public static readonly GEN_AI_CALLER_ID_KEY = 'gen_ai.caller.id';
75-
public static readonly GEN_AI_CALLER_NAME_KEY = 'gen_ai.caller.name';
76-
public static readonly GEN_AI_CALLER_UPN_KEY = 'gen_ai.caller.upn';
77-
public static readonly GEN_AI_CALLER_CLIENT_IP_KEY = 'gen_ai.caller.client.ip';
80+
public static readonly GEN_AI_CALLER_ID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.caller.id' : 'gen_ai.caller.id';
81+
public static readonly GEN_AI_CALLER_NAME_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.caller.name' : 'gen_ai.caller.name';
82+
public static readonly GEN_AI_CALLER_UPN_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.caller.upn' : 'gen_ai.caller.upn';
83+
public static readonly GEN_AI_CALLER_CLIENT_IP_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'client.address' : 'gen_ai.caller.client.ip';
7884

7985
// Agent to Agent caller agent dimensions
80-
public static readonly GEN_AI_CALLER_AGENT_USER_ID_KEY = 'gen_ai.caller.agent.userid';
86+
public static readonly GEN_AI_CALLER_AGENT_USER_ID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.caller.agent.user.id' : 'gen_ai.caller.agent.userid';
8187
public static readonly GEN_AI_CALLER_AGENT_UPN_KEY = 'gen_ai.caller.agent.upn';
8288
public static readonly GEN_AI_CALLER_AGENT_TENANT_ID_KEY = 'gen_ai.caller.agent.tenantid';
83-
public static readonly GEN_AI_CALLER_AGENT_NAME_KEY = 'gen_ai.caller.agent.name';
84-
public static readonly GEN_AI_CALLER_AGENT_ID_KEY = 'gen_ai.caller.agent.id';
85-
public static readonly GEN_AI_CALLER_AGENT_TYPE_KEY = 'gen_ai.caller.agent.type';
86-
public static readonly GEN_AI_CALLER_AGENT_APPLICATION_ID_KEY = 'gen_ai.caller.agent.applicationid';
89+
public static readonly GEN_AI_CALLER_AGENT_NAME_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.caller.agent.name' : 'gen_ai.caller.agent.name';
90+
public static readonly GEN_AI_CALLER_AGENT_ID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.caller.agent.id' : 'gen_ai.caller.agent.id';
91+
public static readonly GEN_AI_CALLER_AGENT_TYPE_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.caller.agent.type' : 'gen_ai.caller.agent.type';
92+
public static readonly GEN_AI_CALLER_AGENT_APPLICATION_ID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.caller.agent.blueprint.id' : 'gen_ai.caller.agent.applicationid';
8793
public static readonly GEN_AI_CALLER_AGENT_CLIENT_IP_KEY = 'gen_ai.caller.agent.user.client.ip';
88-
public static readonly GEN_AI_CALLER_AGENT_PLATFORM_ID_KEY = 'gen_ai.caller.agent.platformid';
94+
public static readonly GEN_AI_CALLER_AGENT_PLATFORM_ID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.caller.agent.platform.id' : 'gen_ai.caller.agent.platformid';
8995
// Agent-specific dimensions
9096
public static readonly AGENT_ID_KEY = 'gen_ai.agent.id';
9197
public static readonly GEN_AI_TASK_ID_KEY = 'gen_ai.task.id';
92-
public static readonly SESSION_ID_KEY = 'session.id';
93-
public static readonly SESSION_DESCRIPTION_KEY = 'session.description';
98+
public static readonly SESSION_ID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.session.id' : 'session.id';
99+
public static readonly SESSION_DESCRIPTION_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.session.description' : 'session.description';
94100
public static readonly GEN_AI_ICON_URI_KEY = 'gen_ai.agent365.icon_uri';
95-
public static readonly TENANT_ID_KEY = 'tenant.id';
101+
public static readonly TENANT_ID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.tenant.id' : 'tenant.id';
96102

97103
// Baggage keys
98104
public static readonly OPERATION_SOURCE_KEY = 'operation.source';
99-
public static readonly GEN_AI_AGENT_AUID_KEY = 'gen_ai.agent.user.id';
100-
public static readonly GEN_AI_AGENT_UPN_KEY = 'gen_ai.agent.upn';
101-
public static readonly GEN_AI_AGENT_BLUEPRINT_ID_KEY = 'gen_ai.agent.applicationid';
105+
public static readonly GEN_AI_AGENT_AUID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.a365.agent.user.id' : 'gen_ai.agent.user.id';
106+
public static readonly GEN_AI_AGENT_UPN_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.agent.user.upn' : 'gen_ai.agent.upn';
107+
public static readonly GEN_AI_AGENT_BLUEPRINT_ID_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.agent.blueprint.id' : 'gen_ai.agent.applicationid';
102108
public static readonly CORRELATION_ID_KEY = 'correlation.id';
103109
public static readonly HIRING_MANAGER_ID_KEY = 'hiring.manager.id';
104110

@@ -108,12 +114,20 @@ export class OpenTelemetryConstants {
108114

109115
// Source metadata dimensions
110116
public static readonly GEN_AI_EXECUTION_SOURCE_ID_KEY = 'gen_ai.execution.sourceMetadata.id';
111-
public static readonly GEN_AI_EXECUTION_SOURCE_NAME_KEY = 'gen_ai.channel.name';
112-
public static readonly GEN_AI_EXECUTION_SOURCE_DESCRIPTION_KEY = 'gen_ai.channel.link';
117+
public static readonly GEN_AI_EXECUTION_SOURCE_NAME_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.channel.name' : 'gen_ai.channel.name';
118+
public static readonly GEN_AI_EXECUTION_SOURCE_DESCRIPTION_KEY = OpenTelemetryConstants.isNewTelemetrySchemaEnabled ? 'microsoft.channel.link' : 'gen_ai.channel.link';
113119

114120
// Custom parent id and parent name key
115121
public static readonly CUSTOM_PARENT_SPAN_ID_KEY = 'custom.parent.span.id';
116122
public static readonly CUSTOM_SPAN_NAME_KEY = 'custom.span.name';
123+
124+
// Telemetry SDK attributes (replace operation.source when isNewTelemetrySchemaEnabled)
125+
public static readonly TELEMETRY_SDK_NAME_KEY = 'telemetry.sdk.name';
126+
public static readonly TELEMETRY_SDK_LANGUAGE_KEY = 'telemetry.sdk.language';
127+
public static readonly TELEMETRY_SDK_VERSION_KEY = 'telemetry.sdk.version';
128+
public static readonly TELEMETRY_SDK_NAME_VALUE = 'Agent365Sdk';
129+
public static readonly TELEMETRY_SDK_LANGUAGE_VALUE = 'nodejs';
130+
public static readonly TELEMETRY_SDK_VERSION_VALUE = '0.0.0-placeholder';
117131
}
118132

119133
/**

packages/agents-a365-observability/src/tracing/contracts.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ export interface InferenceDetails {
236236

237237
/** Response ID from the model provider */
238238
responseId?: string;
239+
240+
/** The thought process used by the agent */
241+
thoughtProcess?: string;
239242
}
240243

241244
/**

packages/agents-a365-observability/src/tracing/middleware/BaggageBuilder.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ export class BaggageBuilder {
9595
* @returns Self for method chaining
9696
*/
9797
correlationId(value: string | null | undefined): BaggageBuilder {
98-
this.set(OpenTelemetryConstants.CORRELATION_ID_KEY, value);
98+
if (!OpenTelemetryConstants.isNewTelemetrySchemaEnabled) {
99+
this.set(OpenTelemetryConstants.CORRELATION_ID_KEY, value);
100+
}
99101
return this;
100102
}
101103

@@ -125,7 +127,9 @@ export class BaggageBuilder {
125127
* @returns Self for method chaining
126128
*/
127129
hiringManagerId(value: string | null | undefined): BaggageBuilder {
128-
this.set(OpenTelemetryConstants.HIRING_MANAGER_ID_KEY, value);
130+
if (!OpenTelemetryConstants.isNewTelemetrySchemaEnabled) {
131+
this.set(OpenTelemetryConstants.HIRING_MANAGER_ID_KEY, value);
132+
}
129133
return this;
130134
}
131135

packages/agents-a365-observability/src/tracing/processors/SpanProcessor.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ export class SpanProcessor implements BaseSpanProcessor {
6969
INVOKE_AGENT_ATTRIBUTES.forEach(key => targetKeys.add(key));
7070
}
7171

72-
// Set operation source - coalesce baggage value with SDK default
73-
if (!existingAttrs.has(OpenTelemetryConstants.OPERATION_SOURCE_KEY)) {
72+
// Set operation source or telemetry SDK attributes
73+
if (OpenTelemetryConstants.isNewTelemetrySchemaEnabled) {
74+
span.setAttribute(OpenTelemetryConstants.TELEMETRY_SDK_NAME_KEY, OpenTelemetryConstants.TELEMETRY_SDK_NAME_VALUE);
75+
span.setAttribute(OpenTelemetryConstants.TELEMETRY_SDK_LANGUAGE_KEY, OpenTelemetryConstants.TELEMETRY_SDK_LANGUAGE_VALUE);
76+
span.setAttribute(OpenTelemetryConstants.TELEMETRY_SDK_VERSION_KEY, OpenTelemetryConstants.TELEMETRY_SDK_VERSION_VALUE);
77+
} else if (!existingAttrs.has(OpenTelemetryConstants.OPERATION_SOURCE_KEY)) {
7478
const operationSource =
7579
baggageMap.get(OpenTelemetryConstants.OPERATION_SOURCE_KEY) ||
7680
OperationSource.SDK;

packages/agents-a365-observability/src/tracing/processors/util.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ export const GENERIC_ATTRIBUTES: readonly string[] = [
1111
consts.TENANT_ID_KEY,
1212
consts.CUSTOM_PARENT_SPAN_ID_KEY,
1313
consts.CUSTOM_SPAN_NAME_KEY,
14-
consts.CORRELATION_ID_KEY,
14+
...(consts.isNewTelemetrySchemaEnabled ? [] : [consts.CORRELATION_ID_KEY]),
1515
consts.SESSION_ID_KEY,
1616
consts.GEN_AI_CONVERSATION_ID_KEY,
1717
consts.GEN_AI_CONVERSATION_ITEM_LINK_KEY,
1818
consts.GEN_AI_OPERATION_NAME_KEY,
1919
consts.GEN_AI_AGENT_ID_KEY,
2020
consts.GEN_AI_AGENT_NAME_KEY,
21-
consts.GEN_AI_AGENT_TYPE_KEY,
21+
...(consts.isNewTelemetrySchemaEnabled ? [] : [consts.GEN_AI_AGENT_TYPE_KEY]),
2222
consts.GEN_AI_AGENT_DESCRIPTION_KEY,
2323
consts.SESSION_DESCRIPTION_KEY,
2424
consts.GEN_AI_AGENT_USER_ID_KEY,
2525
consts.GEN_AI_AGENT_UPN_KEY,
26-
consts.GEN_AI_AGENT_BLUEPRINT_ID_KEY,
26+
...(consts.isNewTelemetrySchemaEnabled ? [] : [consts.GEN_AI_AGENT_BLUEPRINT_ID_KEY]),
2727
consts.GEN_AI_AGENT_AUID_KEY,
2828
consts.GEN_AI_AGENT_PLATFORM_ID_KEY,
2929
];
@@ -49,8 +49,10 @@ export const INVOKE_AGENT_ATTRIBUTES: readonly string[] = [
4949
consts.GEN_AI_CALLER_AGENT_CLIENT_IP_KEY,
5050
consts.GEN_AI_CALLER_AGENT_PLATFORM_ID_KEY,
5151
// Execution context
52-
consts.GEN_AI_EXECUTION_TYPE_KEY,
52+
...(consts.isNewTelemetrySchemaEnabled ? [] : [consts.GEN_AI_EXECUTION_TYPE_KEY]),
5353
consts.GEN_AI_EXECUTION_SOURCE_ID_KEY,
5454
consts.GEN_AI_EXECUTION_SOURCE_NAME_KEY,
5555
consts.GEN_AI_EXECUTION_SOURCE_DESCRIPTION_KEY,
56+
// New schema: agent type and blueprint ID are InvokeAgent-only
57+
...(consts.isNewTelemetrySchemaEnabled ? [consts.GEN_AI_AGENT_TYPE_KEY, consts.GEN_AI_AGENT_BLUEPRINT_ID_KEY] : []),
5658
];

packages/agents-a365-observability/src/tracing/scopes/ExecuteToolScope.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { SpanKind, TimeInput } from '@opentelemetry/api';
55
import { OpenTelemetryScope } from './OpenTelemetryScope';
6-
import { ToolCallDetails, AgentDetails, TenantDetails, SourceMetadata } from '../contracts';
6+
import { ToolCallDetails, AgentDetails, TenantDetails, SourceMetadata, CallerDetails } from '../contracts';
77
import { ParentContext } from '../context/trace-context-propagation';
88
import { OpenTelemetryConstants } from '../constants';
99

@@ -24,6 +24,7 @@ export class ExecuteToolScope extends OpenTelemetryScope {
2424
* tool call after execution has already completed.
2525
* @param endTime Optional explicit end time (ms epoch, Date, or HrTime). When provided, the span will
2626
* use this timestamp when disposed instead of the current wall-clock time.
27+
* @param callerDetails Optional caller details.
2728
* @returns A new ExecuteToolScope instance.
2829
*/
2930
public static start(
@@ -34,9 +35,10 @@ export class ExecuteToolScope extends OpenTelemetryScope {
3435
sourceMetadata?: Pick<SourceMetadata, "name" | "description">,
3536
parentContext?: ParentContext,
3637
startTime?: TimeInput,
37-
endTime?: TimeInput
38+
endTime?: TimeInput,
39+
callerDetails?: CallerDetails
3840
): ExecuteToolScope {
39-
return new ExecuteToolScope(details, agentDetails, tenantDetails, conversationId, sourceMetadata, parentContext, startTime, endTime);
41+
return new ExecuteToolScope(details, agentDetails, tenantDetails, conversationId, sourceMetadata, parentContext, startTime, endTime, callerDetails);
4042
}
4143

4244
private constructor(
@@ -47,7 +49,8 @@ export class ExecuteToolScope extends OpenTelemetryScope {
4749
sourceMetadata?: Pick<SourceMetadata, "name" | "description">,
4850
parentContext?: ParentContext,
4951
startTime?: TimeInput,
50-
endTime?: TimeInput
52+
endTime?: TimeInput,
53+
callerDetails?: CallerDetails
5154
) {
5255
super(
5356
SpanKind.INTERNAL,
@@ -57,7 +60,8 @@ export class ExecuteToolScope extends OpenTelemetryScope {
5760
tenantDetails,
5861
parentContext,
5962
startTime,
60-
endTime
63+
endTime,
64+
callerDetails
6165
);
6266

6367
// Destructure the details object to match C# pattern

packages/agents-a365-observability/src/tracing/scopes/InferenceScope.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
InferenceDetails,
99
AgentDetails,
1010
TenantDetails,
11-
SourceMetadata
11+
SourceMetadata,
12+
CallerDetails
1213
} from '../contracts';
1314
import { ParentContext } from '../context/trace-context-propagation';
1415

@@ -27,6 +28,7 @@ export class InferenceScope extends OpenTelemetryScope {
2728
* Accepts a ParentSpanRef (manual traceId/spanId) or an OTel Context (e.g. from extractTraceContext).
2829
* @param startTime Optional explicit start time (ms epoch, Date, or HrTime).
2930
* @param endTime Optional explicit end time (ms epoch, Date, or HrTime).
31+
* @param callerDetails Optional caller details.
3032
* @returns A new InferenceScope instance
3133
*/
3234
public static start(
@@ -37,9 +39,10 @@ export class InferenceScope extends OpenTelemetryScope {
3739
sourceMetadata?: Pick<SourceMetadata, "name" | "description">,
3840
parentContext?: ParentContext,
3941
startTime?: TimeInput,
40-
endTime?: TimeInput
42+
endTime?: TimeInput,
43+
callerDetails?: CallerDetails
4144
): InferenceScope {
42-
return new InferenceScope(details, agentDetails, tenantDetails, conversationId, sourceMetadata, parentContext, startTime, endTime);
45+
return new InferenceScope(details, agentDetails, tenantDetails, conversationId, sourceMetadata, parentContext, startTime, endTime, callerDetails);
4346
}
4447

4548
private constructor(
@@ -50,7 +53,8 @@ export class InferenceScope extends OpenTelemetryScope {
5053
sourceMetadata?: Pick<SourceMetadata, "name" | "description">,
5154
parentContext?: ParentContext,
5255
startTime?: TimeInput,
53-
endTime?: TimeInput
56+
endTime?: TimeInput,
57+
callerDetails?: CallerDetails
5458
) {
5559
super(
5660
SpanKind.CLIENT,
@@ -60,7 +64,8 @@ export class InferenceScope extends OpenTelemetryScope {
6064
tenantDetails,
6165
parentContext,
6266
startTime,
63-
endTime
67+
endTime,
68+
callerDetails
6469
);
6570

6671
// Set core inference information matching C# implementation
@@ -71,9 +76,10 @@ export class InferenceScope extends OpenTelemetryScope {
7176
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_USAGE_OUTPUT_TOKENS_KEY, details.outputTokens?.toString());
7277
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_RESPONSE_FINISH_REASONS_KEY, details.finishReasons?.join(','));
7378
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_RESPONSE_ID_KEY, details.responseId);
79+
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_AGENT_THOUGHT_PROCESS_KEY, details.thoughtProcess);
7480
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_CONVERSATION_ID_KEY, conversationId);
7581
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_EXECUTION_SOURCE_NAME_KEY, sourceMetadata?.name);
76-
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_EXECUTION_SOURCE_DESCRIPTION_KEY, sourceMetadata?.description);
82+
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_EXECUTION_SOURCE_DESCRIPTION_KEY, sourceMetadata?.description);
7783
}
7884

7985
/**

packages/agents-a365-observability/src/tracing/scopes/InvokeAgentScope.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,19 @@ export class InvokeAgentScope extends OpenTelemetryScope {
5959
tenantDetails,
6060
parentContext,
6161
startTime,
62-
endTime
62+
endTime,
63+
callerDetails
6364
);
6465

6566
// Set session ID and endpoint information
6667
this.setTagMaybe(OpenTelemetryConstants.SESSION_ID_KEY, invokeAgentDetails.sessionId);
6768

69+
// New schema: agent type and blueprint ID are InvokeAgent-only (base class skips them)
70+
if (OpenTelemetryConstants.isNewTelemetrySchemaEnabled) {
71+
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_AGENT_TYPE_KEY, invokeAgentDetails.agentType);
72+
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_AGENT_BLUEPRINT_ID_KEY, invokeAgentDetails.agentBlueprintId);
73+
}
74+
6875
if (invokeAgentDetails.endpoint) {
6976
this.setTagMaybe(OpenTelemetryConstants.SERVER_ADDRESS_KEY, invokeAgentDetails.endpoint.host);
7077

@@ -77,7 +84,8 @@ export class InvokeAgentScope extends OpenTelemetryScope {
7784
// Set request-related tags
7885
const requestToUse = invokeAgentDetails.request;
7986
if (requestToUse) {
80-
if (requestToUse.executionType) {
87+
// gen_ai.execution.type is removed in new schema
88+
if (!OpenTelemetryConstants.isNewTelemetrySchemaEnabled && requestToUse.executionType) {
8189
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_EXECUTION_TYPE_KEY, requestToUse.executionType.toString());
8290
}
8391
if (requestToUse.sourceMetadata) {
@@ -89,15 +97,6 @@ export class InvokeAgentScope extends OpenTelemetryScope {
8997

9098
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_CONVERSATION_ID_KEY, invokeAgentDetails.conversationId);
9199

92-
// Set caller details tags
93-
if (callerDetails) {
94-
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_CALLER_ID_KEY, callerDetails.callerId);
95-
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_CALLER_UPN_KEY, callerDetails.callerUpn);
96-
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_CALLER_NAME_KEY, callerDetails.callerName);
97-
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_CALLER_TENANT_ID_KEY, callerDetails.tenantId);
98-
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_CALLER_CLIENT_IP_KEY, callerDetails.callerClientIp);
99-
}
100-
101100
// Set caller agent details tags
102101
if (callerAgentDetails) {
103102
this.setTagMaybe(OpenTelemetryConstants.GEN_AI_CALLER_AGENT_NAME_KEY, callerAgentDetails.agentName);

0 commit comments

Comments
 (0)