-
Notifications
You must be signed in to change notification settings - Fork 909
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
Use Span.recordException for logging throwable #813
Use Span.recordException for logging throwable #813
Conversation
ad49556
to
2059831
Compare
instrumentation/jsp-2.3/src/test/groovy/JSPInstrumentationBasicTests.groovy
Show resolved
Hide resolved
instrumentation/ratpack-1.4/src/test/groovy/server/RatpackHttpServerTest.groovy
Show resolved
Hide resolved
.../io/opentelemetry/auto/instrumentation/googlehttpclient/GoogleHttpClientInstrumentation.java
Show resolved
Hide resolved
StringWriter errorString = new StringWriter(); | ||
throwable.printStackTrace(new PrintWriter(errorString)); | ||
span.setAttribute(MoreAttributes.ERROR_STACK, errorString.toString()); | ||
span.recordException(throwable); |
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.
🎉
|
||
@Override | ||
boolean testException() { | ||
// TODO(anuraaga): https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/807 |
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 (endpoint.errored) { | ||
"error.msg" { it == null || it == EXCEPTION.body } | ||
"error.type" { it == null || it == Exception.name } | ||
"error.stack" { it == null || it instanceof String } | ||
} |
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.
no replacement for this?
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.
Don't think so - the exception is recorded in the handler span so isn't on this one. Not sure if this is an issue with the instrumentation or expected though.
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.
ah, makes sense, i think this is expected
@@ -68,6 +68,12 @@ class VertxRxHttpServerTest extends HttpServerTest<Vertx> { | |||
return false | |||
} | |||
|
|||
@Override | |||
boolean testException() { | |||
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/807 |
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.
just helping with the future search 😄
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/807 | |
// TODO(anuraaga): https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/807 |
event(0) { | ||
eventName(SemanticAttributes.EXCEPTION_EVENT_NAME) | ||
attributes { | ||
"${SemanticAttributes.EXCEPTION_TYPE.key()}" errorClass.name | ||
"${SemanticAttributes.EXCEPTION_MESSAGE.key()}" ~/Connection refused:( no further information:)? \/127.0.0.1:$UNUSABLE_PORT/ | ||
"${SemanticAttributes.EXCEPTION_STACKTRACE.key()}" String |
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 are a few places that look like they could use errorEvent
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.
This one's because the message is matched using regex. I could make errorevent more powerful but didn't find enough of these places to warrant it yet.
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.
it looks like you are using errorEvent
in other places with regex?
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.
Ah didn't even notice - message
is the only one in my function without a type parameter mostly by accident :D Yeah I'll use it then
if (endpoint.errored) { | ||
"error.msg" { it == null || it == EXCEPTION.body } | ||
"error.type" { it == null || it == Exception.name } | ||
"error.stack" { it == null || it instanceof String } | ||
} |
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.
Don't think so - the exception is recorded in the handler span so isn't on this one. Not sure if this is an issue with the instrumentation or expected though.
.../io/opentelemetry/auto/instrumentation/googlehttpclient/GoogleHttpClientInstrumentation.java
Show resolved
Hide resolved
instrumentation/jsp-2.3/src/test/groovy/JSPInstrumentationBasicTests.groovy
Show resolved
Hide resolved
event(0) { | ||
eventName(SemanticAttributes.EXCEPTION_EVENT_NAME) | ||
attributes { | ||
"${SemanticAttributes.EXCEPTION_TYPE.key()}" errorClass.name | ||
"${SemanticAttributes.EXCEPTION_MESSAGE.key()}" ~/Connection refused:( no further information:)? \/127.0.0.1:$UNUSABLE_PORT/ | ||
"${SemanticAttributes.EXCEPTION_STACKTRACE.key()}" String |
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.
This one's because the message is matched using regex. I could make errorevent more powerful but didn't find enough of these places to warrant it yet.
instrumentation/ratpack-1.4/src/test/groovy/server/RatpackHttpServerTest.groovy
Show resolved
Hide resolved
event(0) { | ||
eventName(SemanticAttributes.EXCEPTION_EVENT_NAME) | ||
attributes { | ||
"${SemanticAttributes.EXCEPTION_TYPE.key()}" { it == null || it == Exception.name } |
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.
This one I'll update
…-instr-java into use-record-exception
instrumentation/jsp-2.3/src/test/groovy/JSPInstrumentationBasicTests.groovy
Outdated
Show resolved
Hide resolved
…cTests.groovy Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
…try-auto-instr-java into use-record-exception
I found some quirks on the way
Previously, our exception assertions allowed no exception. This seems like a very fragile check, and instead I have gone though and explicitly disabled the exception test itself and we can investigate whether these are limitations of instrumentation, bugs of instrumentation, or expected in Certain instrumentation does not record exception in many tests #807
Many tests actually handle exception and convert to HTTP responses. This makes exception and error to effectively be the same test and suppressing the exception test is probably correct for them. Will confirm in Certain instrumentation does not record exception in many tests #807
Note the removal of tags from some server spans is expected - the new attributes are only for exceptions, we don't map HTTP errors onto them anymore.
I expected this PR to take a while but was even more digging than I expected :) Filed some other issues along the way.
In the process, looks like I fixed the
null
assertions everywhere, so fixes #806