I'm adding several custom properties to my AppInsights events using Initialize method of ITelemetryInitializer. Some of them are retrieved from the database or other sources which might fail. The question is, are there any official recommendations from the developers on whether or not a try-catch clause should be included inside of Initialize method?
From what I've observed, throwing an exception inside the method doesn't prevent telemetry from appearing, though the custom properties cannot be seen, as expected. Can I rely on this behaviour? Does it somehow affect performance that I don't handle exceptions manually and let AppInsights' code handle them instead?
It depends, doesn't it. If the telemetry initializer adds multiple custom properties and the first one in line fails with an exception, do you want to try to add the others. If so, put a try/catch around each custom property.
If it is just a single property, or all should not be added as soon as the first one fails then you could choose not to handle the exception. In my opinion however, I would want to have control over the exception propagation and choose for handling them myself. (and maybe ignore them with an empty catch, depending on the situation)
Ignoring them completely may give troubles in the future when the SDK for example is altered to not send the telemetry to App Insights when a telemetry initializer fails with an unhandled exception. At least if you decide to go this route try take a peek in the source code of the SDK to see what happens with the unhandled exception.
Related
In my mobile UWP/iOS app I log but ignore a number of exceptions. I am expecting these exceptions but still want to monitor them without losing the full details of the exception (call stack for example). This means I must use the Crashes.TrackError method rather than the Analytics.TrackEvent method.
However, this causes the ignored exceptions to get mixed in with the unexpected exceptions when I view them in AppCenter under Diagnostics, Issues, Errors. I'd like to split out unexpected exceptions to the Diagnostics, Issues, Crashes category.
Is there anyway to force an exception reported to AppCenter into the Crashes category?
As an alternative, is there any way to set the status of an error reported to AppCenter to Ignored?
I'm having this weard mistake "The object you are trying to update was changed by another user. Please try your change again." I would like to know what is the reason of this without context. There are no logs about it, no exception stacktrace, no information about this mistake in documentation. I believe this is something about Bundles but I want to now the exact reason
GW throws several exceptions related, by example ConcurrentDataChangeException, DBVersionConflictException depending of entity type. It occurs when a bean is modified concurrent by two or more transactions (bundle).
This error usually happens because on one bundle two transaction changes are trying to commit where prior bundle is still not committed.
Let us understand with one example- There is user which does a policy change to add any contact or any other business operation. And at the same time another user open same transaction in his GW PC UI and tries to do some business operation at this GW system throws this error on UI because the pervious bundle is still not committed.
The error trace leads you to some OOTB java classed and I think you can get it from PCLogs from PC UI Server logs.
Hopes this clarifies you.
Actually this happens because your object was updated by someone else on the DB during your db read from the DB and your attempt to write it back into the DB.
GW does this by leveraging the version check from your database object.
The exception message actually tells you who and when did the conflicting update. There're no stack traces that will point you to the cause of the other update.
Root causes might be several - from distributed cache in clustered env going out of sync to actually having some other party doing work on the same entities as you do. So the fix is per case really.
my question should be quite simple, but unfortunately I had no luck in solving it.
Basically, I have some Web API controllers hosted by OWIN and deployed on Azure.
I really need to track down exceptions that occur in each middleware (for example OAuthAuthorizationServerProvider or SignalR Persistent Connections), but I definitely don't have a clue on how to achieve it.
I tried Elmah, but it doesn't seem to work properly with OWIN due to lacking HttpContext.
I tried using log4net, but I'm only able to log exceptions thrown by Web API Controllers using a custom ExceptionFilterAttribute.. others are ignored.
I tried to define a custom LoggerFactory and to assign it in Startup, using app.SetLoggerFactory(new MyLoggerFactory()),
but exception thrown by other middlewares are not logged.
I tried to get at least a meaningful error message sent to the client, but despite <customErrors mode="Off"/> and <deployment retail="false"/>, Azure refuses to return anything but {"message":"an error has occurred"}.. I tried both Azure Web Sites and Azure Cloud Services.
I saw some cloud alternatives that should work with OWIN, like Elmah.io or Raygun.io, but I don't need their cloud features and it is definitely not worth paying hundreds $ per year just to log some exceptions.
What should be the best way to log any possible exception thrown by my application?
Thanks for your help
have you take a look at this link ? http://www.asp.net/web-api/overview/error-handling/web-api-global-error-handling
Because you can't catch all the exceptions using an exceptionFilter, they propose to use a IExceptionLogger and IExceptionHandler to allow global error handling in Web Api 2.
After that, if it's not fit your need, you can construct an OwinMiddleWare that you will place in first position (before the Authenticate stage), this middleware could :
create a requestId in the header of the response
analyse the response code, before sending response, and if it's not a IsSuccessStatusCode, you could log the exception message to a DB and replace the content of the response to send a simple error message to the client using the requestId (to allow you to find the related exception in your db)
hope this help
I'm hosting my workflow services in IIS and I need to perform some custom actions when an instance is faulted for an internal exception during its excecution.
I found the WorkflowUnhandledExceptionBehavior extension, but there I can only use predefined actions. I would like to be able to have some "event" I can subscribe to to be able to run my own logic.
I think I should use a custom behavior, but where could I found a good example?
Thanks
It depends a bit on what you want/need to do. If you add a TrackingParticipant it can receive information about unhandled errors through a WorkflowInstanceUnhandledExceptionRecord.
If any exception occurs inside any activity, it can be easily catch through inbuilt try catch activity. Put a try catch at the workflow level. If any exception generated, catch them and perform your own tasks.
Automation using WatiN is being carried out. Using couple of simultaneous threads to test the application. Few threads are failed and log report/stack trace says the following.
System.InvalidCastException: Specified cast is not valid.
at SHDocVw.IWebBrowser2.get_HWND()
at WatiN.Core.Native.InternetExplorer.IEBrowser.get_hWnd()
at WatiN.Core.Browser.get_hWnd()
at WatiN.Core.DomContainer.StartDialogWatcher()
at WatiN.Core.IE.CreateNewIEAndGoToUri(Uri uri, IDialogHandler logonDialogHandler, Boolean createInNewProcess)
at WatiN.Core.IE..ctor(Boolean createInNewProcess)
at Core.BaseWatinTestWrapper.Run()
Following this exception there is another exception being raised i.e.
System.Runtime.InteropServices.COMException Retrieving the COM class factory for component with CLSID {0002DF01-0000-0000-C000-000000000046} failed due to the following error: 80080005.
Please provide some help. Thanks in advance.
I was also using couple of threads and was getting the same error. Make your main method [MTAThread]. This fixed the problem for me.
If I'm not mistaken, WatiN explicitly is single-threaded [STApartment]
- http://watin.org/documentation/sta-apartmentstate/
If you wish to have such test, I believe you need separate processes in OS-level.
I can't tell for sure does you approach collide with this requirement, yet I'd suggest single instance for single browser (and it's descendent windows / processess).
Also, there might be another hickup - WatiN connects to IE using browser's internals, but if there's any Windows / User Session related activity along the way, this might bring additional confusion.