Open
Conversation
- Add WorkflowTelemetryOptions class with EnableSensitiveData property - Add WorkflowTelemetryContext to manage ActivitySource lifecycle - Add WithOpenTelemetry() extension method on WorkflowBuilder - Update all workflow components to use telemetry context: - WorkflowBuilder, Workflow, Executor - InProcessRunnerContext, InProcessRunner - LockstepRunEventStream, StreamingRunEventStream - All edge runners (Direct, FanIn, FanOut, Response) - Telemetry is now disabled by default - Users must call WithOpenTelemetry() to enable spans/activities BREAKING CHANGE: Workflow telemetry is now opt-in. Users who relied on automatic telemetry must add .WithOpenTelemetry() to their workflow builder.
- Remove IWorkflowContextWithTelemetry interface - Add internal ExecuteAsync overload that accepts WorkflowTelemetryContext - Public ExecuteAsync delegates with WorkflowTelemetryContext.Disabled - InProcessRunner passes TelemetryContext when calling ExecuteAsync - BoundContext now implements IWorkflowContext (not the removed interface)
Allow users to provide their own ActivitySource when enabling telemetry, giving them better control over the ActivitySource lifecycle. When not provided, the framework creates one internally (existing behavior). Changes: - Add optional activitySource parameter to WithOpenTelemetry() extension - Update WorkflowTelemetryContext to accept external ActivitySource - Add unit test for user-provided ActivitySource scenario
Allow users to selectively disable specific activity types via WorkflowTelemetryOptions. All activities are enabled by default. New disable flags: - DisableWorkflowBuild: Disables workflow.build activities - DisableWorkflowRun: Disables workflow_invoke activities - DisableExecutorProcess: Disables executor.process activities - DisableEdgeGroupProcess: Disables edge_group.process activities - DisableMessageSend: Disables message.send activities Added helper methods to WorkflowTelemetryContext for each activity type and updated all activity creation sites to use them.
When EnableSensitiveData is true in WorkflowTelemetryOptions, executor input and output are logged as JSON-serialized attributes in the executor.process activity. New activity tags: - executor.input: JSON serialized input message - executor.output: JSON serialized output result (non-void only) Added suppression attributes for AOT/trimming warnings since this is an opt-in feature for debugging/diagnostics.
Move tagging logic into WorkflowTelemetryContext methods: - StartExecutorProcessActivity now accepts executorId, executorType, messageType, and message; sets all tags including executor.input when EnableSensitiveData is true - Added SetExecutorOutput method to set executor.output after execution - StartMessageSendActivity now accepts sourceId, targetId, and message; sets all tags including message.content when EnableSensitiveData is true Simplified Executor.cs and InProcessRunnerContext.cs by removing inline tagging code. Added message.content tag constant.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request implements opt-in telemetry for .NET workflows with comprehensive configuration options. The PR addresses requirements from the Foundry observability team to improve workflow telemetry capabilities while making it configurable and privacy-conscious.
Changes:
- Introduced opt-in telemetry via
WithOpenTelemetry()extension method onWorkflowBuilder(telemetry is now disabled by default) - Renamed workflow run activity from
workflow.runtoworkflow_invokefor consistency with telemetry naming conventions - Added executor input/output attributes to executor activities (when
EnableSensitiveDatais true) - Implemented granular telemetry configuration through
WorkflowTelemetryOptions(disable specific activities, enable sensitive data logging) - Added executor ID to
executor.processactivity names for better traceability
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| OpenTelemetryWorkflowBuilderExtensions.cs | New public API for enabling workflow telemetry with fluent configuration |
| WorkflowTelemetryOptions.cs | Configuration class for controlling telemetry behavior (sensitive data, activity toggles) |
| WorkflowTelemetryContext.cs | Internal context managing telemetry state and creating activities with appropriate tags |
| ActivityNames.cs | Renamed WorkflowRun constant from "workflow.run" to "workflow_invoke" |
| Tags.cs | Added ExecutorInput, ExecutorOutput, and MessageContent tag constants |
| WorkflowBuilder.cs | Integrated telemetry context and removed static ActivitySource |
| Workflow.cs | Added TelemetryContext property |
| Executor.cs | Updated to use telemetry context and log input/output when enabled |
| InProcessRunner.cs | Pass telemetry context to executor execution |
| InProcessRunnerContext.cs | Use telemetry context for message send activities |
| IRunnerContext.cs | Added TelemetryContext property to interface |
| ISuperStepRunner.cs | Added TelemetryContext property to interface |
| StreamingRunEventStream.cs | Removed static ActivitySource, use telemetry context |
| LockstepRunEventStream.cs | Removed static ActivitySource, use telemetry context |
| EdgeRunner.cs | Added helper method for starting edge activities (has bug) |
| DirectEdgeRunner.cs | Use helper method from base class |
| FanInEdgeRunner.cs | Use helper method from base class |
| FanOutEdgeRunner.cs | Use helper method from base class |
| ResponseEdgeRunner.cs | Use helper method from base class |
| DeclarativeWorkflowOptions.cs | Added telemetry configuration properties |
| WorkflowActionVisitor.cs | Apply telemetry configuration to declarative workflows with validation |
| ObservabilityTests.cs | Comprehensive test coverage for all telemetry features |
| DeclarativeWorkflowOptionsTest.cs | Tests for declarative workflow telemetry configuration |
| TestRunContext.cs | Updated test infrastructure to support telemetry context |
| CosmosDBCollectionFixture.cs | Removed redundant using statement (global using in place) |
| AspireDashboard/Program.cs | Updated sample to demonstrate opt-in telemetry with sensitive data enabled |
| ApplicationInsights/Program.cs | Updated sample to demonstrate opt-in telemetry with sensitive data enabled |
| FoundryAgents_Step01.1_Basics/Program.cs | Removed unused import |
dotnet/src/Microsoft.Agents.AI.Workflows/Execution/EdgeRunner.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Workflows/Observability/WorkflowTelemetryContext.cs
Outdated
Show resolved
Hide resolved
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/ObservabilityTests.cs
Outdated
Show resolved
Hide resolved
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/ObservabilityTests.cs
Outdated
Show resolved
Hide resolved
crickman
approved these changes
Feb 6, 2026
Contributor
crickman
left a comment
There was a problem hiding this comment.
Thanks for the unit test!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Closes #3386
Foundry observability team has requested the following features from AF workflow telemetry:
workflow.runtoworkflow_invokeexecutor.processactivitiesDescription
workflow.runtoworkflow_invokeSendMessage, where the messages will be added as attributes in themessage.sendactivities.EnableSensitiveData, and disabling activities from workflows.executor.processactivitiesContribution Checklist