Skip to content

.NET: [BREAKING] align workflow span name with OpenTelemetry conventions - #9899

Merged
Vincent Biret (baywet) merged 7 commits into
mainfrom
fix/workflow-span-name
Nov 2, 2026
Merged

Vincent Biret (baywet) merged 7 commits into
mainfrom
fix/workflow-span-name

Conversation

@baywet

@baywet Vincent Biret (baywet) commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Motivation & Context

Align .NET workflow invocation telemetry with the pinned OpenTelemetry GenAI invoke-workflow conventions. The existing instrumentation emits workflow_invoke, uses the nonstandard workflow.name key only on build activities, omits the required operation attribute, and does not record application-supplied conversation context on invocation activities. These inconsistencies make standard queries, sampling, and conversation correlation harder.

Description & Review Guide

  • What are the major changes? Emit invoke_workflow {gen_ai.workflow.name} for named workflows and bare invoke_workflow when no meaningful name exists. Replace workflow.name with gen_ai.workflow.name on build activities and propagate the name through both execution paths onto invocation activities. Record gen_ai.operation.name="invoke_workflow" at activity creation, keeping its value independent of the workflow-name suffix. Also record a supplied gen_ai.conversation.id from OpenTelemetry baggage, falling back to the current Activity's baggage; non-blank OpenTelemetry baggage takes precedence. Add regression coverage and update telemetry option documentation and the .NET consumer observability reference.
  • What is the impact of these changes? This is a breaking telemetry change, not a public API signature or workflow execution change. Update dashboards, exporters, and filters from workflow_invoke to the new span-name format and from workflow.name to gen_ai.workflow.name. To identify invocation activities independently of their workflow names, filter on gen_ai.operation.name="invoke_workflow". For conversation correlation, supply gen_ai.conversation.id through OpenTelemetry or Activity baggage before running the workflow. Missing/blank conversation IDs are omitted; execution session.id is preserved and is never repurposed as a fallback conversation ID. This does not automatically infer conversation IDs from workflow-as-agent sessions or declarative backend state. Framework-specific build/session/executor/message span names and unrelated custom attributes remain unchanged.
  • What do you want reviewers to focus on? Name propagation for named and unnamed workflows across Lockstep, OffThread, and Concurrent execution, with streaming and non-streaming APIs; creation-time availability of the semantic attributes and full span name; keeping the base operation value unchanged; conversation-context precedence and omission without context; and preservation of named-span stopping, exportability, and parent relationships. Existing prefix-based activity lookups remain compatible. Python already supports scoped conversation IDs, including supplied AG-UI thread IDs, and Python: [BREAKING] align workflow span name with OpenTelemetry conventions #9900 preserves that behavior for named spans; no Python changes are included here.

From dotnet, the following commands passed:

dotnet build src\Microsoft.Agents.AI.Workflows\Microsoft.Agents.AI.Workflows.csproj --no-restore --tl:off
# Passed for net472, netstandard2.0, net8.0, net9.0, and net10.0; 0 warnings, 0 errors.

dotnet run --project tests\Microsoft.Agents.AI.Workflows.UnitTests -f net10.0 --no-restore -- --progress off
# Passed: all 928 workflow unit tests.

dotnet run --project tests\Microsoft.Agents.AI.Workflows.UnitTests -f net10.0 --no-restore -- --filter-class '*ObservabilityTests' --progress off
# Passed: all 55 observability cases, including conversation propagation and omission regressions.

dotnet run --project tests\Microsoft.Agents.AI.Workflows.Declarative.UnitTests -f net10.0 --no-restore -- --filter-class '*DeclarativeWorkflowOptionsTest' --progress off
# Passed: 10 declarative telemetry/configuration tests.

Changed production and workflow-test files were formatted in their respective projects after each implementation step. The final conversation-ID formatting commands were:

dotnet format src\Microsoft.Agents.AI.Workflows\Microsoft.Agents.AI.Workflows.csproj --no-restore --include src\Microsoft.Agents.AI.Workflows\Observability\Tags.cs src\Microsoft.Agents.AI.Workflows\Observability\WorkflowTelemetryContext.cs
# Passed.

dotnet format tests\Microsoft.Agents.AI.Workflows.UnitTests\Microsoft.Agents.AI.Workflows.UnitTests.csproj --no-restore --include tests\Microsoft.Agents.AI.Workflows.UnitTests\ObservabilityTests.cs
# Passed.

The initial declarative-test expectation change was also formatted:

dotnet format tests\Microsoft.Agents.AI.Workflows.Declarative.UnitTests --no-restore --verbosity minimal
# Passed.

The full solution test suite and integration tests were not run. Python source and existing regression tests were inspected, not rerun.

Related Issue

N/A - trivial change: correct unambiguous workflow invocation span/attribute mismatches with the linked specification. No competing open .NET workflow telemetry-alignment PR was found. #9900 is the complementary Python change, not a duplicate.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: GitHub Copilot assisted with implementation, regression tests, documentation, validation, the Python behavior comparison, and this PR description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fa592ce6-05c6-4421-801b-59c77df4b2df

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The workflow invocation span-name correction has no active review issues.

