Skip to content

Remove explicit ActivityStatusCode.Ok setting to comply with OpenTelemetry specification#9703

Merged
ReubenBond merged 2 commits intomainfrom
copilot/fix-d6b97255-aa55-4a33-8e6e-59824a2d2f42
Oct 3, 2025
Merged

Remove explicit ActivityStatusCode.Ok setting to comply with OpenTelemetry specification#9703
ReubenBond merged 2 commits intomainfrom
copilot/fix-d6b97255-aa55-4a33-8e6e-59824a2d2f42

Conversation

Copy link
Contributor

Copilot AI commented Oct 2, 2025

Problem

Orleans was explicitly setting ActivityStatusCode.Ok after successful grain calls, which violates the OpenTelemetry specification guidance. According to OTEP 0136:

OK represents a span which has been explicitly marked as being free of errors, and should not be counted against an error budget. Note that only end users should set this status. Instead, instrumentation should leave the status as UNSET for operations that do not generate an error.

The specification defines three status codes:

  • UNSET - the default status code (instrumentation should use this for successful operations)
  • ERROR - represents all error types
  • OK - should only be set explicitly by end users, not instrumentation libraries

Changes

Removed the explicit setting of ActivityStatusCode.Ok in ActivityPropagationGrainCallFilter.cs after successful grain call completions. The activity status now remains as UNSET (the default) for successful operations.

Before:

try
{
    await context.Invoke();
    if (activity is not null && activity.IsAllDataRequested)
    {
        activity.SetStatus(ActivityStatusCode.Ok);  // ❌ Violates spec
    }
}

After:

try
{
    await context.Invoke();
    // Status remains UNSET (default) for successful operations ✓
}

Error handling remains unchanged - exceptions still correctly set ActivityStatusCode.Error with appropriate exception tags.

Impact

  • ✅ Complies with OpenTelemetry specification
  • ✅ No breaking changes to functionality
  • ✅ Activity propagation, tracing, and baggage handling unchanged
  • ✅ Error handling unchanged

Fixes #9078

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 0t3vsblobprodcus362.vsblob.vsassets.io
    • Triggering command: dotnet build src/Orleans.Core/Orleans.Core.csproj --configuration Debug -v minimal (dns block)
  • 96bvsblobprodcus338.vsblob.vsassets.io
    • Triggering command: dotnet build src/Orleans.Core/Orleans.Core.csproj --configuration Debug -v minimal (dns block)
  • cflvsblobprodcus383.vsblob.vsassets.io
    • Triggering command: dotnet build src/Orleans.Core/Orleans.Core.csproj --configuration Debug -v minimal (dns block)
  • ckzvsblobprodcus347.vsblob.vsassets.io
    • Triggering command: dotnet build src/Orleans.Core/Orleans.Core.csproj --configuration Debug -v minimal (dns block)
  • dnceng.pkgs.visualstudio.com
    • Triggering command: dotnet build src/Orleans.Core/Orleans.Core.csproj --configuration Debug -v minimal (dns block)
  • frdvsblobprodcus327.vsblob.vsassets.io
    • Triggering command: dotnet build src/Orleans.Core/Orleans.Core.csproj --configuration Debug -v minimal (dns block)
  • imzvsblobprodcus368.vsblob.vsassets.io
    • Triggering command: dotnet build src/Orleans.Core/Orleans.Core.csproj --configuration Debug -v minimal (dns block)
  • jrqvsblobprodcus343.vsblob.vsassets.io
    • Triggering command: dotnet build src/Orleans.Core/Orleans.Core.csproj --configuration Debug -v minimal (dns block)
  • kh4vsblobprodcus325.vsblob.vsassets.io
    • Triggering command: dotnet build src/Orleans.Core/Orleans.Core.csproj --configuration Debug -v minimal (dns block)
  • lylvsblobprodcus31.vsblob.vsassets.io
    • Triggering command: dotnet build src/Orleans.Core/Orleans.Core.csproj --configuration Debug -v minimal (dns block)
  • m6xvsblobprodcus342.vsblob.vsassets.io
    • Triggering command: dotnet build src/Orleans.Core/Orleans.Core.csproj --configuration Debug -v minimal (dns block)
  • pdfvsblobprodcus380.vsblob.vsassets.io
    • Triggering command: dotnet build src/Orleans.Core/Orleans.Core.csproj --configuration Debug -v minimal (dns block)
  • rcxvsblobprodcus328.vsblob.vsassets.io
    • Triggering command: dotnet build src/Orleans.Core/Orleans.Core.csproj --configuration Debug -v minimal (dns block)
  • yluvsblobprodcus367.vsblob.vsassets.io
    • Triggering command: dotnet build src/Orleans.Core/Orleans.Core.csproj --configuration Debug -v minimal (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Wrong OpenTelemtry traces status</issue_title>
<issue_description>Hello.
Please do not explicitly set the OK status, as it is not recommended by the OpenTelemetry developers.

activity.SetStatus(ActivityStatusCode.Ok);

Image

</issue_description>

<agent_instructions>Fix the OpenTelemetry implementation in Orleans so that it follows the official guidance by not explicitly setting the Ok status code</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@ReubenBond Source: https://github.com/open-telemetry/oteps/blob/main/text/trace/0136-error_flagging.md > Status Codes Currently, OpenTelemetry does not have a use case for differentiating between different types of errors. However, this use case may appear in the future. For now, we would like to reduce the number of status codes, and then add them back in as the need becomes clear. We would also like to differentiate between status codes which have not been set, and an explicit OK status set by an end user. > > * UNSET is the default status code. > * ERROR represents all error types. > * OK represents a span which has been explicitly marked as being free of errors, and should not be counted against an error budget. Note that only end users should set this status. Instead, instrumentation should leave the status as UNSET for operations that do not generate an error.
Fixes #9694

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Microsoft Reviewers: Open in CodeFlow

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>
Copilot AI changed the title [WIP] Wrong OpenTelemtry traces status Remove explicit ActivityStatusCode.Ok setting to comply with OpenTelemetry specification Oct 2, 2025
Copilot AI requested a review from ReubenBond October 2, 2025 17:36
@ReubenBond ReubenBond marked this pull request as ready for review October 3, 2025 14:20
@ReubenBond ReubenBond merged commit 024914f into main Oct 3, 2025
33 of 36 checks passed
@ReubenBond ReubenBond deleted the copilot/fix-d6b97255-aa55-4a33-8e6e-59824a2d2f42 branch October 3, 2025 14:20
ledjon-behluli pushed a commit to ledjon-behluli/orleans that referenced this pull request Oct 26, 2025
…metry specification (dotnet#9703)

* Initial plan

* Remove explicit ActivityStatusCode.Ok per OpenTelemetry spec

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>
github-merge-queue bot pushed a commit that referenced this pull request Oct 31, 2025
* retire and purge state machines

* Update src/Orleans.Journaling/StateMachineManager.cs

Co-authored-by: Reuben Bond <203839+ReubenBond@users.noreply.github.com>

* move comments up

* wip

* time-based retirement logic

* last touches

* remove test project

* remove unused usings

* prevent duplicate key error during state machine resurrection

* ensure buffered data is re-applied if machine comes back

* remove hacky assertion in tests

* Update src/Orleans.Journaling/StateMachineManager.cs

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

* Update src/Orleans.Journaling/StateMachineManager.cs

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

* Update test/Orleans.Journaling.Tests/StateMachineManagerTests.cs

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

* Update test/Orleans.Journaling.Tests/StateMachineManagerTests.cs

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

* Update test/Orleans.Journaling.Tests/StateMachineManagerTests.cs

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

* Fix table creation logging to reflect existing tables correctly (#9696)

The `CreateIfNotExistsAsync` method's response will have a 409-statuscode if the table already exists and will always return the `TableItem` if the call is successful.

* Fix ZooKeeper CI tests: correct service name and use official Docker image (#9699)

* Initial plan

* Fix ZooKeeper CI tests: correct service name and use specific image tag

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

* Use official ZooKeeper Docker image instead of bitnami

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

* Fix Consul CI tests by using compatible Consul version (#9701)

* Fix Consul key format to comply with allowed characters

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

* Use custom encoding for Consul keys instead of URL encoding

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

* Simplify encoding logic to handle both IPv4 and IPv6

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

* Revert breaking changes and use older Consul version for tests

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

* Remove explicit ActivityStatusCode.Ok setting to comply with OpenTelemetry specification (#9703)

* Initial plan

* Remove explicit ActivityStatusCode.Ok per OpenTelemetry spec

Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ReubenBond <203839+ReubenBond@users.noreply.github.com>

* chore(deps): bump dotnet-sdk from 9.0.303 to 9.0.305 (#9677)

Bumps [dotnet-sdk](https://github.com/dotnet/sdk) from 9.0.303 to 9.0.305.
- [Release notes](https://github.com/dotnet/sdk/releases)
- [Commits](dotnet/sdk@v9.0.303...v9.0.305)

---
updated-dependencies:
- dependency-name: dotnet-sdk
  dependency-version: 9.0.305
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fix race condition in `TransactionInfo.Fork` `PendingCalls` increment (#9702)

* [FIX] Potential NRE in the activation repartitioner (#9713)

fix potentiall NRE in the activation repartioner

* Remove infinite timespan reminder checks (#9715)

* Timeout.InfiniteTimeSpan is not allowed for reminders

* Specifically check for InfiniteTimeSpan to make clear it's usage is not allowed (and to allow for an eventual future change of the InfiniteTimeSpan value)

---------

Co-authored-by: Jerremy Koot <jerremy.koot@gmail.com>

* ResponseCompletionSource: RunContinuationsAsynchronously (#9724)

* chore(deps): bump dotnet-sdk from 9.0.305 to 9.0.306 (#9720)

Bumps [dotnet-sdk](https://github.com/dotnet/sdk) from 9.0.305 to 9.0.306.
- [Release notes](https://github.com/dotnet/sdk/releases)
- [Commits](dotnet/sdk@v9.0.305...v9.0.306)

---
updated-dependencies:
- dependency-name: dotnet-sdk
  dependency-version: 9.0.306
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Add `BigInteger` codec (#9669)

* StateMachineManager: start work loop during activation (#9725)

* Flag PostgreSQL as asynchronous (#9705)

Changed isSynchronousAdoNetImplementation from true to false for PostgreSQL thanks to updates in Npgsql 8.0.
npgsql/npgsql#1130

* Enable GitHub merge queue (#9727)

Enable merge queue

* Add missing validation for the NATS stream provider (#9668)

Add missing validation for the Nats stream provider

* `ActivationDataActivatorProvider`: run grain constructor on grain scheduler (#9726)

* ActivationDataActivatorProvider: always run grain constructor on ActivationTaskScheduler

* ActivationDataActivatorProvider: always run grain constructor on ActivationTaskScheduler

* Modifying Endpoint to use Pascale Casing as EndPoint for consistency (#9671)

Co-authored-by: Ramzi Mourtada <ramourt@microsoft.com>

* treat retirement tracker as a first-class (internal) machine

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Reuben Bond <203839+ReubenBond@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Egil Hansen <egil@assimilated.dk>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bk <bknote71@gmail.com>
Co-authored-by: Da-Teach <da_teach@thehackerwithin.com>
Co-authored-by: Jerremy Koot <jerremy.koot@gmail.com>
Co-authored-by: Gutemberg Ribeiro <gutemberg@outlook.com>
Co-authored-by: Burak Büyükatlı <burak.buyukatli@gmail.com>
Co-authored-by: Ramzi Mourtada <ramzimort@gmail.com>
Co-authored-by: Ramzi Mourtada <ramourt@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Nov 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong OpenTelemtry traces status

2 participants