Skip to content

Commit

Permalink
Set Activity.Status when adding SetErrorStatusOnException (#4336)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishweshbankwar authored Mar 31, 2023
1 parent a274f06 commit 6918866
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
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
activity.SetStatus(Status.Error);

// 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

0 comments on commit 6918866

Please sign in to comment.