/// <summary> /// Setup client behaviour - attributes, events /// </summary> private void SetupBacktraceLibrary() { backtraceClient.HandleApplicationException(); //Add new scoped attributes backtraceClient.Attributes["ClientAttributeNumber"] = 1; backtraceClient.Attributes["ClientAttributeString"] = "string attribute"; backtraceClient.Attributes["ClientAttributeCustomClass"] = new { Name = "Backtrace", Type = "Library" }; backtraceClient.Attributes["ComplexObject"] = new Dictionary <string, Uri>() { { "backtrace.io", new Uri("http://backtrace.io") }, { "Google url", new Uri("http://google.com") } }; //Add your own handler to client API backtraceClient.BeforeSend = (BacktraceData <object> model) => { var data = model; data.Attributes.Add("eventAtrtibute", "EventAttributeValue"); if (data.Classifier == null || !data.Classifier.Any()) { data.Attachments.Add("path to attachment"); } return(data); }; backtraceClient.Send($"{DateTime.Now}: Library Initialized"); }
private void SetupClient(Framework.Settings settings) { // setup new Backtrace client instance var credentials = new BacktraceCredentials(settings.BacktraceHost, settings.BacktraceToken); _client = new BacktraceClient(credentials, _attributes, settings.BacktraceDatabasePath, settings.BacktraceClientSiteLimiting); _client.HandleApplicationException(); _client.AsyncRequest = true; _client.HandleApplicationException(); _client.OnServerAnswer = (BacktraceServerResponse response) => { Trace.WriteLine(response); }; _client.WhenServerUnvailable = (Exception e) => { Trace.WriteLine(e.Message); }; }
/// <summary> /// Setup client behaviour - attributes, events /// </summary> private void SetupBacktraceLibrary() { //setup tls support for tested server ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | (SecurityProtocolType)0x00000300 | (SecurityProtocolType)0x00000C00; //create Backtrace library configuration var configuartion = new BacktraceClientConfiguration(credentials) { ReportPerMin = 0 }; //create Backtrace database var database = new BacktraceDatabase(databaseSettings); //setup new client backtraceClient = new BacktraceClient(configuartion, database) { UnpackAggregateExcetpion = true }; //handle all unhandled application exceptions backtraceClient.HandleApplicationException(); //Add new scoped attributes backtraceClient.Attributes["ClientAttributeNumber"] = 1; backtraceClient.Attributes["ClientAttributeString"] = "string attribute"; backtraceClient.Attributes["ClientAttributeCustomClass"] = new { Name = "Backtrace", Type = "Library" }; backtraceClient.Attributes["ComplexObject"] = new Dictionary <string, Uri>() { { "backtrace.io", new Uri("http://backtrace.io") }, { "Google url", new Uri("http://google.com") } }; //Add your own handler to client API backtraceClient.BeforeSend = (BacktraceData model) => { var data = model; data.Attributes.Add("eventAtrtibute", "EventAttributeValue"); if (data.Classifier == null || !data.Classifier.Any()) { data.Attachments.Add("path to attachment"); } return(data); }; }
/// <summary> /// Setup client behaviour - attributes, events /// </summary> private void SetupBacktraceLibrary() { //create Backtrace library configuration var configuartion = new BacktraceClientConfiguration(credentials) { ReportPerMin = 0 }; //create Backtrace database var database = new BacktraceDatabase(databaseSettings); //setup new client backtraceClient = new BacktraceClient(configuartion, database); //handle all unhandled application exceptions backtraceClient.HandleApplicationException(); //Add new scoped attributes backtraceClient.Attributes["ClientAttributeNumber"] = 1; backtraceClient.Attributes["ClientAttributeString"] = "string attribute"; backtraceClient.Attributes["ClientAttributeCustomClass"] = new { Name = "Backtrace", Type = "Library" }; backtraceClient.Attributes["ComplexObject"] = new Dictionary <string, Uri>() { { "backtrace.io", new Uri("http://backtrace.io") }, { "Google url", new Uri("http://google.com") } }; backtraceClient.BeforeSend = (BacktraceData data) => { string json = Newtonsoft.Json.JsonConvert.SerializeObject(data); System.Diagnostics.Trace.WriteLine(json); return(data); }; //Add your own handler to client API backtraceClient.BeforeSend = (BacktraceData model) => { var data = model; data.Attributes.Add("eventAtrtibute", "EventAttributeValue"); if (data.Classifier == null || !data.Classifier.Any()) { data.Attachments.Add("path to attachment"); } return(data); }; }
static void Main() { BacktraceClient backtraceClient = new BacktraceClient( new BacktraceCredentials(@"https://myserver.sp.backtrace.io:6097", "4dca18e8769d0f5d10db0d1b665e64b3d716f76bf182fbcdad5d1d8070c12db0"), reportPerMin: 0 //unlimited number of reports per secound ); backtraceClient.OnUnhandledApplicationException += (Exception e) => { Trace.WriteLine(e.Message); }; backtraceClient.HandleApplicationException(); Application.EnableVisualStyles(); Application.ThreadException += backtraceClient.HandleApplicationThreadException; Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
static void Main() { //create Backtrace library configuration var configuartion = new BacktraceClientConfiguration(credentials) { ReportPerMin = 0 }; //create Backtrace - var database = new BacktraceDatabase(databaseSettings); //initialize new BacktraceClient backtraceClient = new BacktraceClient(configuartion, database); //Setting application exceptions backtraceClient.HandleApplicationException(); Application.EnableVisualStyles(); Application.ThreadException += backtraceClient.HandleApplicationThreadException; Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }