public MetricsHttpListener(string listenerUriPrefix, MetricsRegistry registry, Func<HealthStatus> healthStatus)
 {
     this.httpListener = new HttpListener();
     this.httpListener.Prefixes.Add(listenerUriPrefix);
     this.registry = registry;
     this.healthStatus = healthStatus;
 }
Beispiel #2
0
        internal RpcMetrics(Server server, Configuration conf)
        {
            string port = server.GetListenerAddress().Port.ToString();

            name        = "RpcActivityForPort" + port;
            this.server = server;
            registry    = new MetricsRegistry("rpc").Tag("port", "RPC port", port);
            int[] intervals = conf.GetInts(CommonConfigurationKeys.RpcMetricsPercentilesIntervalsKey
                                           );
            rpcQuantileEnable = (intervals.Length > 0) && conf.GetBoolean(CommonConfigurationKeys
                                                                          .RpcMetricsQuantileEnable, CommonConfigurationKeys.RpcMetricsQuantileEnableDefault
                                                                          );
            if (rpcQuantileEnable)
            {
                rpcQueueTimeMillisQuantiles      = new MutableQuantiles[intervals.Length];
                rpcProcessingTimeMillisQuantiles = new MutableQuantiles[intervals.Length];
                for (int i = 0; i < intervals.Length; i++)
                {
                    int interval = intervals[i];
                    rpcQueueTimeMillisQuantiles[i] = registry.NewQuantiles("rpcQueueTime" + interval
                                                                           + "s", "rpc queue time in milli second", "ops", "latency", interval);
                    rpcProcessingTimeMillisQuantiles[i] = registry.NewQuantiles("rpcProcessingTime" +
                                                                                interval + "s", "rpc processing time in milli second", "ops", "latency", interval
                                                                                );
                }
            }
            Log.Debug("Initialized " + registry);
        }
 protected BaseMetricsContext(string context, MetricsRegistry registry, MetricsBuilder metricsBuilder, Func <DateTime> timestampProvider)
 {
     this.context        = context;
     this.registry       = registry;
     this.metricsBuilder = metricsBuilder;
     this.DataProvider   = new DefaultDataProvider(this.context, timestampProvider, this.registry.DataProvider, () => this.childContexts.Values.Select(c => c.DataProvider));
 }
Beispiel #4
0
        public static string GetAsHumanReadable(MetricsRegistry registry, Func <HealthStatus> healthStatus)
        {
            var report = new StringReporter();

            report.RunReport(registry, healthStatus);
            return(report.Result);
        }
 public ModuleConfig(MetricsRegistry registry, Func <HealthStatus> healthStatus, Action <INancyModule> moduleConfig, string metricsPath)
 {
     this.Registry           = registry;
     this.HealthStatus       = healthStatus;
     this.ModuleConfigAction = moduleConfig;
     this.ModulePath         = metricsPath;
 }
Beispiel #6
0
        public override void Run()
        {
            try {
                var format = new SimpleDateFormat("s", _locale);
                var dateTime = DateTimeEx.GetInstance(_timeZone, _clock.Time());
                var dateTimeString = format.Format(dateTime);
                _writer.Write(dateTimeString);
                _writer.Write(' ');
                for (var i = 0; i < CONSOLE_WIDTH - dateTimeString.Length - 1; i++) {
                    _writer.Write('=');
                }

                _writer.WriteLine();
                foreach (var entry in MetricsRegistry.GroupedMetrics(_predicate)) {
                    _writer.Write(entry.Key);
                    _writer.WriteLine(':');
                    foreach (var subEntry in entry.Value) {
                        _writer.Write("  ");
                        _writer.Write(subEntry.Key.Name);
                        _writer.WriteLine(':');
                        subEntry.Value.ProcessWith(this, subEntry.Key, _writer);
                        _writer.WriteLine();
                    }

                    _writer.WriteLine();
                }

                _writer.WriteLine();
                _writer.Flush();
            }
            catch (Exception e) {
                _writer.WriteLine(e.StackTrace);
            }
        }
Beispiel #7
0
 internal RpcDetailedMetrics(int port)
 {
     name     = "RpcDetailedActivityForPort" + port;
     registry = new MetricsRegistry("rpcdetailed").Tag("port", "RPC port", port.ToString
                                                           ());
     Log.Debug(registry.Info());
 }
Beispiel #8
0
 /// <summary>
 /// Configure NancyFx integration
 /// </summary>
 /// <param name="config">Chainable configuration object.</param>
 /// <param name="registry">Custom metrics registry.</param>
 /// <param name="healthStatus">Custom health checks status</param>
 /// <param name="nancyConfig">Action to configure NancyFx integration.</param>
 /// <returns>Chainable configuration object.</returns>
 public static MetricsConfig WithNancy(this MetricsConfig config, MetricsRegistry registry, Func <HealthStatus> healthStatus,
                                       Action <NancyMetricsConfig> nancyConfig)
 {
     CurrentConfig = new NancyMetricsConfig(registry, healthStatus);
     nancyConfig(CurrentConfig);
     return(config);
 }
Beispiel #9
0
 public ModuleConfig(MetricsRegistry registry, Func<HealthStatus> healthStatus, Action<INancyModule> moduleConfig, string metricsPath)
 {
     this.Registry = registry;
     this.HealthStatus = healthStatus;
     this.ModuleConfigAction = moduleConfig;
     this.ModulePath = metricsPath;
 }
 public static void RegisterSystemCounters(MetricsRegistry registry)
 {
     registry.Register("System AvailableRAM", () => new PerformanceCounterGauge("Memory", "Available MBytes"), Unit.Custom("Mb"));
     registry.Register("System CPU Usage", () => new PerformanceCounterGauge("Processor", "% Processor Time", TotalInstance), Unit.Custom("%"));
     registry.Register("System Disk Writes/sec", () => new DerivedGauge(new PerformanceCounterGauge("PhysicalDisk", "Disk Reads/sec", TotalInstance), f => f / 1024), Unit.Custom("kb/s"));
     registry.Register("System Disk Reads/sec", () => new DerivedGauge(new PerformanceCounterGauge("PhysicalDisk", "Disk Writes/sec", TotalInstance), f => f / 1024), Unit.Custom("kb/s"));
 }
 public static void RegisterSystemCounters(MetricsRegistry registry)
 {
     registry.Register("System AvailableRAM", () => new PerformanceCounterGauge("Memory", "Available MBytes"), Unit.Custom("Mb"));
     registry.Register("System CPU Usage", () => new PerformanceCounterGauge("Processor", "% Processor Time", TotalInstance), Unit.Custom("%"));
     registry.Register("System Disk Writes/sec", () => new DerivedGauge(new PerformanceCounterGauge("PhysicalDisk", "Disk Reads/sec", TotalInstance), f => f / 1024), Unit.Custom("kb/s"));
     registry.Register("System Disk Reads/sec", () => new DerivedGauge(new PerformanceCounterGauge("PhysicalDisk", "Disk Writes/sec", TotalInstance), f => f / 1024), Unit.Custom("kb/s"));
 }
