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

setStatus method conforms to the specified behavior regarding status … #6808

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Victorsesan
Copy link

…code priorities and description handling

Relate to #6797

@Victorsesan Victorsesan requested a review from a team as a code owner October 21, 2024 01:16
this.status = StatusData.create(statusCode, description);
}
return this;
synchronized (lock) {
Copy link
Member

Choose a reason for hiding this comment

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

We use spotless to ensure consist code formatting. Please run ./gradlew spotlessApply.

@@ -418,22 +418,37 @@ private void addTimedEvent(EventData timedEvent) {

@Override
public ReadWriteSpan setStatus(StatusCode statusCode, @Nullable String description) {
if (statusCode == null) {
return this;
}
Copy link
Member

Choose a reason for hiding this comment

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

Why remove this?


// Prevent setting a lower priority status
if (currentStatusCode == StatusCode.OK) {
logger.log(Level.FINE, "Calling setStatus() on a Span that is already set to OK.");
Copy link
Member

Choose a reason for hiding this comment

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

Only log a warning the target status code is != StatusCode.OK.

if (statusCode == StatusCode.ERROR) {
this.status = StatusData.create(statusCode, description); // Allow description for ERROR
} else {
this.status = StatusData.create(statusCode, null); // Ignore description for non-ERROR statuses
Copy link
Member

Choose a reason for hiding this comment

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

#nit: Let's skip the extra allocation if the status code doesn't stand to change.

Suggested change
this.status = StatusData.create(statusCode, null); // Ignore description for non-ERROR statuses
if (currentStatusCode != statusCode) {
this.status = StatusData.create(statusCode, null); // Ignore description for non-ERROR statuses
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants