Skip to content
Prev Previous commit
Next Next commit
Set Activity.Status on SetErrorStatusOnException
  • Loading branch information
Vishwesh Bankwar committed Mar 27, 2023
commit a28e8614579a2136dd98a4d195cb135e5188b7b2
4 changes: 4 additions & 0 deletions src/OpenTelemetry/Trace/ExceptionProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ public override void OnEnd(Activity activity)

if (snapshot != pointers)
{
// TODO: Remove this when SetStatus is deprecated
activity.SetStatus(Status.Error);
Copy link
Member

@alanwest alanwest Mar 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume there's never a time we'd call this version of SetStatus and not also want to call the "real" version, right?

Here's another spot

We could kill two stones with one bird if we moved the call to activity.SetStatus(ActivityStatusCode) to our extension method. Though, from what I can tell I think that OpenTracing shim is the only other place... so maybe easier to just duplicate the call there as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alanwest I was not aware of this one, will get it updated. what do you think about marking our extension method obsolete?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would support marking it obsolete.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1


// For processors/exporters checking `Status` property.
activity.SetStatus(ActivityStatusCode.Error);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void SetErrorStatusOnExceptionEnabled()
}

Assert.Equal(StatusCode.Error, activity.GetStatus().StatusCode);
Assert.Equal(ActivityStatusCode.Error, activity.Status);
}

[Fact]
Expand Down Expand Up @@ -84,6 +85,7 @@ public void SetErrorStatusOnExceptionDisabled()
}

Assert.Equal(StatusCode.Unset, activity.GetStatus().StatusCode);
Assert.Equal(ActivityStatusCode.Unset, activity.Status);
}

[Fact]
Expand Down