static void Main(string[] args) { var db1Metrics = new MetricRegistry(); var reporter = ConsoleReporter.ForRegistry(db1Metrics).build(); var meter = db1Metrics.Meter("testMeter"); var randomHist = db1Metrics.Histogram("testHist"); //var machineMetrics = MachineMetrics.Create(MachineMetricsCategory.All); //db1Metrics.Register("MachineMetrics", machineMetrics); //reporter.Start(1, TimeUnit.Seconds); CsvReporter creporter = CsvReporter.forRegistry(db1Metrics).build("c:\\merchlog"); //creporter.Start(1, TimeUnit.Seconds); Graphite sender = new Graphite("ttolley-lap3", 2003); GraphiteReporter greporter = GraphiteReporter.ForRegistry(db1Metrics).Build(sender); greporter.Start(10, TimeUnit.Seconds); //var docsTimedCounterPerSec = db1Metrics.TimedCounter("db1", "docs new indexed/sec", "new Indexed Documents"); int i = 0; db1Metrics.Gauge <int>("testGauge", () => i); Random r = new Random(); var counter = db1Metrics.Counter("testCounter"); for (; i < 10000; i++) { meter.Mark(); counter.Increment(i); randomHist.Update(r.Next(101)); Thread.Sleep(100); } Console.WriteLine("Done counting"); for (i = 0; i < 10; i++) { Thread.Sleep(60000); } //Console.WriteLine(docsTimedCounterPerSec.CurrentValue); /*var RequestsPerSecondHistogram = db1Metrics.Histogram("db1.Request Per Second Histogram"); * for (int i = 0; i < 100; i++) * { * RequestsPerSecondCounter.Mark(); * RequestsPerSecondHistogram.Update((long)RequestsPerSecondCounter.CurrentValue); * Thread.Sleep(10); * } * StringBuilder sb = new StringBuilder(); * double[] res; * var perc = RequestsPerSecondHistogram.Percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999); * res = perc; * RequestsPerSecondHistogram.LogJson(sb,perc); * Console.WriteLine(sb); * Console.WriteLine(RequestsPerSecondHistogram.Percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999)); * // RequestsPerSecondHistogram.Update((long)documentDatabase.WorkContext.MetricsCounters.RequestsPerSecondCounter.CurrentValue); //?? */ }
// Returns source code of a demo file public static string GetSourceCode(string suffix, bool dicFiles, int intActiveIndex, string path, Graphite.Internal.Config config) { string strFileName = "default"; if (dicFiles == false) { int intMenuItemActive = intActiveIndex; strFileName = config.Type(intMenuItemActive); } string strRoot = HttpContext.Current.Server.MapPath(path) + "\\"; StringBuilder sbCode = new StringBuilder(); try { System.IO.StreamReader sr = new System.IO.StreamReader(strRoot + strFileName + suffix); string line; while (sr.Peek() != -1) { line = sr.ReadLine(); sbCode.AppendLine(line); } sr.Close(); sr.Dispose(); } catch (Exception exp) { // } return sbCode.ToString(); }
public override void Init() { // Setup Graphite reporting //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final com.codahale.metrics.graphite.Graphite graphite = new com.codahale.metrics.graphite.Graphite(hostnamePort.getHost(), hostnamePort.getPort()); Graphite graphite = new Graphite(_hostnamePort.Host, _hostnamePort.Port); _graphiteReporter = GraphiteReporter.forRegistry(_registry).prefixedWith(_prefix).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL).build(graphite); }
public void FailingSend_ThrowsException() { var mockClient = new Mock <IGraphiteClient>(); mockClient.Setup(x => x.Send(It.IsAny <string>(), It.IsAny <double>())).Throws <Exception>(); var graphite = new Graphite(_log, _settings, mockClient.Object); Assert.Throws <Exception>(() => { graphite.Send("test", 1); }); }
public void Send_Datapoint_Works() { var mockClient = new Mock <IGraphiteClient>(); mockClient.Setup(x => x.Send(It.IsAny <Datapoint[]>())); _settings.ThrowExceptions = true; var graphite = new Graphite(_log, _settings, mockClient.Object); Assert.DoesNotThrow(() => { graphite.Send(new Datapoint("test", 1, DateTime.UtcNow)); }); }
public void Send_Works() { var mockClient = new Mock <IGraphiteClient>(); mockClient.Setup(x => x.Send(It.IsAny <string>(), It.IsAny <double>())); _settings.ThrowExceptions = true; var graphite = new Graphite(_log, _settings, mockClient.Object); Assert.DoesNotThrow(() => { graphite.Send("test", 1); }); }
public ShapeSelector(Graphite.Shapes.Manager shapeMan) { _shapeMan = shapeMan; foreach (Graphite.Core.Shape sh in _shapeMan.Shapes) Items.Add (sh.name ()); DropDownStyle = ComboBoxStyle.DropDownList; SelectedIndex = 0; }
public void NullHost_ThrowsException() { _settings.ThrowExceptions = true; _settings.Host = null; var cakeLog = new FakeLog(); Assert.Throws <ArgumentNullException>(() => { _graphite = new Graphite(cakeLog, _settings); }); }
public void Setup() { _settings = new GraphiteSettings() { Host = "192.0.2.0", HttpApiPort = 10, BatchSize = 500, ThrowExceptions = true }; var cakeLog = new FakeLog(); _graphite = new Graphite(cakeLog, _settings); }
public static string GetCodeBehind(string ascxSource, string cssClass, string path, Graphite.Internal.Config config, int activeIndex) { string strCode = ""; // Get URL to Codebehind string strCodeBehindURL = ""; int intCodeFileStart = ascxSource.IndexOf("CodeFile=", StringComparison.OrdinalIgnoreCase); int intIgnoreCodeFile = ascxSource.IndexOf("<!-- Graphite: Ignore Codefile -->", StringComparison.OrdinalIgnoreCase); int intStartQuote = ascxSource.IndexOf("\"", intCodeFileStart); int intEndQuote = ascxSource.IndexOf("\"", (intStartQuote + 1)); if (intStartQuote >= 0) { strCodeBehindURL = ascxSource.Substring((intStartQuote + 1), (intEndQuote - intStartQuote - 1)); } string strRoot = HttpContext.Current.Server.MapPath(path) + "\\"; if (intIgnoreCodeFile >= 0) { // Get Codebehind code try { StringBuilder sbCode = new StringBuilder(); System.IO.StreamReader sr = new System.IO.StreamReader(strRoot + strCodeBehindURL); while (sr.Peek() != -1) { string line = sr.ReadLine(); sbCode.AppendLine(line); } sr.Close(); sr.Dispose(); strCode = sbCode.ToString(); // Insert class into private variable _strRootClass int rootClassStart = strCode.IndexOf("_strRootClass", StringComparison.OrdinalIgnoreCase); int rootClassValueStart = strCode.IndexOf("\"\"", rootClassStart); strCode = strCode.Insert(rootClassValueStart + 1, config.CssClass(activeIndex)); } catch (Exception exp) { // No Codebehind available } } return strCode; }
public static void Main(string[] args) { Console.WriteLine(typeof(Exception).IsAssignableFrom(typeof(ArgumentNullException))); Console.WriteLine(typeof(ArgumentNullException).IsAssignableFrom(typeof(Exception))); IKernel kernel = new StandardKernel(); MetricRegistry registry = new MetricRegistry(); kernel.Bind <MetricRegistry>().ToConstant <MetricRegistry>(registry); Tryout t = kernel.Get <Tryout>(); ConsoleReporter reporter = ConsoleReporter.ForRegistry(registry).build(); reporter.Start(1, TimeUnit.Seconds); Graphite sender = new Graphite("ttolley-lap3", 2003); GraphiteReporter greporter = GraphiteReporter.ForRegistry(registry).Build(sender); greporter.Start(10, TimeUnit.Seconds); int i = 0; Random r = new Random(); for (; i < 10000; i++) { try { t.Test(r.Next(101)); } catch { // Do nothing } } Console.WriteLine("Done counting"); for (i = 0; i < 10; i++) { Thread.Sleep(60000); } }
public void SendingWithPrefix_Works() { const string prefix = "prefix_test"; const string testMetricName = "test"; string returnValue = null; var expectedName = $"{prefix}.{testMetricName}"; _settings.Prefix = prefix; var mockClient = new Mock <IGraphiteClient>(); mockClient.Setup(x => x.Send(It.IsAny <string>(), It.IsAny <double>())) .Callback((string metricName, double value) => { returnValue = metricName; }); var graphite = new Graphite(_log, _settings, mockClient.Object); graphite.Send(testMetricName, 1); Assert.IsNotNull(returnValue); Assert.AreEqual(returnValue, expectedName); }
public void SendingDatapointWithPrefix_Works() { const string prefix = "prefix_test"; const string testMetricName = "test"; string returnValue = null; var expectedName = $"{prefix}.{testMetricName}"; _settings.Prefix = prefix; var mockClient = new Mock <IGraphiteClient>(); mockClient.Setup(x => x.Send(It.IsAny <ICollection <Datapoint> >())) .Callback((ICollection <Datapoint> x) => { returnValue = x.First().Series; }); mockClient.Setup(x => x.Send(It.IsAny <Datapoint>())) .Callback((Datapoint[] x) => { returnValue = x[0].Series; }); var graphite = new Graphite(_log, _settings, mockClient.Object); graphite.Send(new Datapoint(testMetricName, 1, DateTime.Now)); Assert.IsNotNull(returnValue); Assert.AreEqual(expectedName, returnValue); }
public Idle(Graphite.Core.Document doc, Graphite.Core.IUISet ui) : base(doc, ui) { }
public Edge(Graphite.Core.Edge edge) { _assignedEdge = edge; }
public void VertexRemoved(Graphite.Core.Vertex v) { var element = _vertexVisuals.First (x => x.AssignedTo == v); _vertexVisuals.Remove (element); Refresh (); }
public void VertexDisconnected(Graphite.Core.Vertex a, Graphite.Core.Vertex b) { UpdateEdges (); Refresh (); }
public void VertexAdded(Graphite.Core.Vertex v) { _vertexVisuals.Add (new Graphite.Scene.Elements.Vertex (v)); Refresh (); }
public System.Drawing.Color Color(Graphite.Scene.Elements.Vertex v) { if (v.Marked) return System.Drawing.Color.Red; else return (v.Selected ? SystemColors.Highlight : System.Drawing.Color.Black); }
public State(Graphite.Core.Document doc, Graphite.Core.IUISet ui) { _document = doc; _ui = ui; }
public Deleting(Graphite.Core.Document doc, Graphite.Core.IUISet ui) : base(doc, ui) { }
public Disconnecting(Graphite.Core.Document doc, Graphite.Core.IUISet ui) : base(doc, ui) { }
protected void RenderId(Graphite.Scene.Elements.Vertex v, Graphics g) { var text = v.AssignedTo.Id.ToString (); TextRenderer.DrawText (g, text, Font, boundingBox(v), Color (v), TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); }
protected virtual Rectangle boundingBox(Graphite.Scene.Elements.Vertex v) { var vertex = (v as Graphite.Scene.Elements.Vertex).AssignedTo; return Graphite.Math.Geom.Square (vertex.Position, radius); }
public Vertex(Graphite.Core.Vertex vertex) { _assignedVertex = vertex; }
protected override Rectangle boundingBox(Graphite.Scene.Elements.Vertex v) { var r = base.boundingBox (v); r.Offset (0, radius / 3); return r; }