-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add Status field to Activity API #46689
Comments
Tagging subscribers to this area: @tarekgh, @tommcdon, @pjanotti Issue DetailsDiagnosticSource package was enhanced in 5.0 to achieve OpenTelemetry Tracing API scenarios. There were few areas which were required in OpenTelemetry API, but was not included in 5.0, due to timing issues/OpenTelemetry spec not being ready before .NET 5 cut off time. Status spec in OpenTelemetry: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#set-status (Currently, OpenTelemetry works around by storing status inside special Activity.SetTag())
|
@cijothomas @noahfalk I have added the proposed APIs in the issue description. Please have a look and send your feedback. Thanks! |
I don't have any particular objection to the name, but I do think we should check with the API reviewers if a name such as 'None' would better follow .NET naming guidelines?
Perhaps this should be?
Two considerations lead me that direction:
Aside from that, LGTM! |
I kept the same name as the specs defined it. But I am ok with whatever better name will be suggested by the design committee.
Although this is true but we already introduced the property pattern like
This is not really accurate. The .NET design guidelines says the following:
IMHO, I prefer the property than the setter method. Please let me know if you still think otherwise and I can add alternative design option to discuss with the design committee. @cijothomas @reyang do you have any input on the proposal before we offer it to the design commitee? |
I vote for using a method Activity.SetStatus(StatusCode.Error, description: "connection reset"); Rather than these (since it is hard to use): Activity.SetStatus(new ActivityStatus(code, description));
Activity.Status = new ActivityStatus(code, description); Another thing we might consider - what's the behavior if the caller is using |
|
Did you consider if someone has Status object and want to set on the Activity? that will be something Activity.SetStatus(status.Error, status.Description); Which will look not that good compared to Activity.SetStatus(ActivityStatus.Ok.Code, ActivityStatus.Ok.Description); Why you think If I go with your proposal, I would not provide at all.
I'll list all proposal as alternative options and we can discuss it in the design meeting.
I believe we should allow it for flexibility if there were some error and someone else wanted to ignore it. but I don't mind not allowing it if this can lead to wrong behavior. |
I guess nobody would do it? I don't have strong opinion here. Looks like Python is not taking this approach https://github.com/open-telemetry/opentelemetry-python/blob/6489bf50a576c9c772d2f7b78d677cf16b4526ac/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py#L670.
I guess the SetStatus one requires less typing and looks tighter (no need to have two spaces around the
There is a "cool way" which may take advantage of the predefined value https://github.com/open-telemetry/opentelemetry-dotnet/blob/8cda9ef394a1b075fd156d73dace48e48f5b3c9b/test/OpenTelemetry.Tests/Trace/ActivityExtensionsTest.cs#L54. |
Looks to me OTel is using What I am trying to say is with the proposal
I agree with that. I am just looking at the issue from the discoverability side. If someone look at Status property getter and notice no setter, it is difficult to guess there is a setter method. I'll list all proposals so we ensure to discuss it in the review meeting. it is really good getting different opinions and compare between options. |
Ah thanks for correcting my understanding. In that case I withdraw my objection, property setter is fine by me. |
namespace System.Diagnostics
{
public enum ActivityStatusCode
{
Unset = 0,
Ok = 1,
Error = 2
}
public partial class Activity
{
public ActivityStatus Status { get; }
public string? StatusDescription { get; }
public void SetStatus(ActivityStatusCode code, string? description = null);
}
} |
one small update to the approved API is having SetStatus returning activity object to be consistent with the rest of the Set methods inside the class. public Activity SetStatus(ActivityStatusCode code, string? description = null); |
DiagnosticSource package was enhanced in 5.0 to achieve OpenTelemetry Tracing API scenarios. There were few areas which were required in OpenTelemetry API, but was not included in 5.0, due to timing issues/OpenTelemetry spec not being ready before .NET 5 cut off time.
This issue is about "Status" field in Activity. At the time of 5.0 , Status API in OpenTelemetry was not finalized. Now that the field and its intent is finalized in the OpenTelemetry spec, proposing to support this in Activity class.
Status spec in OpenTelemetry: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#set-status
(Currently, OpenTelemetry works around by storing status inside special Activity.SetTag())
The proposal is added by @tarekgh
Proposal
Alternative Proposals
Alternative 1
This option is proposed to have consistency with the other patterns in the Activity class e.g.
SetParentId
,SetStartTime
...etc.Alternative 2
This option is proposed to have less writing when setting the status. like doing
Activty.SetStatus(ActivityStatusCode.Ok, "Success")
instead ofActivity.Status = new ActivityStatus(ActivityStatusCode.Ok, "Success")
If we go with this option, we shouldn't provide the following static properties in the ActivityStatus.
The text was updated successfully, but these errors were encountered: