Skip to content

System.Diagnostics.DiagnosticSource: Activity with null operation name #77621

Closed

Description

@CodeBlanch

Activity has a quirk in that its OperationName is not marked as nullable but its constructor allows it to be null. Chatted offline with the group CCed below and we agreed that it is a low-risk change to coalesce to string.Empty in this case.

Something like this:

        public Activity(string operationName)
        {
            Source = s_defaultSource;
            // Allow data by default in the constructor to keep the compatibility.
            IsAllDataRequested = true;

            if (string.IsNullOrEmpty(operationName))
            {
                NotifyError(new ArgumentException(SR.OperationNameInvalid)); // <- Note: Does not throw.
                operationName = string.Empty; // <- New logic here.
            }

            OperationName = operationName;
        }

We consider setting to something like "<null>" but decided to use string.Empty because that is similar to what happens for Activity.Source.Name in the case of legacy instances.

/cc @tarekgh @noahfalk @reyang @cijothomas @utpilla @alanwest

Activity

  1. ghost added
    untriaged
    on Oct 28, 2022
  2. added and removed
    untriaged
    on Oct 28, 2022
  3. added
    breaking-change
    on Oct 28, 2022
  4. added this to the 8.0.0 milestone on Oct 28, 2022
  5. added
    needs-breaking-change-doc-created
    on Oct 28, 2022
  6. self-assigned this
    on Oct 28, 2022
  7. ghost added
    in-pr
    on Nov 1, 2022
  8. ghost removed
    in-pr
    on Nov 1, 2022
  9. ghost locked as resolved and limited conversation to collaborators on Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-System.Diagnostics.Activitybreaking-changeneeds-breaking-change-doc-created

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions