-
Notifications
You must be signed in to change notification settings - Fork 839
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
7f9ef5f
ef46f8f
9590742
a9fb915
500d261
aa731c7
bed6535
c21608c
ec33889
ab67793
189c416
7991abf
448ece8
5a62252
2fdd372
d452c3e
f04bb8d
5aa430e
db6a054
b1776cf
d9e11e8
8fc9659
cb9283e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,5 @@ bin | |
|
||
# Vim | ||
.swp | ||
|
||
.fake | ||
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -418,22 +418,37 @@ private void addTimedEvent(EventData timedEvent) { | |||||||||
|
||||||||||
@Override | ||||||||||
public ReadWriteSpan setStatus(StatusCode statusCode, @Nullable String description) { | ||||||||||
if (statusCode == null) { | ||||||||||
return this; | ||||||||||
} | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove this? |
||||||||||
synchronized (lock) { | ||||||||||
if (!isModifiableByCurrentThread()) { | ||||||||||
logger.log(Level.FINE, "Calling setStatus() on an ended Span."); | ||||||||||
return this; | ||||||||||
} else if (this.status.getStatusCode() == StatusCode.OK) { | ||||||||||
logger.log(Level.FINE, "Calling setStatus() on a Span that is already set to OK."); | ||||||||||
return this; | ||||||||||
if (statusCode == null) { | ||||||||||
return this; // No action if statusCode is null | ||||||||||
} | ||||||||||
this.status = StatusData.create(statusCode, description); | ||||||||||
} | ||||||||||
return this; | ||||||||||
synchronized (lock) { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use spotless to ensure consist code formatting. Please run |
||||||||||
if (!isModifiableByCurrentThread()) { | ||||||||||
logger.log(Level.FINE, "Calling setStatus() on an ended Span."); | ||||||||||
return this; // Prevent modification if the span has ended | ||||||||||
} | ||||||||||
|
||||||||||
// Check the current status and enforce priority rules | ||||||||||
StatusCode currentStatusCode = this.status.getStatusCode(); | ||||||||||
|
||||||||||
// 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."); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only log a warning the target status code is |
||||||||||
return this; // Do not allow lower priority status to override OK | ||||||||||
} else if (currentStatusCode == StatusCode.ERROR && statusCode == StatusCode.UNSET) { | ||||||||||
logger.log(Level.FINE, "Cannot set status to UNSET when current status is ERROR."); | ||||||||||
return this; // Do not allow UNSET to override ERROR | ||||||||||
} | ||||||||||
|
||||||||||
// Set the status, ignoring description if status is not ERROR | ||||||||||
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 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||||||
} | ||||||||||
} | ||||||||||
return this; // Return the current span for method chaining | ||||||||||
} | ||||||||||
|
||||||||||
@Override | ||||||||||
public ReadWriteSpan recordException(Throwable exception) { | ||||||||||
recordException(exception, Attributes.empty()); | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert this change