.NET: Workflow observability (#959)

* Add basic Workflow telemetry

* Add sample

* Add source propagation for executor spans

* Fix tests and address comments

* Fix formatting

* Fix declarative unit tests

* Address comments

* Remove Microsoft.Extensions.AI.Agents.EnableTelemetry

* Formatting

* Formatting

* Formatting

* fix solution

* Address comments

* Add workflow json definition for serialization

* Formmating

* Address comments
This commit is contained in:
Tao Chen
2025-09-30 23:40:04 +00:00
committed by GitHub
parent 2539282d30
commit 042099009f
29 changed files with 598 additions and 72 deletions
@@ -149,6 +149,8 @@ public class SpecializedExecutorSmokeTests
return default;
}
public IReadOnlyDictionary<string, string>? TraceContext => null;
}
[Fact]
@@ -9,7 +9,10 @@ namespace Microsoft.Agents.AI.Workflows.UnitTests;
public class TestRunContext : IRunnerContext
{
private sealed class BoundContext(string executorId, TestRunContext runnerContext) : IWorkflowContext
private sealed class BoundContext(
string executorId,
TestRunContext runnerContext,
IReadOnlyDictionary<string, string>? traceContext) : IWorkflowContext
{
public ValueTask AddEventAsync(WorkflowEvent workflowEvent)
=> runnerContext.AddEventAsync(workflowEvent);
@@ -34,6 +37,8 @@ public class TestRunContext : IRunnerContext
public ValueTask SendMessageAsync(object message, string? targetId = null)
=> runnerContext.SendMessageAsync(executorId, message, targetId);
public IReadOnlyDictionary<string, string>? TraceContext => traceContext;
}
public List<WorkflowEvent> Events { get; } = [];
@@ -44,7 +49,8 @@ public class TestRunContext : IRunnerContext
return default;
}
public IWorkflowContext Bind(string executorId) => new BoundContext(executorId, this);
public IWorkflowContext Bind(string executorId, Dictionary<string, string>? traceContext = null)
=> new BoundContext(executorId, this, traceContext);
public List<ExternalRequest> ExternalRequests { get; } = [];
public ValueTask PostAsync(ExternalRequest request)