Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Activity.IsStopped Property #63713

Merged
merged 4 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public string? Id
}

public bool IsAllDataRequested { get { throw null; } set { throw null; } }
public bool IsStopped { get { throw null; } }
public System.Diagnostics.ActivityIdFormat IdFormat { get { throw null; } }
public System.Diagnostics.ActivityKind Kind { get { throw null; } }
public string OperationName { get { throw null; } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,11 @@ public ActivityTraceId TraceId
/// </summary>
public bool IsAllDataRequested { get; set;}

/// <summary>
/// Indicate if the this Activity object is stopped
/// </summary>
public bool IsStopped { get => IsFinished; }
tarekgh marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Return the flags (defined by the W3C ID specification) associated with the activity.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ public void ActivityIdOverflow()
Assert.Equal('#', activity.Id[activity.Id.Length - 1]);
}


/// <summary>
/// Tests activity start and stop
/// Checks Activity.Current correctness, Id generation
Expand All @@ -320,6 +319,31 @@ public void StartStop()
Assert.Null(Activity.Current);
}

/// <summary>
/// Tests Activity.IsStopped
/// </summary>
[Fact]
public void IsStoppedTest()
{
var activity = new Activity("activity");
tarekgh marked this conversation as resolved.
Show resolved Hide resolved
Assert.False(activity.IsStopped);
activity.Start();
Assert.False(activity.IsStopped);
Assert.Equal(TimeSpan.Zero, activity.Duration);
activity.Stop();
Assert.NotEqual(TimeSpan.Zero, activity.Duration);
Assert.True(activity.IsStopped);

activity = new Activity("activity");
Assert.False(activity.IsStopped);
activity.Start();
Assert.False(activity.IsStopped);
activity.SetEndTime(DateTime.UtcNow.AddMinutes(1)); // Setting end time shouldn't mark the activity as stopped
Assert.False(activity.IsStopped);
activity.Stop();
Assert.True(activity.IsStopped);
}

/// <summary>
/// Tests Id generation
/// </summary>
Expand Down