Commit Graph

2 Commits

  • .NET: Workflow telemetry opt in (#3467)
    * feat(workflows): Make telemetry opt-in via WithOpenTelemetry()
    
    - 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.
    
    * refactor: Pass telemetry context as parameter instead of via interface
    
    - 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)
    
    * Add optional ActivitySource parameter to WithOpenTelemetry
    
    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
    
    * Add component-level telemetry control with disable flags
    
    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.
    
    * Implement EnableSensitiveData to log executor input/output
    
    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.
    
    * Refactor activity start methods to centralize tagging logic
    
    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.
    
    * Revert Python changes
    
    * Update samples and code cleanup
    
    * Fix file formatting
    
    * Add comment
    
    * Add telemetry configuration to declarative workflow
    
    * Remove delays in tests
    
    * Address comments
  • .NET: Add Cosmos DB implementations for ChatMessageStore and CheckpointStore. (#1838)
    * draft commit
    
    * Added Cosmos agent thread and tests
    
    * revert unnecessary changes and fix tests
    
    * add multi-tenant support with hierarchical partition keys (and tests).
    
    * enhance transactional batch
    
    * address review comments
    
    * Address PR review comments from @westey-m
    
    * Merge upstream/main - resolve slnx conflicts
    
    * use param validation helpers
    
    * Replace useManagedIdentity boolean with TokenCredential parameter
    
    * Remove redundant suppressions and fix tests
    
    * Rename project from Microsoft.Agents.AI.Abstractions.CosmosNoSql to Microsoft.Agents.AI.CosmosNoSql
    
    * Refactor constructors to use chaining pattern
    
    * Reorder deserialization constructor parameters for consistency
    
    * Remove database/container IDs from serialized state
    
    * Remove auto-generation of MessageId
    
    * Optimize AddMessagesAsync to avoid enumeration when possible
    
    * Add MaxMessagesToRetrieve to limit context window
    
    * Make Role nullable instead of defaulting
    
    * Fix net472 build without rebasing 19 commits
    
    * Add Cosmos DB emulator to CI workflow
    
    * Fix Cosmos DB emulator tests: use Skip.If instead of Assert.Fail and start emulator before unit tests
    
    * Replace Skip.If() with conditional return to fix compilation
    
    * Use env var to skip Cosmos tests on non-Windows CI
    
    * Add Xunit.SkippableFact package to properly skip Cosmos tests on Linux
    
    * Change [Fact] to [SkippableFact] for proper test skipping behavior
    
    * Remove stale Microsoft.Agents.AI.Abstractions.CosmosNoSql directory
    
    * Fix code formatting: add braces, this. qualifications, and final newlines
    
    * Fix file encoding to UTF-8 with BOM, fix import ordering, and remove unnecessary using directives
    
    * Convert backing fields to auto-properties and remove Azure.Identity using directive
    
    * Fix CosmosChatMessageStore.cs encoding back to UTF-8 with BOM
    
    * Fix test file formatting: indentation, encoding, imports, this. qualifications, naming conventions, and simplify new expressions
    
    * Fix const field naming violations: Remove s_ prefix from const fields and add this. qualification to Dispose call
    
    * Add local .editorconfig for Cosmos DB tests to suppress IDE0005 false positives from multi-targeting
    
    * Fix IDE1006 naming violations: Rename TestDatabaseId to s_testDatabaseId and add final newlines
    
    * Address PR review comments
    
    Address Wesley's review comments:
    
    - Remove Cosmos DB package references from core projects
    
    - Delete duplicate test files from old package structure
    
    - Remove redundant parameter validation from extension methods
    
    Address Kiran's review comments:
    
    - Remove redundant 429 retry logic (SDK handles automatically)
    
    - Add explicit RequestEntityTooLarge error handling
    
    - Remove dead code in GetMessageCountAsync
    
    - Add defensive partition key validation comments
    
    * Fix IDE0001 formatting error in AgentProviderExtensions.cs. Use type alias to resolve namespace conflict between Azure.AI.Agents.Persistent.RunStatus and Microsoft.Agents.AI.Workflows.RunStatus. This eliminates the need for global:: qualifier which triggered the formatter warning.
    
    * Update package versions for Aspire 13.0.0 compatibility
    
    * Fix TargetFrameworks in Cosmos DB projects
    
    - Replace  with  which is defined in Directory.Build.props
    - Fix package reference from System.Linq.Async to System.Linq.AsyncEnumerable to match Directory.Packages.props
    
    * Remove redundant counter, add partition key validation, use factory pattern for deserialization