static DiagnosticsKitHttpModule() { var diagurl = WebConfigurationManager.AppSettings["lowleveldesign.diagnostics.url"]; Uri uri; if (!Uri.TryCreate(diagurl, UriKind.Absolute, out uri)) { throw new ConfigurationErrorsException("Please check lowleveldesign.diagnostics.url key in the appSettings - its value should contain an url " + "pointing to the diagnostics main application (Castle)."); } connector = new HttpCastleConnector(uri); }
public DiagnosticsKitTraceListener(String diagnosticsCastleUri) { connector = new HttpCastleConnector(new Uri(diagnosticsCastleUri)); }
static void Main(string[] args) { int numberOfLogs = 10000; int batchSize = 0; var p = new OptionSet { { "n|nlogs=", "number of logs to generate", v => numberOfLogs = Int32.Parse(v) }, { "b|batchsize=", "send logs in batches", v => batchSize = Int32.Parse(v) }, }; List <String> extra; try { extra = p.Parse(args); } catch (Exception ex) { Console.Write("testlog: "); Console.WriteLine(ex.Message); Console.WriteLine("Try `testlog --help' for more information."); return; } if (extra.Count == 0) { Console.WriteLine("ERROR: Missing diagnostics url."); Console.WriteLine(); p.WriteOptionDescriptions(Console.Out); return; } int errorsCnt = 0; int recordsGenerated = 0; long ticks = 0; using (new Timer((o) => { Console.Write("\rProcessed: {0} / {1} ", recordsGenerated, numberOfLogs); }, null, 0, 500)) { var sw = new Stopwatch(); sw.Start(); using (var connector = new HttpCastleConnector(new Uri(extra[0]))) { var opt = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }; if (batchSize > 0) { Parallel.For(0, numberOfLogs / batchSize, opt, (i) => { var recs = new LogRecord[batchSize]; for (int j = 0; j < batchSize; j++) { recs[j] = GenerateRandomLogRecord(); } try { connector.SendLogRecords(recs); Interlocked.Add(ref ticks, sw.Elapsed.Ticks); Interlocked.Add(ref recordsGenerated, batchSize); } catch (Exception ex) { Interlocked.Increment(ref errorsCnt); Console.WriteLine("Error occured: {0} - {1}", ex.GetType().FullName, ex.Message); } }); } else { Parallel.For(0, numberOfLogs, opt, (i) => { try { connector.SendLogRecord(GenerateRandomLogRecord()); Interlocked.Increment(ref recordsGenerated); } catch (Exception ex) { Interlocked.Increment(ref errorsCnt); Console.WriteLine("Error occured: {0} - {1}", ex.GetType().FullName, ex.Message); } }); } } sw.Stop(); var ts = sw.Elapsed; Console.WriteLine("\rRecords generated: {0}, errors: {1}, time: {2:#,#.##} ms which gives {3:0.000} processed records / sec", recordsGenerated, errorsCnt, ts.TotalMilliseconds, recordsGenerated / ts.TotalSeconds); } }
public override void ActivateOptions() { base.ActivateOptions(); connector = new HttpCastleConnector(new Uri(DiagnosticsCastleUrl)); }
protected override void InitializeTarget() { base.InitializeTarget(); connector = new HttpCastleConnector(new Uri(DiagnosticsCastleUrl)); }