No open issues 🎉

What changed in this PR

Corrects the .NET workflow invocation span name from workflow_invoke to invoke_workflow to align with OpenTelemetry conventions. Telemetry filters using the old name will need updating.

Changes:

  • Updates the shared span-name constant and declarative telemetry expectation.
  • Adds six regression cases covering streaming and non-streaming execution across Lockstep, OffThread, and Concurrent environments.
  • Aligns API documentation and existing test comments with the corrected name.
File Description
dotnet/​tests/​Microsoft.Agents.AI.Workflows.UnitTests/​WorkflowRunActivityStopTests.cs Updates comments only to use the corrected span name.
dotnet/​tests/​Microsoft.Agents.AI.Workflows.UnitTests/​ObservabilityTests.cs Adds six cases asserting the literal convention name.
dotnet/​tests/​Microsoft.Agents.AI.Workflows.Declarative.UnitTests/​DeclarativeWorkflowOptionsTest.cs Updates the expected invocation span name.
dotnet/​src/​Microsoft.Agents.AI.Workflows/​Observability/​WorkflowTelemetryOptions.cs Corrects the span name in API documentation.
dotnet/​src/​Microsoft.Agents.AI.Workflows/​Observability/​ActivityNames.cs Changes the shared invocation span-name constant.

Review effort: Balanced

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAF Automated Review — Iteration 1

Result: No findings
Scope: full PR (1 commit(s)): c0fa63f0d9bb
Model: gpt-5.6-sol

Overview

The PR centralizes the corrected invoke_workflow activity name in the existing internal constant and updates its public documentation and declarative expectation consistently. The new regression covers streaming and non-streaming runs across Lockstep, OffThread, and Concurrent execution, while existing tests preserve activity enablement, routing, and disposal guarantees. No PR-introduced Critical, High, or Medium defect remains after reconciliation.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.

@github-code-quality

github-code-quality Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage overview

Languages: C#

C# / code-coverage/dotnet

main f148334 fix/workflow-span-na... 95d38a6 +/-
86% 86% 0%
View coverage of the 4 most impacted files.
File main f148334 fix/workflow-span-na... 95d38a6 +/-
/home/runner/wo...SessionStore.cs 100% 56% -44%
/home/runner/wo...kflowBuilder.cs 90% 90% 0%
/home/runner/wo...metryContext.cs 90% 91% +1%
/home/runner/wo...rocessRunner.cs 91% 92% +1%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 02, 2026 18:19 UTC

@baywet
Vincent Biret (baywet) marked this pull request as ready for review October 30, 2026 19:15
@baywet Vincent Biret (baywet) changed the title .NET: align workflow span name with OpenTelemetry conventions .NET: [BREAKING] align workflow span name with OpenTelemetry conventions Oct 30, 2026
@agent-framework-automation agent-framework-automation Bot added the breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible label Oct 30, 2026
Record application-defined workflow names on invocation spans at creation, replace the legacy build-span key, and omit blank names. Cover named and unnamed workflows across execution modes and document the attribute migration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: aa4dae7a-fdbd-475c-8ec6-fa8333e77cc4
Set gen_ai.operation.name to invoke_workflow at activity creation for sampling. Verify named and unnamed workflows across execution modes, creation-time sampling, and omission from unrelated activities.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: aa4dae7a-fdbd-475c-8ec6-fa8333e77cc4
Append meaningful workflow names at activity creation while preserving the base operation attribute and unnamed fallback. Cover sampling, streaming and non-streaming execution, and named-span lifecycle and parenting. Update telemetry documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: aa4dae7a-fdbd-475c-8ec6-fa8333e77cc4
Record gen_ai.conversation.id from OpenTelemetry or Activity baggage at invocation activity creation, with no execution-session fallback. Cover context precedence, named and unnamed workflows, streaming and non-streaming execution, and omission without context.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: aa4dae7a-fdbd-475c-8ec6-fa8333e77cc4
Address review comment 4445228927 with a using declaration for the lockstep invocation activity while preserving status cleanup. Remove misleading async-iterator disposal comments and verify cancellation, early enumeration disposal, consumer errors, and executor failures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: aa4dae7a-fdbd-475c-8ec6-fa8333e77cc4

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Selective sampling can clear Activity.Current when no workflow session activity is created, causing invocations to lose the application's gen_ai.conversation.id baggage; the ambient activity must be preserved and covered by a regression test.

1 open issue

Review effort: Balanced

Ensure Activity.Current is set to a valid session activity.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the .NET workflow telemetry alignment with OpenTelemetry GenAI conventions.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@baywet
Vincent Biret (baywet) added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit f6548e7 Nov 2, 2026
40 checks passed
@baywet
Vincent Biret (baywet) deleted the fix/workflow-span-name branch November 2, 2026 18:42

This branch was previously deployed

2 inactive deployments
integration — 95d38a64 Deployed Nov 2, 2026 by baywet via dotnet-foundry-hosted-it #31952
github-app-auth — 95d38a64 Deployed Nov 2, 2026 by baywet via add_label #26876
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants