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

Set Activity.Status when adding SetErrorStatusOnException #4336

Merged
merged 9 commits into from
Mar 31, 2023
6 changes: 6 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

* Enabling `SetErrorStatusOnException` on TracerProvider will now set the
`Status` property on Activity to `ActivityStatusCode.Error` in case of an error.
This will be done in addition to current behavior of setting `otel.status_code`
tag on activity.
([#4336](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4336))

* Add support for configuring the
[Base2 Exponential Bucket Histogram Aggregation](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#base2-exponential-bucket-histogram-aggregation)
using the `AddView` API. This aggregation is supported by OTLP but not yet by
Expand Down
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
utpilla marked this conversation as resolved.
Show resolved Hide resolved
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