Skip to content

Commit f495f73

Browse files
add agent version
1 parent 9d5b744 commit f495f73

File tree

6 files changed

+30
-3
lines changed

6 files changed

+30
-3
lines changed

src/Observability/Runtime/Common/BaggageBuilder.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ public BaggageBuilder AgentDescription(string? v)
107107
return this;
108108
}
109109

110+
/// <summary>
111+
/// Sets the agent version baggage value.
112+
/// </summary>
113+
public BaggageBuilder AgentVersion(string? v)
114+
{
115+
Set(OpenTelemetryConstants.GenAiAgentVersionKey, v);
116+
return this;
117+
}
118+
110119
/// <summary>
111120
/// Sets the agentic user ID baggage value.
112121
/// </summary>

src/Observability/Runtime/Tracing/Contracts/AgentDetails.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class AgentDetails : IEquatable<AgentDetails>
2525
/// <param name="agentClientIP">Optional client IP address of the agent.</param>
2626
/// <param name="agentPlatformId">Optional platform ID for the agent.</param>
2727
/// <param name="providerName">Optional provider name (e.g., openai, anthropic).</param>
28+
/// <param name="agentVersion">Optional version of the agent (e.g., "1.0.0", "2025-05-01").</param>
2829
/// <remarks>
2930
/// <para>
3031
/// <b>Certification Requirements:</b> The following parameters must be set for the agent to pass certification requirements, and these values override any of the same values specified in the <see cref="Microsoft.Agents.A365.Observability.Runtime.Common.BaggageBuilder"/> class:
@@ -55,7 +56,8 @@ public AgentDetails(
5556
AgentType? agentType = null,
5657
IPAddress? agentClientIP = null,
5758
string? agentPlatformId = null,
58-
string? providerName = null)
59+
string? providerName = null,
60+
string? agentVersion = null)
5961
{
6062
AgentId = agentId;
6163
AgentName = agentName;
@@ -68,6 +70,7 @@ public AgentDetails(
6870
AgentClientIP = agentClientIP;
6971
AgentPlatformId = agentPlatformId;
7072
ProviderName = providerName;
73+
AgentVersion = agentVersion;
7174
}
7275

7376
/// <summary>
@@ -125,6 +128,11 @@ public AgentDetails(
125128
/// </summary>
126129
public string? ProviderName { get; }
127130

131+
/// <summary>
132+
/// Optional version of the agent (e.g., "1.0.0", "2025-05-01").
133+
/// </summary>
134+
public string? AgentVersion { get; }
135+
128136
/// <summary>
129137
/// Deconstructs the current instance into discrete values.
130138
/// </summary>
@@ -138,6 +146,7 @@ public AgentDetails(
138146
/// <param name="tenantId">Receives the tenant identifier.</param>
139147
/// <param name="agentClientIP">Receives the client IP address.</param>
140148
/// <param name="agentPlatformId">Receives the platform ID.</param>
149+
/// <param name="agentVersion">Receives the agent version.</param>
141150
public void Deconstruct(
142151
out string? agentId,
143152
out string? agentName,
@@ -148,7 +157,8 @@ public void Deconstruct(
148157
out AgentType? agentType,
149158
out string? tenantId,
150159
out IPAddress? agentClientIP,
151-
out string? agentPlatformId)
160+
out string? agentPlatformId,
161+
out string? agentVersion)
152162
{
153163
agentId = AgentId;
154164
agentName = AgentName;
@@ -160,6 +170,7 @@ public void Deconstruct(
160170
tenantId = TenantId;
161171
agentClientIP = AgentClientIP;
162172
agentPlatformId = AgentPlatformId;
173+
agentVersion = AgentVersion;
163174
}
164175

165176
/// <inheritdoc/>
@@ -179,7 +190,8 @@ public bool Equals(AgentDetails? other)
179190
AgentType == other.AgentType &&
180191
string.Equals(TenantId, other.TenantId, StringComparison.Ordinal) &&
181192
Equals(AgentClientIP, other.AgentClientIP) &&
182-
string.Equals(AgentPlatformId, other.AgentPlatformId, StringComparison.Ordinal);
193+
string.Equals(AgentPlatformId, other.AgentPlatformId, StringComparison.Ordinal) &&
194+
string.Equals(AgentVersion, other.AgentVersion, StringComparison.Ordinal);
183195
}
184196

185197
/// <inheritdoc/>
@@ -204,6 +216,7 @@ public override int GetHashCode()
204216
hash = (hash * 31) + (TenantId != null ? StringComparer.Ordinal.GetHashCode(TenantId) : 0);
205217
hash = (hash * 31) + (AgentClientIP?.GetHashCode() ?? 0);
206218
hash = (hash * 31) + (AgentPlatformId != null ? StringComparer.Ordinal.GetHashCode(AgentPlatformId) : 0);
219+
hash = (hash * 31) + (AgentVersion != null ? StringComparer.Ordinal.GetHashCode(AgentVersion) : 0);
207220
return hash;
208221
}
209222
}

src/Observability/Runtime/Tracing/Processors/ActivityProcessor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public sealed class ActivityProcessor : BaseProcessor<Activity>
1717
OpenTelemetryConstants.GenAiAgentIdKey,
1818
OpenTelemetryConstants.GenAiAgentNameKey,
1919
OpenTelemetryConstants.GenAiAgentDescriptionKey,
20+
OpenTelemetryConstants.GenAiAgentVersionKey,
2021
OpenTelemetryConstants.AgentEmailKey,
2122
OpenTelemetryConstants.AgentBlueprintIdKey,
2223
OpenTelemetryConstants.AgentAUIDKey,

src/Observability/Runtime/Tracing/Scopes/InvokeAgentScope.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ private InvokeAgentScope(
107107
SetTagMaybe(OpenTelemetryConstants.CallerAgentAUIDKey, callerAgentDetails.AgenticUserId);
108108
SetTagMaybe(OpenTelemetryConstants.CallerAgentEmailKey, callerAgentDetails.AgenticUserEmail);
109109
SetTagMaybe(OpenTelemetryConstants.CallerAgentPlatformIdKey, callerAgentDetails.AgentPlatformId);
110+
SetTagMaybe(OpenTelemetryConstants.CallerAgentVersionKey, callerAgentDetails.AgentVersion);
110111
}
111112
}
112113
}

src/Observability/Runtime/Tracing/Scopes/OpenTelemetryConstants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public enum OperationNames
6060
public const string GenAiAgentIdKey = "gen_ai.agent.id";
6161
public const string GenAiAgentNameKey = "gen_ai.agent.name";
6262
public const string GenAiAgentDescriptionKey = "gen_ai.agent.description";
63+
public const string GenAiAgentVersionKey = "gen_ai.agent.version";
6364
public const string AgentAUIDKey = "microsoft.agent.user.id";
6465
public const string AgentEmailKey = "microsoft.agent.user.email";
6566
public const string AgentBlueprintIdKey = "microsoft.a365.agent.blueprint.id";
@@ -78,6 +79,7 @@ public enum OperationNames
7879
public const string CallerAgentAUIDKey = "microsoft.a365.caller.agent.user.id";
7980
public const string CallerAgentEmailKey = "microsoft.a365.caller.agent.user.email";
8081
public const string CallerAgentPlatformIdKey = "microsoft.a365.caller.agent.platform.id";
82+
public const string CallerAgentVersionKey = "microsoft.a365.caller.agent.version";
8183

8284
// Service attributes
8385
public const string ServiceNameKey = "service.name";

src/Observability/Runtime/Tracing/Scopes/OpenTelemetryScope.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ protected OpenTelemetryScope(string operationName, string activityName, AgentDet
7777
SetTagMaybe(GenAiAgentIdKey, agentDetails.AgentId);
7878
SetTagMaybe(GenAiAgentNameKey, agentDetails.AgentName);
7979
SetTagMaybe(GenAiAgentDescriptionKey, agentDetails.AgentDescription);
80+
SetTagMaybe(GenAiAgentVersionKey, agentDetails.AgentVersion);
8081
SetTagMaybe(AgentAUIDKey, agentDetails.AgenticUserId);
8182
SetTagMaybe(AgentEmailKey, agentDetails.AgenticUserEmail);
8283
SetTagMaybe(AgentBlueprintIdKey, agentDetails.AgentBlueprintId);

0 commit comments

Comments
 (0)