Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public enum OperationNames
/// <summary>
/// The GenAI tool arguments key.
Comment thread
fpfp100 marked this conversation as resolved.
Outdated
/// </summary>
public const string GenAiToolArgumentsKey = "gen_ai.tool.arguments";
public const string GenAiToolArgumentsKey = "gen_ai.tool.call.arguments";

/// <summary>
/// The GenAI tool type key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public async Task AddTracing_And_ExecuteToolScope_ExporterMakesExpectedRequest()
this.GetAttribute(attributes, "microsoft.a365.agent.blueprint.id").Should().Be(expectedAgentDetails.AgentBlueprintId);
this.GetAttribute(attributes, "microsoft.tenant.id").Should().Be(expectedAgentDetails.TenantId);
this.GetAttribute(attributes, "gen_ai.tool.name").Should().Be(toolCallDetails.ToolName);
this.GetAttribute(attributes, "gen_ai.tool.arguments").Should().Be(toolCallDetails.Arguments);
this.GetAttribute(attributes, "gen_ai.tool.call.arguments").Should().Be(toolCallDetails.Arguments);
this.GetAttribute(attributes, "gen_ai.tool.call.id").Should().Be(toolCallDetails.ToolCallId);
this.GetAttribute(attributes, "gen_ai.tool.description").Should().Be(toolCallDetails.Description);
this.GetAttribute(attributes, "gen_ai.tool.type").Should().Be(toolCallDetails.ToolType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public async Task AddTracing_And_ExecuteToolScope_ExporterMakesExpectedRequest()
this.GetAttribute(attributes, "microsoft.a365.agent.blueprint.id").Should().Be(expectedAgentDetails.AgentBlueprintId);
this.GetAttribute(attributes, "microsoft.tenant.id").Should().Be(expectedAgentDetails.TenantId);
this.GetAttribute(attributes, "gen_ai.tool.name").Should().Be(toolCallDetails.ToolName);
this.GetAttribute(attributes, "gen_ai.tool.arguments").Should().Be(toolCallDetails.Arguments);
this.GetAttribute(attributes, "gen_ai.tool.call.arguments").Should().Be(toolCallDetails.Arguments);
this.GetAttribute(attributes, "gen_ai.tool.call.id").Should().Be(toolCallDetails.ToolCallId);
this.GetAttribute(attributes, "gen_ai.tool.description").Should().Be(toolCallDetails.Description);
this.GetAttribute(attributes, "gen_ai.tool.type").Should().Be(toolCallDetails.ToolType);
Expand Down Expand Up @@ -502,7 +502,7 @@ public async Task Exporter_Truncates_Scope()
{
foundExecuteTool = true;
// Should be truncated
var args = this.GetAttribute(attrs, "gen_ai.tool.arguments");
var args = this.GetAttribute(attrs, "gen_ai.tool.call.arguments");
args.Should().Be("TRUNCATED");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ public void FormatMany_DoesNothing_WhenUnderLimit()
{
// Arrange
using var activity = CreateActivity("tenant-1", "agent-1");
activity.SetTag("gen_ai.tool.arguments", new string('a', 1024)); // 1KB
activity.SetTag("gen_ai.tool.call.arguments", new string('a', 1024)); // 1KB
var resource = ResourceBuilder.CreateEmpty().Build();
var logs = new List<string>();
var formatter = new ExportFormatter(new ListLogger<ExportFormatter>(logs));
Expand All @@ -538,7 +538,7 @@ public void FormatMany_DoesNothing_WhenUnderLimit()
var resourceSpans = doc.RootElement.GetProperty("resourceSpans");
var scopeSpans = resourceSpans[0].GetProperty("scopeSpans");
var span = scopeSpans[0].GetProperty("spans")[0];
span.GetProperty("attributes").GetProperty("gen_ai.tool.arguments").GetString().Should().NotBe("TRUNCATED");
span.GetProperty("attributes").GetProperty("gen_ai.tool.call.arguments").GetString().Should().NotBe("TRUNCATED");
logs.Should().NotContain(l => l.Contains("Truncated"));
}

Expand All @@ -547,7 +547,7 @@ public void FormatMany_TruncatesSingleLargeKey()
{
// Arrange
using var activity = CreateActivity("tenant-1", "agent-2");
activity.SetTag("gen_ai.tool.arguments", new string('b', 300 * 1024)); // 300KB
activity.SetTag("gen_ai.tool.call.arguments", new string('b', 300 * 1024)); // 300KB
var resource = ResourceBuilder.CreateEmpty().Build();
var logs = new List<string>();
var formatter = new ExportFormatter(new ListLogger<ExportFormatter>(logs));
Expand All @@ -560,17 +560,17 @@ public void FormatMany_TruncatesSingleLargeKey()
var resourceSpans = doc.RootElement.GetProperty("resourceSpans");
var scopeSpans = resourceSpans[0].GetProperty("scopeSpans");
var span = scopeSpans[0].GetProperty("spans")[0];
span.GetProperty("attributes").GetProperty("gen_ai.tool.arguments").GetString().Should().Be("TRUNCATED");
logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.arguments' size = "));
logs.Should().Contain(l => l.Contains("Truncated 'gen_ai.tool.arguments'"));
span.GetProperty("attributes").GetProperty("gen_ai.tool.call.arguments").GetString().Should().Be("TRUNCATED");
logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.call.arguments' size = "));
logs.Should().Contain(l => l.Contains("Truncated 'gen_ai.tool.call.arguments'"));
}

[TestMethod]
public void FormatMany_TruncatesMultipleKeys_LargestFirst()
{
// Arrange
using var activity = CreateActivity("tenant-1", "agent-1");
activity.SetTag("gen_ai.tool.arguments", new string('c', 200 * 1024));
activity.SetTag("gen_ai.tool.call.arguments", new string('c', 200 * 1024));
activity.SetTag("gen_ai.tool.call.result", new string('d', 100 * 1024));
var resource = ResourceBuilder.CreateEmpty().Build();
var logs = new List<string>();
Expand All @@ -585,9 +585,9 @@ public void FormatMany_TruncatesMultipleKeys_LargestFirst()
var scopeSpans = resourceSpans[0].GetProperty("scopeSpans");
var span = scopeSpans[0].GetProperty("spans")[0];
var attr = span.GetProperty("attributes");
attr.GetProperty("gen_ai.tool.arguments").GetString().Should().Be("TRUNCATED");
logs.Should().Contain(l => l.Contains("Truncated 'gen_ai.tool.arguments'"));
logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.arguments' size = "));
attr.GetProperty("gen_ai.tool.call.arguments").GetString().Should().Be("TRUNCATED");
logs.Should().Contain(l => l.Contains("Truncated 'gen_ai.tool.call.arguments'"));
logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.call.arguments' size = "));
logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.call.result' size = "));
}

Expand All @@ -596,7 +596,7 @@ public void FormatMany_LogsAllKeySizes()
{
// Arrange
using var activity = CreateActivity("tenant-1", "agent-1");
activity.SetTag("gen_ai.tool.arguments", new string('x', 100 * 1024));
activity.SetTag("gen_ai.tool.call.arguments", new string('x', 100 * 1024));
activity.SetTag("gen_ai.tool.call.result", new string('y', 125 * 1024));
activity.SetTag("gen_ai.input.messages", new string('z', 75 * 1024));
activity.SetTag("gen_ai.agent.invocation_input", new string('z', 0));
Expand All @@ -610,7 +610,7 @@ public void FormatMany_LogsAllKeySizes()
formatter.FormatMany(new[] { activity }, resource);

// Assert
logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.arguments' size = 100"));
logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.call.arguments' size = 100"));
logs.Should().Contain(l => l.Contains("Key 'gen_ai.tool.call.result' size = 125"));
logs.Should().Contain(l => l.Contains("Key 'gen_ai.input.messages' size = 75"));
logs.Should().Contain(l => l.Contains("Key 'gen_ai.agent.invocation_input' size = 0"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public void EstimateActivityBytes_OverEstimatesActualJsonSize()
var attrs = new Dictionary<string, object?>
{
["gen_ai.system"] = "openai",
["gen_ai.tool.arguments"] = new string('x', 1000),
["gen_ai.tool.call_result"] = new string('y', 1000),
["gen_ai.tool.call.arguments"] = new string('x', 1000),
["gen_ai.tool.call.result"] = new string('y', 1000),
};
var activity = CreateActivity("test", attrs);

Expand Down
Loading