예제 #1
0
 public MetricsHttpListener(string listenerUriPrefix, MetricsRegistry registry, Func<HealthStatus> healthStatus)
 {
     this.httpListener = new HttpListener();
     this.httpListener.Prefixes.Add(listenerUriPrefix);
     this.registry = registry;
     this.healthStatus = healthStatus;
 }
예제 #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);
        }
예제 #3
0
 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));
 }
예제 #4
0
        public static string GetAsHumanReadable(MetricsRegistry registry, Func <HealthStatus> healthStatus)
        {
            var report = new StringReporter();

            report.RunReport(registry, healthStatus);
            return(report.Result);
        }
예제 #5
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;
 }
예제 #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);
            }
        }
예제 #7
0
 internal RpcDetailedMetrics(int port)
 {
     name     = "RpcDetailedActivityForPort" + port;
     registry = new MetricsRegistry("rpcdetailed").Tag("port", "RPC port", port.ToString
                                                           ());
     Log.Debug(registry.Info());
 }
예제 #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);
 }
예제 #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;
 }
예제 #10
0
 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"));
 }
예제 #11
0
 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"));
 }
예제 #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;
 }
예제 #13
0
        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);
            }
        }
예제 #14
0
 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));
 }
예제 #15
0
 public void Add(string contextName, MetricsRegistry registry)
 {
     if (!this.cntxtRegistry.ContainsKey(contextName))
     {
         this.cntxtRegistry.Add(contextName, registry);
     }
 }
예제 #16
0
 public MetricsHttpListener(string listenerUriPrefix, MetricsRegistry registry, Func <HealthStatus> healthStatus)
 {
     this.httpListener = new HttpListener();
     this.httpListener.Prefixes.Add(listenerUriPrefix);
     this.registry     = registry;
     this.healthStatus = healthStatus;
 }
예제 #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)
 {
 }
예제 #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)));
        }
예제 #19
0
 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;
 }
예제 #20
0
 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;
 }
예제 #21
0
 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);
 }
예제 #22
0
 internal RetryCacheMetrics(RetryCache retryCache)
 {
     name     = "RetryCache." + retryCache.GetCacheName();
     registry = new MetricsRegistry(name);
     if (Log.IsDebugEnabled())
     {
         Log.Debug("Initialized " + registry);
     }
 }
예제 #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)
 {
 }
예제 #24
0
        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);
        }
예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #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);
 }
예제 #28
0
 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();
 }
예제 #29
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();
 }
예제 #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());
 }
예제 #31
0
 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));
        }
예제 #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);
        }
예제 #34
0
        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));
        }
예제 #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));
        }
예제 #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);
        }
예제 #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;
        }
예제 #40
0
 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;
 }
예제 #42
0
 public OwinRequestMetricsConfig( Action<object> middlewareRegistration, MetricsRegistry metricsRegistry)
 {
     this.middlewareRegistration = middlewareRegistration;
     this.metricsRegistry = metricsRegistry;
     this.MetricsPrefix = "Owin";
 }
예제 #43
0
 public NancyGlobalMetrics(MetricsRegistry repository)
 {
     this.registry = repository;
     this.MetricsPrefix = "NancyFx";
 }
예제 #44
0
 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("%"));
 }
예제 #45
0
 public ErrorMeterMiddleware(MetricsRegistry registry, string metricName)
 {
     this.errorMeter = registry.Meter(metricName, Unit.Errors, TimeUnit.Seconds);
 }
예제 #46
0
 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;
 }
예제 #49
0
 public static string GetAsHumanReadable(MetricsRegistry registry, Func<HealthStatus> healthStatus)
 {
     var report = new StringReporter();
     report.RunReport(registry, healthStatus);
     return report.Result;
 }
예제 #50
0
 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();
 }
예제 #51
0
 public OwinMetricsConfig(IAppBuilder app, MetricsRegistry metricsRegistry)
 {
     this.app = app;
     this.metricsRegistry = metricsRegistry;
     this.MetricsPrefix = "Owin";
 }
예제 #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);
 }
예제 #54
0
 public MetricsReports(MetricsRegistry metricsRegistry, Func<HealthStatus> healthStatus)
 {
     this.metricsRegistry = metricsRegistry;
     this.healthStatus = healthStatus;
 }
예제 #55
0
 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");
 }
예제 #58
0
 public static void Configure(MetricsRegistry registry, Func<HealthStatus> healthStatus, Action<INancyModule> moduleConfig, string metricsPath)
 {
     MetricsModule.Config = new ModuleConfig(registry, healthStatus, moduleConfig, metricsPath);
 }
예제 #59
0
 public OwinMetricsConfig(Action<object> middlewareRegistration, MetricsRegistry registry, Func<HealthStatus> healthStatus)
 {
     this.middlewareRegistration = middlewareRegistration;
     this.registry = registry;
     this.healthStatus = healthStatus;
 }
예제 #60
0
 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();
 }