-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Removing full exception trace from 404 error #24195
Removing full exception trace from 404 error #24195
Conversation
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.
shouldn't we do the same thing for 409s (ResourceAlreadyExists) as well?
other than that LGTM. thanks @simplynaveen20
@@ -289,10 +281,18 @@ public void addEvent(String name, Map<String, Object> attributes, OffsetDateTime | |||
|
|||
private void end(int statusCode, Throwable throwable, Context context) { | |||
if (throwable != null) { | |||
tracer.setAttribute(TracerProvider.ERROR_MSG, throwable.getMessage(), context); | |||
tracer.setAttribute(TracerProvider.ERROR_TYPE, throwable.getClass().getName(), context); | |||
if (statusCode == HttpConstants.StatusCodes.NOTFOUND) { |
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.
shouldn't we do the same thing for 409s (ResourceAlreadyExists) as well?
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.
And 412
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.
We talked through all these and decided 404 is more regular business scenario then others. We will wait and watch for other error on customer demand basis
@@ -289,10 +281,18 @@ public void addEvent(String name, Map<String, Object> attributes, OffsetDateTime | |||
|
|||
private void end(int statusCode, Throwable throwable, Context context) { | |||
if (throwable != null) { | |||
tracer.setAttribute(TracerProvider.ERROR_MSG, throwable.getMessage(), context); | |||
tracer.setAttribute(TracerProvider.ERROR_TYPE, throwable.getClass().getName(), context); | |||
if (statusCode == HttpConstants.StatusCodes.NOTFOUND) { |
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 only remove the callstack etc. for 404 with Substatusode 0 - for any SubStatusCode != 0 (like ReadSessionNotAvailable 1002 etc.) we should leave the callstack
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.
Yea sure will add substatus check as well.
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.
Done, added 404/0 check
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.
LGTM except for the 404 with SubStatusCode != 0
tracer.setAttribute(TracerProvider.ERROR_TYPE, throwable.getClass().getName(), context); | ||
tracer.end(statusCode, null, context); | ||
} else { | ||
tracer.setAttribute(TracerProvider.ERROR_MSG, throwable.getMessage(), context); |
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.
BTW, why are we adding those?
tracer.end
will dospan.recordException(t)
- which internally record common exception attributes
https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/RecordEventsReadableSpan.java#L406-L409
So we can remove all ERROR_TYPE/ERROR_MSG attributes logic?
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.
If we remove ERROR_TYPE/ERROR_MSG then we wont be seeing below attributes which was the initial requirement from @trask
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.
Can you please add screenshot for non-404 case? There will be standard otel attributes recorded for exception (exception.type
and exceptions.message
)?
@trask I believe you wanted to have otel semantic exception attributes attached, they have changed and now we are populating new ones + old ones. Are you ok with cosmos removing error.msg
and error.type
? Do you believe we use them anywhere?
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.
yes, I think we should remove those, I had similar thought a few weeks ago but got distracted from opening PR 😓: trask@af44c69
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.
@trask Removed error.msg and error.type.
@lmolkova please see the screen shot when it is not 404/0 (item or collection not found). We cannot differentiate between item and collection not found without parsing cosmos exception diagnostics and it will be error prone in future.
However if the customer logging the exception they can still see the full diagnostics and differentiate
tracer.setAttribute(TracerProvider.ERROR_MSG, throwable.getMessage(), context); | ||
tracer.setAttribute(TracerProvider.ERROR_TYPE, throwable.getClass().getName(), context); | ||
if (statusCode == HttpConstants.StatusCodes.NOTFOUND) { | ||
tracer.setAttribute(TracerProvider.ERROR_MSG, "Not found exception", context); |
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.
I believe 404 statusCode is enough and the core tracer will populate all the info needed.
Can we avoid populating custom error codes?
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.
If we remove ERROR_TYPE/ERROR_MSG then we wont be seeing below attributes which was the initial requirement from @trask
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.
since this is no longer an exception, it shouldn't have exception attributes - otel.status_description
gives user the info they need
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.
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.
Removed error.msg and error.type
Added 404/0 filter
This PR contains below changes
Before the change
After the change