Beispiel #12
0
 /// <summary>
 /// Configure NancyFx integration
 /// </summary>
 /// <param name="config">Chainable configuration object.</param>
 /// <param name="registry">Custom metrics registry.</param>
 /// <param name="healthStatus">Custom health checks status</param>
 /// <param name="nancyConfig">Action to configure NancyFx integration.</param>
 /// <returns>Chainable configuration object.</returns>
 public static MetricsConfig WithNancy(this MetricsConfig config, MetricsRegistry registry, Func<HealthStatus> healthStatus,
     Action<NancyMetricsConfig> nancyConfig)
 {
     CurrentConfig = new NancyMetricsConfig(registry, healthStatus);
     nancyConfig(CurrentConfig);
     return config;
 }
        public void CompletelyDisableMetrics()
        {
            if (this.isDisabled)
            {
                return;
            }

            this.isDisabled = true;

            var oldRegistry = this.registry;

            this.registry = new NullMetricsRegistry();
            oldRegistry.ClearAllMetrics();
            using (oldRegistry as IDisposable) { }

            ForAllChildContexts(c => c.Advanced.CompletelyDisableMetrics());

            if (this.ContextShuttingDown != null)
            {
                this.ContextShuttingDown(this, EventArgs.Empty);
            }

            if (this.ContextDisabled != null)
            {
                this.ContextDisabled(this, EventArgs.Empty);
            }
        }
 public BaseMetricsContext(string context, MetricsRegistry registry, MetricsBuilder metricsBuilder)
 {
     this.context        = context;
     this.registry       = registry;
     this.metricsBuilder = metricsBuilder;
     this.DataProvider   = new DefaultDataProvider(this.context, this.registry.DataProvider, () => this.childContexts.Values.Select(c => c.DataProvider));
 }
Beispiel #15
0
 public void Add(string contextName, MetricsRegistry registry)
 {
     if (!this.cntxtRegistry.ContainsKey(contextName))
     {
         this.cntxtRegistry.Add(contextName, registry);
     }
 }
 public MetricsHttpListener(string listenerUriPrefix, MetricsRegistry registry, Func <HealthStatus> healthStatus)
 {
     this.httpListener = new HttpListener();
     this.httpListener.Prefixes.Add(listenerUriPrefix);
     this.registry     = registry;
     this.healthStatus = healthStatus;
 }
Beispiel #17
0
 /// <summary>
 ///     Creates a new <seealso cref="ConsoleReporter" /> for a given metrics registry.
 /// </summary>
 /// <param name="metricsRegistry">the metrics registry</param>
 /// <param name="writer">the <seealso cref="TextWriter" /> to which output will be written</param>
 /// <param name="predicate">
 ///     the <seealso cref="MetricPredicate" /> used to determine whether a metric will be output
 /// </param>
 public ConsoleReporter(
     MetricsRegistry metricsRegistry,
     TextWriter writer,
     MetricPredicate predicate)
     : this(metricsRegistry, writer, predicate, Clock.DefaultClock, TimeZoneInfo.Utc)
 {
 }
Beispiel #18
0
        public async Task <ActionResult <object> > GetFeatureLookup([FromQuery] FeatureRequestModel request)
        {
            _metrics.Measure.Counter.Increment(MetricsRegistry.GetFeatureLookupCounter);

            if (string.IsNullOrEmpty(request?.Key) || !Enum.IsDefined(typeof(ShapeProperties), request.Key))
            {
                return(BadRequest());
            }

            var validate = _shapeServiceResolver(ShapeProperties.BoroughBoundaries.ToString()).GetFeatureLookup(request.X, request.Y);

            if (validate == null)
            {
                return(NoContent());
            }

            var results = _shapeServiceResolver(request.Key).GetFeatureLookup(request.X, request.Y);

            if (results == null)
            {
                return(NotFound());
            }

            _metrics.Measure.Counter.Increment(MetricsRegistry.GetFeatureTypeLookupCounter(request.Key));

            return(await Task.FromResult(Ok(results)));
        }
 public ScheduledReporter(string name, Func<Reporter> reporter, MetricsRegistry registry, Func<HealthStatus> healthStatus, TimeSpan interval, Scheduler scheduler)
 {
     this.reporter = reporter;
     this.registry = registry;
     this.healthStatus = healthStatus;
     this.interval = interval;
     this.scheduler = scheduler;
 }
 public ScheduledReporter(string name, Func <Reporter> reporter, MetricsRegistry registry, Func <HealthStatus> healthStatus, TimeSpan interval, Scheduler scheduler)
 {
     this.reporter     = reporter;
     this.registry     = registry;
     this.healthStatus = healthStatus;
     this.interval     = interval;
     this.scheduler    = scheduler;
 }
 private static void AddMetrics(MetricsRegistry registry)
 {
     var name = "Test";
     registry.Gauge(name, () => 0.0, Unit.Calls);
     registry.Counter(name, Unit.Calls);
     registry.Meter(name, Unit.Calls, TimeUnit.Seconds);
     registry.Histogram(name, Unit.Calls, SamplingType.FavourRecent);
     registry.Timer(name, Unit.Calls, SamplingType.FavourRecent, TimeUnit.Seconds, TimeUnit.Milliseconds);
 }
Beispiel #22
0
 internal RetryCacheMetrics(RetryCache retryCache)
 {
     name     = "RetryCache." + retryCache.GetCacheName();
     registry = new MetricsRegistry(name);
     if (Log.IsDebugEnabled())
     {
         Log.Debug("Initialized " + registry);
     }
 }
Beispiel #23
0
 /// <summary>
 ///     Creates a new <seealso cref="ConsoleReporter" /> for a given metrics registry.
 /// </summary>
 /// <param name="metricsRegistry">the metrics registry</param>
 /// <param name="writer">the <seealso cref="TextWriter" /> to which output will be written</param>
 /// <param name="predicate">
 ///     the <seealso cref="MetricPredicate" /> used to determine whether a metric will be output
 /// </param>
 /// <param name="clock">the <seealso cref="Clock" /> used to print time</param>
 /// <param name="timeZone">the <seealso cref="TimeZone" /> used to print time</param>
 public ConsoleReporter(
     MetricsRegistry metricsRegistry,
     TextWriter writer,
     MetricPredicate predicate,
     Clock clock,
     TimeZoneInfo timeZone)
     : this(metricsRegistry, writer, predicate, clock, timeZone, CultureInfo.CurrentCulture)
 {
 }
        private static void AddMetrics(MetricsRegistry registry)
        {
            var name = "Test";

            registry.Gauge(name, () => 0.0, Unit.Calls);
            registry.Counter(name, Unit.Calls);
            registry.Meter(name, Unit.Calls, TimeUnit.Seconds);
            registry.Histogram(name, Unit.Calls, SamplingType.FavourRecent);
            registry.Timer(name, Unit.Calls, SamplingType.FavourRecent, TimeUnit.Seconds, TimeUnit.Milliseconds);
        }
Beispiel #25
0
        private static void RegisterMetrics()
        {
            registry = new MetricsRegistry(RecordInfo);
            registry.Tag(RecordInfo, "ResourceManager");
            MetricsSystem ms = DefaultMetricsSystem.Instance();

            if (ms != null)
            {
                ms.Register("ClusterMetrics", "Metrics for the Yarn Cluster", Instance);
            }
        }
Beispiel #26
0
        private FSOpDurations()
        {
            registry = new MetricsRegistry(RecordInfo);
            registry.Tag(RecordInfo, "FSOpDurations");
            MetricsSystem ms = DefaultMetricsSystem.Instance();

            if (ms != null)
            {
                ms.Register(RecordInfo.Name(), RecordInfo.Description(), this);
            }
        }
Beispiel #27
0
 /// <summary>
 ///     Enables the console reporter for the given metrics registry, and causes it to print to STDOUT
 ///     with the specified period and unrestricted output.
 /// </summary>
 /// <param name="metricsRegistry">the metrics registry</param>
 /// <param name="period">the period between successive outputs</param>
 /// <param name="unit">the time unit of {@code period}</param>
 public static void Enable(
     MetricsRegistry metricsRegistry,
     long period,
     TimeUnit unit)
 {
     var reporter = new ConsoleReporter(
         metricsRegistry,
         Console.Out,
         AnyMetricPredicate.INSTANCE);
     reporter.Start(period, unit);
 }
 private static void WriteTextMetrics(HttpListenerContext context, MetricsRegistry registry, Func <HealthStatus> healthStatus)
 {
     context.Response.ContentType       = "text/plain";
     context.Response.StatusCode        = 200;
     context.Response.StatusDescription = "OK";
     using (var writer = new StreamWriter(context.Response.OutputStream))
     {
         writer.Write(RegistrySerializer.GetAsHumanReadable(registry, healthStatus));
     }
     context.Response.Close();
 }
 public static string GetAsJson(MetricsRegistry registry)
 {
     return new JsonFormatter()
         .AddTimestamp(Clock.Default)
         .AddObject(registry.Gauges)
         .AddObject(registry.Counters)
         .AddObject(registry.Meters)
         .AddObject(registry.Histograms)
         .AddObject(registry.Timers)
         .GetJson();
 }
Beispiel #30
0
 public static string GetAsJson(MetricsRegistry registry)
 {
     return(new JsonFormatter()
            .AddTimestamp(Clock.Default)
            .AddObject(registry.Gauges)
            .AddObject(registry.Counters)
            .AddObject(registry.Meters)
            .AddObject(registry.Histograms)
            .AddObject(registry.Timers)
            .GetJson());
 }
 public static void RegisterCLRAppCounters(MetricsRegistry registry)
 {
     var app = Process.GetCurrentProcess().ProcessName;
     registry.Register("Mb in all Heaps", () => new DerivedGauge(new PerformanceCounterGauge(Memory, "# Bytes in all Heaps", app), v => v / (1024 * 1024)), Unit.Custom("Mb"));
     registry.Register("Time in GC", () => new PerformanceCounterGauge(Memory, "% Time in GC", app), Unit.Custom("%"));
     registry.Register("Total Exceptions", () => new PerformanceCounterGauge(Exceptions, "# of Exceps Thrown", app), Unit.Custom("Exceptions"));
     registry.Register("Exceptions Thrown / Sec", () => new PerformanceCounterGauge(Exceptions, "# of Exceps Thrown / Sec", app), Unit.Custom("Exceptions/s"));
     registry.Register("Logical Threads", () => new PerformanceCounterGauge(LocksAndThreads, "# of current logical Threads", app), Unit.Custom("Threads"));
     registry.Register("Physical Threads", () => new PerformanceCounterGauge(LocksAndThreads, "# of current physical Threads", app), Unit.Custom("Threads"));
     registry.Register("Contention Rate / Sec", () => new PerformanceCounterGauge(LocksAndThreads, "Contention Rate / Sec", app), Unit.Custom("Attempts/s"));
     registry.Register("Queue Length / sec", () => new PerformanceCounterGauge(LocksAndThreads, "Queue Length / sec", app), Unit.Custom("Threads/s"));
 }
        public static async Task <IForwarder> Create(IConfiguration configuration, string sectionName = null)
        {
            var options = configuration.GetSection(sectionName ?? DefaultConfigurationSectionName).Get <ServiceAgentOptions>();

            var logger = LoggerBuilder.Initialize(configuration);

            var metricsRegistry = MetricsRegistry.CreateRoot(configuration);

            var forwarders = await BuildServiceForwarders(logger, metricsRegistry, options);

            return(new ServiceForwarderHost(metricsRegistry, forwarders));
        }
Beispiel #33
0
        protected internal QueueMetrics(MetricsSystem ms, string queueName, Queue parent,
                                        bool enableUserMetrics, Configuration conf)
        {
            registry       = new MetricsRegistry(RecordInfo);
            this.queueName = queueName;
            this.parent    = parent != null?parent.GetMetrics() : null;

            this.users = enableUserMetrics ? new Dictionary <string, Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.QueueMetrics
                                                             >() : null;
            metricsSystem = ms;
            this.conf     = conf;
            runningTime   = BuildBuckets(conf);
        }
        public static void RegisterCLRAppCounters(MetricsRegistry registry)
        {
            var app = Process.GetCurrentProcess().ProcessName;

            registry.Register("Mb in all Heaps", () => new DerivedGauge(new PerformanceCounterGauge(Memory, "# Bytes in all Heaps", app), v => v / (1024 * 1024)), Unit.Custom("Mb"));
            registry.Register("Time in GC", () => new PerformanceCounterGauge(Memory, "% Time in GC", app), Unit.Custom("%"));
            registry.Register("Total Exceptions", () => new PerformanceCounterGauge(Exceptions, "# of Exceps Thrown", app), Unit.Custom("Exceptions"));
            registry.Register("Exceptions Thrown / Sec", () => new PerformanceCounterGauge(Exceptions, "# of Exceps Thrown / Sec", app), Unit.Custom("Exceptions/s"));
            registry.Register("Logical Threads", () => new PerformanceCounterGauge(LocksAndThreads, "# of current logical Threads", app), Unit.Custom("Threads"));
            registry.Register("Physical Threads", () => new PerformanceCounterGauge(LocksAndThreads, "# of current physical Threads", app), Unit.Custom("Threads"));
            registry.Register("Contention Rate / Sec", () => new PerformanceCounterGauge(LocksAndThreads, "Contention Rate / Sec", app), Unit.Custom("Attempts/s"));
            registry.Register("Queue Length / sec", () => new PerformanceCounterGauge(LocksAndThreads, "Queue Length / sec", app), Unit.Custom("Threads/s"));
        }
        public static async Task <ServiceForwarder> Create(ILogger logger, MetricsRegistry metricsRegistry, ServiceNamespaceOptions serviceNamespace, string entityPath)
        {
            var forwarderIdx = Interlocked.Increment(ref _idx);

            var endpointVia = new UriBuilder("sb", serviceNamespace.ServiceNamespace, -1, entityPath).Uri;

            var tokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(serviceNamespace.AccessRuleName, serviceNamespace.AccessRuleKey);

            var relayListener = new HybridConnectionListener(endpointVia, tokenProvider);

            var metadata = await RelayMetadata.Parse(logger, relayListener);

            return(new ServiceForwarder(logger, metricsRegistry, forwarderIdx, relayListener, metadata, entityPath));
        }
Beispiel #36
0
        public static ClientForwarderHost Create(IConfiguration configuration)
        {
            var options = configuration.GetSection("PortBridge").Get <ClientAgentOptions>();

            var logger = LoggerBuilder.Initialize(configuration);

            logger.Information("Building Client Forwarders");

            var metricsRegistry = MetricsRegistry.CreateRoot(configuration);

            var forwarders = BuildPortForwarders(logger, metricsRegistry, options);

            return(new ClientForwarderHost(metricsRegistry, forwarders));
        }
Beispiel #37
0
        public ClientTcpForwarder(ILogger logger, MetricsRegistry registry, ServiceNamespaceOptions serviceNamespace, int fromPort, PortMappingOptions portMappings)
        {
            _log           = logger.ForContext(GetType());
            _firewallRules = new FirewallRules(portMappings);
            _fromPort      = fromPort;
            _bindTo        = portMappings.BindToAddress;

            var metrics = new TunnelMetrics(registry, new MetricTags(
                                                new [] { "entityPath", "fromPort" }, new [] { portMappings.EntityPath, fromPort.ToString() }));

            _relayFactory = new RelayTunnelFactory(logger, metrics, serviceNamespace, portMappings);

            _log.Information("TCP Forwarder for port {port} initialized", fromPort);
        }
        private ServiceForwarder(ILogger logger, MetricsRegistry registry, int forwarderIdx, HybridConnectionListener listener, RelayMetadata metadata, string entityPath)
        {
            _log = logger.ForContext(GetType());

            _forwarderIdx  = forwarderIdx;
            _relayListener = listener;
            _metadata      = metadata;

            var tags = new MetricTags(nameof(entityPath), entityPath);

            var metrics = new TunnelMetrics(registry, tags);

            _tunnelFactory = new RelayTunnelFactory(logger, metrics);
        }
Beispiel #39
0
        /// <summary>
        /// Configure the Metrics library to use a custom MetricsRegistry.
        /// </summary>
        /// <remarks>
        /// You must call Metric.Config.WithRegistry before any other Metric call.
        /// </remarks>
        /// <param name="registry">The custom registry to use for registering metrics.</param>
        /// <returns>Chainable configuration object.</returns>
        public MetricsConfig WithRegistry(MetricsRegistry registry)
        {
            if (this.isDisabled)
            {
                return this;
            }

            if (this.registry.IsValueCreated)
            {
                throw new InvalidOperationException("Metrics registry has already been created. You must call Metric.Config.WithRegistry before any other Metric call.");
            }

            this.registry = new Lazy<MetricsRegistry>(() => registry);

            return this;
        }
 public static object GetForSerialization(MetricsRegistry registry)
 {
     return new
     {
         Gauges = registry.Gauges.ToDictionary(g => g.Name, g => g.Value),
         Counters = registry.Counters.ToDictionary(c => c.Name, c => c.Value),
         Meters = registry.Meters.ToDictionary(m => m.Name, m => m.Value.Scale(m.RateUnit)),
         Histograms = registry.Histograms.ToDictionary(h => h.Name, h => h.Value),
         Timers = registry.Timers.ToDictionary(t => t.Name, t => t.Value.Scale(t.RateUnit, t.DurationUnit)),
         Units = new
         {
             Gauges = registry.Gauges.ToDictionary(g => g.Name, g => g.Unit.Name),
             Counters = registry.Counters.ToDictionary(c => c.Name, c => c.Unit.Name),
             Meters = registry.Meters.ToDictionary(m => m.Name, m => string.Format("{0}/{1}", m.Unit.Name, m.RateUnit.Unit())),
             Histograms = registry.Histograms.ToDictionary(h => h.Name, h => h.Unit.Name),
             Timers = registry.Timers.ToDictionary(t => t.Name, t => new
             {
                 Rate = string.Format("{0}/{1}", t.Unit.Name, t.RateUnit.Unit()),
                 Duration = t.DurationUnit.Unit()
             })
         }
     };
 }
 public MetricsEndpointMiddleware(OwinMetricsEndpointConfig endpointConfig, MetricsRegistry registry, Func<HealthStatus> healthStatus)
 {
     this.endpointConfig = endpointConfig;
     this.registry = registry;
     this.healthStatus = healthStatus;
 }
 public OwinRequestMetricsConfig( Action<object> middlewareRegistration, MetricsRegistry metricsRegistry)
 {
     this.middlewareRegistration = middlewareRegistration;
     this.metricsRegistry = metricsRegistry;
     this.MetricsPrefix = "Owin";
 }
Beispiel #43
0
 public NancyGlobalMetrics(MetricsRegistry repository)
 {
     this.registry = repository;
     this.MetricsPrefix = "NancyFx";
 }
 public static void RegisterCLRGlobalCounters(MetricsRegistry registry)
 {
     registry.Register(".NET Mb in all Heaps", () => new DerivedGauge(new PerformanceCounterGauge(Memory, "# Bytes in all Heaps", GlobalInstance), v => v / (1024 * 1024)), Unit.Custom("Mb"));
     registry.Register(".NET Time in GC", () => new PerformanceCounterGauge(Memory, "% Time in GC", GlobalInstance), Unit.Custom("%"));
 }
 public ErrorMeterMiddleware(MetricsRegistry registry, string metricName)
 {
     this.errorMeter = registry.Meter(metricName, Unit.Errors, TimeUnit.Seconds);
 }
 public NancyMetricsConfig(MetricsRegistry metricsRegistry, Func<HealthStatus> healthStatus)
 {
     this.metricsRegistry = metricsRegistry;
     this.healthStatus = healthStatus;
 }
 public ActiveRequestCounterMiddleware(MetricsRegistry registry, string metricName)
 {
     this.activeRequests = registry.Counter(metricName, Unit.Custom("ActiveRequests"));
 }
 public TimerForEachRequestMiddleware(MetricsRegistry registry, string metricPrefix)
 {
     this.registry = registry;
     this.metricPrefix = metricPrefix;
 }
 public static string GetAsHumanReadable(MetricsRegistry registry, Func<HealthStatus> healthStatus)
 {
     var report = new StringReporter();
     report.RunReport(registry, healthStatus);
     return report.Result;
 }
 private static void WriteJsonMetrics(HttpListenerContext context, MetricsRegistry registry)
 {
     context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
     context.Response.Headers.Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
     context.Response.ContentType = "application/json";
     context.Response.StatusCode = 200;
     context.Response.StatusDescription = "OK";
     var json = RegistrySerializer.GetAsJson(registry);
     using (var writer = new StreamWriter(context.Response.OutputStream))
     {
         writer.Write(json);
     }
     context.Response.Close();
 }
 public OwinMetricsConfig(IAppBuilder app, MetricsRegistry metricsRegistry)
 {
     this.app = app;
     this.metricsRegistry = metricsRegistry;
     this.MetricsPrefix = "Owin";
 }
Beispiel #52
0
 /// <summary>
 /// Configure NancyFx integration
 /// </summary>
 /// <param name="config">Chainable configuration object.</param>
 /// <param name="registry">Custom metrics registry.</param>
 /// <param name="nancyConfig">Action to configure NancyFx integration.</param>
 /// <returns>Chainable configuration object.</returns>
 public static MetricsConfig WithNancy(this MetricsConfig config, MetricsRegistry registry, Action<NancyMetricsConfig> nancyConfig)
 {
     return config.WithNancy(registry, config.HealthStatus, nancyConfig);
 }
 public PostAndPutRequestSizeHistogramMiddleware(MetricsRegistry registry, string metricName)
 {
     this.histogram = registry.Histogram(metricName, Unit.Bytes, SamplingType.FavourRecent);
 }
Beispiel #54
0
 public MetricsReports(MetricsRegistry metricsRegistry, Func<HealthStatus> healthStatus)
 {
     this.metricsRegistry = metricsRegistry;
     this.healthStatus = healthStatus;
 }
 public RequestTimerMiddleware(MetricsRegistry registry, string metricName)
 {
     this.requestTimer = registry.Timer(metricName, Unit.Requests, SamplingType.FavourRecent, TimeUnit.Seconds, TimeUnit.Milliseconds);
 }
 private static Task GetAsHumanReadable(IDictionary<string, object> environment, MetricsRegistry registry, Func<HealthStatus> healthStatus)
 {
     var report = new StringReporter();
     report.RunReport(registry, healthStatus);
     return WriteResponse(environment, report.Result, "text/plain");
 }
 private static Task GetJsonContent(IDictionary<string, object> environment, MetricsRegistry registry)
 {
     var content = RegistrySerializer.GetAsJson(registry);
     return WriteResponse(environment, content, "application/json");
 }
Beispiel #58
0
 public static void Configure(MetricsRegistry registry, Func<HealthStatus> healthStatus, Action<INancyModule> moduleConfig, string metricsPath)
 {
     MetricsModule.Config = new ModuleConfig(registry, healthStatus, moduleConfig, metricsPath);
 }
Beispiel #59
0
 public OwinMetricsConfig(Action<object> middlewareRegistration, MetricsRegistry registry, Func<HealthStatus> healthStatus)
 {
     this.middlewareRegistration = middlewareRegistration;
     this.registry = registry;
     this.healthStatus = healthStatus;
 }
 private static void WriteTextMetrics(HttpListenerContext context, MetricsRegistry registry, Func<HealthStatus> healthStatus)
 {
     context.Response.ContentType = "text/plain";
     context.Response.StatusCode = 200;
     context.Response.StatusDescription = "OK";
     using (var writer = new StreamWriter(context.Response.OutputStream))
     {
         writer.Write(RegistrySerializer.GetAsHumanReadable(registry, healthStatus));
     }
     context.Response.Close();
 }