Skip to content

ActivityTraceFlags is not reflected in Activity Id when updated after activity start() #61857

Open

Description

@vishweshbankwar

Description

ActivityTraceFlags can be updated after activity is started. However, doing so does not update the activity Id.

Reproduction Steps

var activity = new Activity("Test");
activity.Start();
Console.WriteLine("ActivityId Before TraceFlags are set: " + activity.Id);
Console.WriteLine("ActivityTraceFlags Before: " + activity.ActivityTraceFlags);
activity.ActivityTraceFlags |= ActivityTraceFlags.Recorded;
Console.WriteLine("ActivityId After TraceFlags are set: " + activity.Id);
Console.WriteLine("ActivityTraceFlags After: " + activity.ActivityTraceFlags);

---- sample output ----
ActivityId Before TraceFlags are set: 00-b33ee4ebf1fa3d81e0ab30363fe291e2-40f3aace946db1d2-00
ActivityTraceFlags Before: None
ActivityId After TraceFlags are set: 00-b33ee4ebf1fa3d81e0ab30363fe291e2-40f3aace946db1d2-00
ActivityTraceFlags After: Recorded

Expected behavior

Updated ActivityTraceFlags is reflected in Activity.Id

Actual behavior

Updated ActivityTraceFlags is not reflected in Activity.Id

Regression?

No

Known Workarounds

No response

Configuration

No response

Other information

No response

Activity

  1. ghost added
    untriaged
    on Nov 19, 2021
  2. vishweshbankwar commented on Nov 19, 2021

    @vishweshbankwar
    ContributorAuthor

    @cijothomas @tarekgh - Adding it here for tracking.

  3. removed
    untriaged
    on Nov 19, 2021
  4. added this to the 7.0.0 milestone on Nov 19, 2021
  5. cijothomas commented on Nov 22, 2021

    @cijothomas
    Contributor

    For now, there are workarounds which needs to tried first. This issue requires no action, until the workarounds are tried in OpenTelemetry/ApplicationInsights.

  6. modified the milestones: 7.0.0, Future on Jan 11, 2022
  7. modified the milestones: Future, 9.0.0 on Jan 10, 2024
  8. modified the milestones: 9.0.0, 10.0.0 on Aug 7, 2024
  9. modified the milestones: 10.0.0, Future on Jul 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions