Skip to content

[Breaking change]: Change the Activity operation name when the Activity is created with null value #32117

Closed

Description

@tarekgh

Description

Creating an Activity object using null operation name is currently allowed but it has an undesired effect on the backend trace collectors. Usually trace collectors assume non-value operation names. The breaking change here is when creating the Activity object using null operation name, the operation name will use empty string "" instead of the null.

area: System.Diagnostics

Version

.NET 8 (other)

Previous behavior

Creating an Activity object using null operation name was storing the operation name inside the activity as null.

new Activity(operationName: null).OperationName // will have a null value

New behavior

Creating an Activity object using null operation name will convert the operation name to empty string

new Activity(operationName: null).OperationName // will have an empty string value

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load/execute or different run-time behavior.
  • Source incompatible: Source code may encounter a breaking change in behavior when targeting the new runtime/component/SDK, such as compile errors or different run-time behavior.

Reason for change

Having null operation name inside the Activity object causes the trace collectors to special case it. Otherwise, it can run into crashes.

Recommended action

This is very unlikely to break as using null when creating Activity object is rare. If anyone for any reason was depending on null value will need to adjust the code to either not using null or expect getting empty string operation name when using null.

Feature area

Other (please put exact area in description textbox)

Affected APIs

  • System.Diagnostics.Activity
    • Constructor
    • OperationName
  • System.Diagnostics.ActivitySource
    • CreateActivity
    • StartActivity

Activity

  1. added
    breaking-change
    on Nov 1, 2022
  2. added
    🏁 Release: .NET 8
    and removed
    ⌚ Not Triaged
    on Nov 1, 2022
  3. ghost added
    in-pr
    on Jan 27, 2023
  4. ghost removed
    in-pr
    on Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 8breaking-change

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions