<commit_before>﻿using System;
using Metrics.Core;
using Metrics.PerfCounters;
using Metrics.Reporters;

namespace Metrics
{
    /// <summary>
    /// Helper class to ease interaction with metrics
    /// </summary>
    public static class Metric
    {
        private static Lazy<MetricsRegistry> registry = new Lazy<MetricsRegistry>(() => new LocalRegistry(), true);

        private static readonly Lazy<MetricsReports> reports = new Lazy<MetricsReports>(() => new MetricsReports(Metric.Registry));
        private static readonly Lazy<PerformanceCounters> machineCounters = new Lazy<PerformanceCounters>(() => new PerformanceCounters(Metric.Registry), true);

        /// <summary>
        /// Configure the Metric static class to use a custom MetricsRegistry.
        /// </summary>
        /// <remarks>
        /// You must call Metric.ConfigureDefaultRegistry before any other Metric call.
        /// </remarks>
        /// <param name="registry">The custom registry to use for registring metrics.</param>
        public static void ConfigureDefaultRegistry(MetricsRegistry registry)
        {
            if (Metric.registry.IsValueCreated)
            {
                throw new InvalidOperationException("Metrics registry has already been created. You must call Metric.ConfigureDefaultRegistry before any other Metric call.");
            }
            Metric.registry = new Lazy<MetricsRegistry>(() => registry);
        }

        /// <summary>
        /// Global error handler for the metrics library. If a handler is registered any error will be passed to the handler.
        /// If no error handler is registered the exception will be re-thrown.
        /// </summary>
        public static Action<Exception> ErrorHandler { get; set; }

        /// <summary>
        /// Entry point for metric reporting operations
        /// </summary>
        public static MetricsReports Reports { get { return reports.Value; } }

        /// <summary>
        /// Entry point for registering metrics derived from PerformanceCounters.
        /// </summary>
        public static PerformanceCounters MachineCounters { get { return machineCounters.Value; } }<commit_msg>fix typo<commit_after>﻿using System;
using Metrics.Core;
using Metrics.PerfCounters;
using Metrics.Reporters;

namespace Metrics
{
    /// <summary>
    /// Helper class to ease interaction with metrics
    /// </summary>
    public static class Metric
    {
        private static Lazy<MetricsRegistry> registry = new Lazy<MetricsRegistry>(() => new LocalRegistry(), true);

        private static readonly Lazy<MetricsReports> reports = new Lazy<MetricsReports>(() => new MetricsReports(Metric.Registry));
        private static readonly Lazy<PerformanceCounters> machineCounters = new Lazy<PerformanceCounters>(() => new PerformanceCounters(Metric.Registry), true);

        /// <summary>
        /// Configure the Metric static class to use a custom MetricsRegistry.
        /// </summary>
        /// <remarks>
        /// You must call Metric.ConfigureDefaultRegistry before any other Metric call.
        /// </remarks>
        /// <param name="registry">The custom registry to use for registering metrics.</param>
        public static void ConfigureDefaultRegistry(MetricsRegistry registry)
        {
            if (Metric.registry.IsValueCreated)
            {
                throw new InvalidOperationException("Metrics registry has already been created. You must call Metric.ConfigureDefaultRegistry before any other Metric call.");
            }
            Metric.registry = new Lazy<MetricsRegistry>(() => registry);
        }

        /// <summary>
        /// Global error handler for the metrics library. If a handler is registered any error will be passed to the handler.
        /// If no error handler is registered the exception will be re-thrown.
        /// </summary>
        public static Action<Exception> ErrorHandler { get; set; }

        /// <summary>
        /// Entry point for metric reporting operations
        /// </summary>
        public static MetricsReports Reports { get { return reports.Value; } }

        /// <summary>
        /// Entry point for registering metrics derived from PerformanceCounters.
        /// </summary>
        public static PerformanceCounters MachineCounters { get { return machineCounters.Value; } }
{'fraction_non_alphanumeric': 0.09806629834254144, 'fraction_numerical': 0.0, 'mean_word_length': 2.5440456769983686, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6774976', 'n_tokens_mistral': 1034, 'n_tokens_neox': 1013, 'n_words': 365}