Repository navigation
Conversation
|
Reiley Yang (@reyang) Arthur Little (@littleaj) could you please help reviewing this contribution. In short, it is to improve our exception capturing ability by triming down the stack trace size to what is supported by backend. |
|
vlev a quick comment on naming first. I would rather prefer something different than traceLength. trace is common terminology in Distributed Tracing (a.k.a correlation) and also is sometimes intermixed as logs. This would create yet another confusing. May be exceptionTraceLength or something of that sort is better alternative. Reiley Yang (@reyang) your thoughts on this? PS: Hardcoding is not what I would prefer. Instead, customer configuration is a good choice. However, it still wont solve all the problems and some packets mights still drop because customer misconfigured it. In this case, it might be wise to log a message for troubleshooting when the backend responds with partial accept. |
| public final class DataOfConfigurationForException { | ||
| private boolean enabled = false; | ||
| private int stackSize = Integer.MAX_VALUE; | ||
| private Integer maxStackSize; |
There was a problem hiding this comment.
why do we need Class type Integer instead of primitive type int?
There was a problem hiding this comment.
The idea is to avoid the duplication of decision logic for default values (in xml, sb and agent config). It seems more convenient to keep it in one place (see ExceptionTelemetryOptions.java).
Null value, in case of the absence of specific configuration, seems like a natural choice.
|
|
||
| public int getStackSize() { | ||
| return stackSize; | ||
| public Integer getMaxStackSize() { |
There was a problem hiding this comment.
can this method be converted to return primitive int instead of Boxed type Integer. I do not see any specific need of it.
There was a problem hiding this comment.
The idea is to avoid the duplication of decision logic for default values (in xml, sb and agent config). It seems more convenient to keep it in one place (see ExceptionTelemetryOptions.java).
Null value, in case of the absence of specific configuration, seems like a natural choice.
| ApplicationInsightsProperties.Exceptions exceptionsConfig = applicationInsightsProperties.getExceptions(); | ||
| if (exceptionsConfig != null) { | ||
| Integer maxStackSize = exceptionsConfig.getMaxStackSize(); | ||
| if (maxStackSize != null) { |
There was a problem hiding this comment.
Put a diagnostic log to indicate that default value will be picked for this which is Integer max when it's left null
| telemetryConfiguration.setMaxStackSize(maxStackSize); | ||
| } | ||
| Integer maxTraceLength = exceptionsConfig.getMaxTraceLength(); | ||
| if (maxTraceLength != null) { |
There was a problem hiding this comment.
When this is null, I think default value will be set to Integer Max. We should have a diagnostic log here to indicate that.
| * @param metrics Measurements associated with this exception event. Appear in "custom metrics" in Metrics Explorer. | ||
| */ | ||
| public void trackException(Exception exception, Map<String, String> properties, Map<String, Double> metrics) { | ||
| public void trackException(Throwable exception, Map<String, String> properties, |
There was a problem hiding this comment.
It's a good move to make this signature to accept Throwable. I think this is also not a breaking change.
| private int maxStackSize; | ||
| private int maxTraceLength; | ||
|
|
||
| public ExceptionTelemetryOptions(Integer maxStackSize, Integer maxTraceLength) { |
There was a problem hiding this comment.
I think it's good to comment out that default values would be Integer Max for future readers.
There was a problem hiding this comment.
I've added the description of default values into class level javadoc.
| telemetryClient.track(telemetry); | ||
| if (throwable != null) { | ||
| InternalLogger.INSTANCE.trace("Sending Sql exception"); | ||
| ExceptionTelemetry exceptionTelemetry = new ExceptionTelemetry(throwable); |
There was a problem hiding this comment.
Nice move to consolidate this logic.
| * @param stackSize The max stack size to report. | ||
| * @param exception The exception to track. | ||
| */ | ||
| public ExceptionTelemetry(Throwable exception, int stackSize) { |
There was a problem hiding this comment.
Are you removing this public constructor? In that case it might be a breaking change, though rarely anyone is relying on it.
| ExceptionTelemetry exceptionTelemetry = new ExceptionTelemetry(exception); | ||
|
|
||
| NullPointerException exception1 = new NullPointerException("mock"); | ||
| exceptionTelemetry.setException(exception1); |
There was a problem hiding this comment.
It seems that you have removed this setter in ExceptionTelemetry class. It was a public method and therefore it means it could be a breaking change. I would like to avoid any breaking change here.
Dhaval Doshi (dhaval24)
left a comment
There was a problem hiding this comment.
The design seems to be good, however naming, and some breaking changes needs to be addressed at the very least I think.
|
vlev to give you some more context, we need to think a bit about this design overall. It might be a good idea to have these properties configurable, however it still leaves a gap for users to make this call and it can well end up that they might misconfigure these properties and hence the telemetry doesn't end up in backend. We also need to ensure that the problem is solved ubiquitously across languages. For example I am not sure there is a similar approach taken in C# or other Application Insights SDK. Sergey Kanzhelev (@SergeyKanzhelev) what are your thoughts and how does C# handle this? We need to understand a bit deeply wether we needed adjustments in our backend to handle large exceptions stack traces properly, wether we need a backend adjustment. or if we need to do it on SDK side we need to ensure design is consistent across SDKs. I would put the PR on a small hold so we can have a better design discussion here on Github. vlev much appreciate that you brought light to this topic again. |
Fixes microsoft#804 traceLength renamed into exceptionTraceLength
Fixes microsoft#804 - Logging of exception handling configuration - Backward incompatible changes in ExceptionTelemetry were reverted
I've reverted all breaking changes and renamed traceLength to exceptionTraceLength. |
Well, I agree - this extra configuration can not be treated as a final solution to #482. |
Regarding this, yes it is a perfectly valid scenario. However, we generally recommend users to implement their own class which implements I am fine with either decision, but to make this solution a generic solution, we need to have consistency across different AI SDKs so that we do not confuse users, to adopt to one solution in one language and another solution in another. I know this might sound a bit stringent, but once a configuration change is introduced it remains in the users configuration file for decade and it's very hard to revert it. So I do want to proceed with caution here. |
|
Dhaval Doshi (@dhaval24) Or, maybe, you need some additional input from my side? |
|
Sergey Kanzhelev (@SergeyKanzhelev) do we face similar issue in .NET SDK? If yes, how did we resolved that? If not, what are your thoughts on above approach from vlev |
|
Sergey Kanzhelev (@SergeyKanzhelev), Dhaval Doshi (@dhaval24) Any news on the issue? |
|
Sergey Kanzhelev (@SergeyKanzhelev) do we know if similar issue is problem for .Net SDK? Current behaviour in Java is very worrying and basically means AppInsights is useless as centralised logs. What's the point of having those when I cannot be sure I have all exceptions there? We already had 2 cases in our recent production when important issue was missed (our application happens to have huge stack traces). Dhaval Doshi (@dhaval24) do we have any examples of how we should implement our own TelemetryProcessor to fix the issue above? |
|
Trask Stalnaker (@trask) FYI - this issue persist in our SDK ( where huge stack traces are not sent due to schema limits). This is a design question in general and Reiley Yang (@reyang) (If I remember correctly) also had some thoughts about it. It depends on the type of application. Assuming it is a springboot type application you can easily wire up a processor like this: Springboot application will then wire up this processor. If it's java ee app similar logic exist. Arthur Little (@littleaj) / Trask Stalnaker (@trask) can assist more on it. |
|
Thanks, Let me know if you have some ideas of what I could possibly miss. What I dislike about this implementation the most is that transforming of throwable stackTrace happens twice: first in logsappender and than in my processor. That's going to be performance hit ;-/. |
|
Dhaval Doshi (@dhaval24) Looks like you've decided to stick with the workaround. |
bbf495e to
51fe9c7
Compare
|
closing, addressed by #1702 |
Fix #804 .
Not sure if this contribution should be considerate a significant one.
If it's required to follow some extra procedures, please let me know.