-
Notifications
You must be signed in to change notification settings - Fork 155
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
Adding an error to a sub/segment, forces a fault flag. #61
Comments
Sorry for the confusion. The error here means "exception". This method is designed to be called when there is an unhandled error. It adds both error message, stack trace and flag as fault since unhandled errors are programing errors which usually result in program behave unexpectedly. If you want to flag a segment as error you can use
|
It is no big deal. I'm new to X-Ray and wished to understand and use the terminology better. I simply wanted to use custom segments and sub-segments in manual mode to wrap sections of my functions and didn't like 😛 that I was forced to flag all "exceptions" as Faults because I wanted to categorize them like so: 1- Flag the exception as a fault if it something that is handled but I still wish to track. Something like a 3rd party service that fails (HTTP request). I can also see the stack trace on why it failed.
2- Flag the exception as an unhandled error otherwise. Something needs to be handled or fixed due my own code logic/syntax.
3- Flag it as throttling if I have my own throttling logic
4- Flag it as throttling and a fault if a 3rd party service throttles.
5- Flag it as a fault and error if a 3rd party service fault is unhandled.
I can always implement my own tagging in the segment's metadata. So it is no issue I guess. I will leave it up to you 😄 |
These are definitely valid use cases. I think we should add an argument on the |
Another option would be to allow passing a value to /**
* Adds fault flag to the subsegment.
*/
Segment.prototype.addFaultFlag = function addFaultFlag(fault = true) {
this.fault = fault;
};
/**
* Adds error flag to the subsegment.
*/
Segment.prototype.addErrorFlag = function addErrorFlag(error = true) {
this.error = error;
}; Then I could just do: segment.addError(err);
segment.addFaultFlag(false); I'm currently using: function traceError(err: any, fault?: boolean): void {
const seg = getSegment();
if (seg) {
seg.addError(err);
if (!fault) {
// @ts-ignore
seg.fault = false;
seg.addErrorFlag();
}
}
} |
Details
this.addFaultFlag();
aws-xray-sdk-node/packages/core/lib/segments/segment.js
Lines 228 to 234 in b899614
AWS X-ray concepts regarding error categorization
Issue
if
addError
refers directly to client errors then it is a bit confusing that it flags it as a "Fault" and not an "Error" flag.If
addError
is more of an abstract method for all x-ray error types, then I don't have the option to specifiy which kind of x-ray error it is per the categorizations above. And I'm forced to have it flagged as a "Fault".The text was updated successfully, but these errors were encountered: