//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void metricsRegisteredAfterStartShouldBeIncluded() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void MetricsRegisteredAfterStartShouldBeIncluded() { MetricRegistry registry = new MetricRegistry(); DynamicAddressPrometheusOutput dynamicOutput = new DynamicAddressPrometheusOutput("localhost", registry, mock(typeof(Log))); System.Action <long> callback = l => { SortedDictionary <string, Gauge> gauges = new SortedDictionary <string, Gauge>(); gauges.put("my.event", () => l); dynamicOutput.Report(gauges, emptySortedMap(), emptySortedMap(), emptySortedMap(), emptySortedMap()); }; registry.register("my.metric", ( Gauge )() => 10); dynamicOutput.Init(); dynamicOutput.Start(); callback(20); string serverAddress = dynamicOutput.ServerAddress; string response = GetResponse(serverAddress); assertTrue(response.Contains("my_metric 10.0")); assertTrue(response.Contains("my_event 20.0")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void eventsShouldBeRedirectedToGauges() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void EventsShouldBeRedirectedToGauges() { MetricRegistry registry = new MetricRegistry(); DynamicAddressPrometheusOutput dynamicOutput = new DynamicAddressPrometheusOutput("localhost", registry, mock(typeof(Log))); System.Action <long> callback = l => { SortedDictionary <string, Gauge> gauges = new SortedDictionary <string, Gauge>(); gauges.put("my.event", () => l); dynamicOutput.Report(gauges, emptySortedMap(), emptySortedMap(), emptySortedMap(), emptySortedMap()); }; callback(10); dynamicOutput.Init(); dynamicOutput.Start(); string serverAddress = dynamicOutput.ServerAddress; assertTrue(GetResponse(serverAddress).Contains("my_event 10.0")); assertTrue(GetResponse(serverAddress).Contains("my_event 10.0")); callback(20); assertTrue(GetResponse(serverAddress).Contains("my_event 20.0")); assertTrue(GetResponse(serverAddress).Contains("my_event 20.0")); }
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); //?? */ }
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); //?? */ }
internal RotatableCsvReporter(MetricRegistry registry, Locale locale, TimeUnit rateUnit, TimeUnit durationUnit, Clock clock, File directory, System.Func <File, RotatingFileOutputStreamSupplier.RotationListener, RotatingFileOutputStreamSupplier> fileSupplierStreamCreator) : base(registry, "csv-reporter", MetricFilter.ALL, rateUnit, durationUnit) { this._locale = locale; this._clock = clock; this._directory = directory; this._fileSupplierStreamCreator = fileSupplierStreamCreator; this._writers = new ConcurrentDictionary <File, CsvRotatableWriter>(); }
internal Builder(MetricRegistry registry) { this.Registry = registry; this.Locale = Locale.Default; this.RateUnit = TimeUnit.SECONDS; this.DurationUnit = TimeUnit.MILLISECONDS; this.Clock = Clock.defaultClock(); }
public Builder(MetricRegistry registry) { this.registry = registry; this.rateUnit = TimeUnit.Seconds; this.durationUnit = TimeUnit.Milliseconds; this.clock = Clock.DefaultClock; this.filter = MetricFilters.ALL; }
public GraphiteOutput(HostnamePort hostnamePort, long period, MetricRegistry registry, Log logger, string prefix) { this._hostnamePort = hostnamePort; this._period = period; this._registry = registry; this._logger = logger; this._prefix = prefix; }
internal PrometheusOutput(HostnamePort hostnamePort, MetricRegistry registry, Log logger, ConnectorPortRegister portRegister) { this._hostnamePort = hostnamePort; this._registry = registry; this._logger = logger; this._portRegister = portRegister; this._eventRegistry = new MetricRegistry(); }
public static void Can_use_gauge_metric() { var queue = new Queue<int>(); var metrics = new MetricRegistry(); var gauge = metrics.Gauge("GaugeTests", () => queue.Count); queue.Enqueue(5); Assert.AreEqual(1, gauge.Value); }
public void Can_inc() { MetricRegistry _metrics = new MetricRegistry(); var counter = _metrics.Counter("CounterTests.Can_count"); Assert.IsNotNull(counter); counter.Increment(); Assert.AreEqual(1, counter.Count); }
internal Builder(MetricRegistry registry) { this.registry = registry; this.clock = Clock.DefaultClock; this.prefix = null; this.rateUnit = TimeUnit.Seconds; this.durationUnit = TimeUnit.Milliseconds; this.filter = MetricFilters.ALL; }
internal Builder(MetricRegistry registry) { this.registry = registry; this.output = Console.Out; this.clock = Clock.DefaultClock; this.rateUnit = TimeUnit.Seconds; this.durationUnit = TimeUnit.Milliseconds; this.filter = MetricFilters.ALL; }
public void Can_dec_multiple() { MetricRegistry _metrics = new MetricRegistry(); var counter = _metrics.Counter("CounterTests.Can_count"); Assert.IsNotNull(counter); counter.Decrement(8); Assert.AreEqual(-8, counter.Count); }
internal CsvOutput(Config config, MetricRegistry registry, Log logger, KernelContext kernelContext, FileSystemAbstraction fileSystem, JobScheduler scheduler) { this._config = config; this._registry = registry; this._logger = logger; this._kernelContext = kernelContext; this._fileSystem = fileSystem; this._scheduler = scheduler; }
public static void Can_use_gauge_metric() { var queue = new Queue <int>(); var metrics = new MetricRegistry(); var gauge = metrics.Gauge("GaugeTests", () => queue.Count); queue.Enqueue(5); Assert.AreEqual(1, gauge.Value); }
public virtual void ContextDestroyed(ServletContextEvent sce) { kmsAudit.Shutdown(); kmsAcls.StopReloader(); jmxReporter.Stop(); jmxReporter.Close(); metricRegistry = null; Log.Info("KMS Stopped"); }
public Neo4jMetricsBuilder(MetricRegistry registry, EventReporter reporter, Config config, LogService logService, KernelContext kernelContext, Dependencies dependencies, LifeSupport life) { this._registry = registry; this._reporter = reporter; this._config = config; this._logService = logService; this._kernelContext = kernelContext; this._dependencies = dependencies; this._life = life; }
public override IInterceptor CreateInterceptor(IProxyRequest request) { if (timer == null) { MetricName metricName = Utils.BuildName(request, Name, Absolute); MetricRegistry registry = request.Context.Kernel.Get <MetricRegistry>(); timer = registry.Timer(metricName); } return(new TimingInterceptor(timer)); }
public void Can_inc_multiple() { MetricRegistry _metrics = new MetricRegistry(); var counter = _metrics.Counter("CounterTests.Can_count"); Assert.IsNotNull(counter); counter.Increment(100); Assert.AreEqual(100, counter.Count); }
public CsvReporter(MetricRegistry registry, string directory, TimeUnit rateUnit, TimeUnit durationUnit, Clock clock, MetricFilter filter) : base(registry, "csv-reporter", filter, rateUnit, durationUnit) { this.directory = directory; this.clock = clock; }
public void Can_dec() { MetricRegistry _metrics = new MetricRegistry(); var counter = _metrics.Counter("CounterTests.Can_count"); Assert.IsNotNull(counter); counter.Decrement(); Assert.AreEqual(-1, counter.Count); }
private ConsoleReporter(MetricRegistry registry, TextWriter output, Clock clock, TimeUnit rateUnit, TimeUnit durationUnit, MetricFilter filter) : base(registry, "console-reporter", filter, rateUnit, durationUnit) { this.output = output; this.clock = clock; }
public override IInterceptor CreateInterceptor(IProxyRequest request) { if (interceptor == null) { MetricName metricName = Utils.BuildName(request, Name, Absolute); MetricRegistry registry = request.Context.Kernel.Get <MetricRegistry>(); Counter counter = registry.Counter(metricName); interceptor = new CountingInterceptor(counter, Monotonic); } return(interceptor); }
public LogRotationMetrics(EventReporter reporter, MetricRegistry registry, Monitors monitors, System.Func <LogRotationMonitor> logRotationMonitorSupplier) { this._registry = registry; this._monitors = monitors; this._logRotationMonitorSupplier = logRotationMonitorSupplier; this._listener = durationMillis => { SortedDictionary <string, Gauge> gauges = new SortedDictionary <string, Gauge>(); gauges.put(LogRotationDuration, () => durationMillis); reporter.Report(gauges, emptySortedMap(), emptySortedMap(), emptySortedMap(), emptySortedMap()); }; }
public CheckPointingMetrics(EventReporter reporter, MetricRegistry registry, Monitors monitors, System.Func <CheckPointerMonitor> checkPointerMonitorSupplier) { this._registry = registry; this._monitors = monitors; this._checkPointerMonitorSupplier = checkPointerMonitorSupplier; this._listener = durationMillis => { SortedDictionary <string, Gauge> gauges = new SortedDictionary <string, Gauge>(); gauges.put(CheckPointDuration, () => durationMillis); reporter.Report(gauges, emptySortedMap(), emptySortedMap(), emptySortedMap(), emptySortedMap()); }; }
private GraphiteReporter(MetricRegistry registry, GraphiteSender graphite, Clock clock, String prefix, TimeUnit rateUnit, TimeUnit durationUnit, MetricFilter filter) : base(registry, "graphite-reporter", filter, rateUnit, durationUnit) { this.graphite = graphite; this.clock = clock; this.prefix = MetricName.build(prefix); }
/// <summary> /// Creates a new <see cref="ScheduledReporter"/> instance /// </summary> /// <param name="registry">the <see cref="MetricRegistry"/> containing the metrics this reporter will report</param> /// <param name="name">the reporter's name</param> /// <param name="filter">the filter for which metrics to report</param> /// <param name="rateUnit">a unit of time</param> /// <param name="durationUnit">a unit of time</param> protected ScheduledReporter(MetricRegistry registry, string name, MetricFilter filter, TimeUnit rateUnit, TimeUnit durationUnit) { this.registry = registry; this.filter = filter; this.rateFactor = rateUnit.ToSeconds(1); this.rateUnit = calculateRateUnit(rateUnit); this.durationFactor = 1.0 / durationUnit.ToNanos(1); this.durationUnit = durationUnit.ToString().ToLowerInvariant(); }
public ServerMetrics(MetricRegistry registry, LogService logService, DependencySatisfier satisfier) { Log userLog = logService.GetUserLog(this.GetType()); this._registry = registry; this._serverThreadView = new ServerThreadViewAnonymousInnerClass(this, userLog); satisfier.SatisfyDependency((ServerThreadViewSetter)_serverThreadView => { Debug.Assert(ServerMetrics.this._serverThreadView != null); ServerMetrics.this._serverThreadView = _serverThreadView; userLog.Info("Server thread metrics have been registered successfully"); }); }
public override IInterceptor CreateInterceptor(IProxyRequest request) { if (meterInterceptor == null) { MetricName metricName = Utils.BuildName(request, Name, Absolute); MetricRegistry registry = request.Context.Kernel.Get <MetricRegistry>(); Meter meter = registry.Meter(metricName); Type t = typeof(Exception); if (ExceptionType != null && ExceptionType.IsSubclassOf(t)) { t = ExceptionType; } meterInterceptor = new ExceptionMeteringInterceptor(meter, t); } return(meterInterceptor); }
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 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); } }
internal DynamicAddressPrometheusOutput(string host, MetricRegistry registry, Log logger) : base(new HostnamePort(host), registry, logger, mock(typeof(ConnectorPortRegister))) { }
public void SetUp() { registry = new MetricRegistry(); }
/// <summary> /// Creates a new <see cref="Builder"/> for <see cref="ConsoleReporter"/> /// </summary> /// <param name="registry">the registry to report</param> /// <returns>a new <see cref="Builder"/> for <see cref="ConsoleReporter"/></returns> public static Builder ForRegistry(MetricRegistry registry) { return(new Builder(registry)); }
/** * Returns a new {@link Builder} for {@link CsvReporter}. * * @param registry the registry to report * @return a {@link Builder} instance for a {@link CsvReporter} */ public static Builder forRegistry(MetricRegistry registry) { return new Builder(registry); }
public virtual void ContextInitialized(ServletContextEvent sce) { try { string confDir = Runtime.GetProperty(KMSConfiguration.KmsConfigDir); if (confDir == null) { throw new RuntimeException("System property '" + KMSConfiguration.KmsConfigDir + "' not defined"); } kmsConf = KMSConfiguration.GetKMSConf(); InitLogging(confDir); Log.Info("-------------------------------------------------------------"); Log.Info(" Java runtime version : {}", Runtime.GetProperty("java.runtime.version" )); Log.Info(" KMS Hadoop Version: " + VersionInfo.GetVersion()); Log.Info("-------------------------------------------------------------"); kmsAcls = new KMSACLs(); kmsAcls.StartReloader(); metricRegistry = new MetricRegistry(); jmxReporter = JmxReporter.ForRegistry(metricRegistry).Build(); jmxReporter.Start(); generateEEKCallsMeter = metricRegistry.Register(GenerateEekMeter, new Meter()); decryptEEKCallsMeter = metricRegistry.Register(DecryptEekMeter, new Meter()); adminCallsMeter = metricRegistry.Register(AdminCallsMeter, new Meter()); keyCallsMeter = metricRegistry.Register(KeyCallsMeter, new Meter()); invalidCallsMeter = metricRegistry.Register(InvalidCallsMeter, new Meter()); unauthorizedCallsMeter = metricRegistry.Register(UnauthorizedCallsMeter, new Meter ()); unauthenticatedCallsMeter = metricRegistry.Register(UnauthenticatedCallsMeter, new Meter()); kmsAudit = new KMSAudit(kmsConf.GetLong(KMSConfiguration.KmsAuditAggregationWindow , KMSConfiguration.KmsAuditAggregationWindowDefault)); // this is required for the the JMXJsonServlet to work properly. // the JMXJsonServlet is behind the authentication filter, // thus the '*' ACL. sce.GetServletContext().SetAttribute(HttpServer2.ConfContextAttribute, kmsConf); sce.GetServletContext().SetAttribute(HttpServer2.AdminsAcl, new AccessControlList (AccessControlList.WildcardAclValue)); // intializing the KeyProvider string providerString = kmsConf.Get(KMSConfiguration.KeyProviderUri); if (providerString == null) { throw new InvalidOperationException("No KeyProvider has been defined"); } KeyProvider keyProvider = KeyProviderFactory.Get(new URI(providerString), kmsConf ); if (kmsConf.GetBoolean(KMSConfiguration.KeyCacheEnable, KMSConfiguration.KeyCacheEnableDefault )) { long keyTimeOutMillis = kmsConf.GetLong(KMSConfiguration.KeyCacheTimeoutKey, KMSConfiguration .KeyCacheTimeoutDefault); long currKeyTimeOutMillis = kmsConf.GetLong(KMSConfiguration.CurrKeyCacheTimeoutKey , KMSConfiguration.CurrKeyCacheTimeoutDefault); keyProvider = new CachingKeyProvider(keyProvider, keyTimeOutMillis, currKeyTimeOutMillis ); } Log.Info("Initialized KeyProvider " + keyProvider); keyProviderCryptoExtension = KeyProviderCryptoExtension.CreateKeyProviderCryptoExtension (keyProvider); keyProviderCryptoExtension = new EagerKeyGeneratorKeyProviderCryptoExtension(kmsConf , keyProviderCryptoExtension); if (kmsConf.GetBoolean(KMSConfiguration.KeyAuthorizationEnable, KMSConfiguration. KeyAuthorizationEnableDefault)) { keyProviderCryptoExtension = new KeyAuthorizationKeyProvider(keyProviderCryptoExtension , kmsAcls); } Log.Info("Initialized KeyProviderCryptoExtension " + keyProviderCryptoExtension); int defaultBitlength = kmsConf.GetInt(KeyProvider.DefaultBitlengthName, KeyProvider .DefaultBitlength); Log.Info("Default key bitlength is {}", defaultBitlength); Log.Info("KMS Started"); } catch (Exception ex) { System.Console.Out.WriteLine(); System.Console.Out.WriteLine("ERROR: Hadoop KMS could not be started"); System.Console.Out.WriteLine(); System.Console.Out.WriteLine("REASON: " + ex.ToString()); System.Console.Out.WriteLine(); System.Console.Out.WriteLine("Stacktrace:"); System.Console.Out.WriteLine("---------------------------------------------------" ); Runtime.PrintStackTrace(ex, System.Console.Out); System.Console.Out.WriteLine("---------------------------------------------------" ); System.Console.Out.WriteLine(); System.Environment.Exit(1); } }