Beispiel #1
0
        public SocketMetricsReporter(MetricsReportingSocketOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (options.MetricsOutputFormatter == null)
            {
                throw new ArgumentNullException(nameof(options.MetricsOutputFormatter));
            }
            _options = options ?? throw new ArgumentNullException(nameof(options));

            if (options.FlushInterval < TimeSpan.Zero)
            {
                throw new InvalidOperationException($"{nameof(MetricsReportingSocketOptions.FlushInterval)} must not be less than zero");
            }

            Formatter = options.MetricsOutputFormatter;

            FlushInterval = options.FlushInterval > TimeSpan.Zero
                ? options.FlushInterval
                : AppMetricsConstants.Reporting.DefaultFlushInterval;

            Filter = options.Filter;

            _socketClient = new DefaultSocketClient(options);

            Logger.Info($"Using Metrics Reporter {this}. Output: {_socketClient.Endpoint} FlushInterval: {FlushInterval}");
        }
Beispiel #2
0
        static void run()
        {
            ClientHandler handler = new ClientHandler();

            DefaultSocketClient client = new DefaultSocketClient(IPAddress.Parse("127.0.0.1"), 8008, handler, new DefaultEncoder());
            handler._client = client;
            client.Start();

            UserInfo info = null;
            string msg = "messagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessagemessage";
            for (int i = 0; ; i++)
            {
                info = new UserInfo(msg + msg + msg, 18);
                client.Send(info);
                Thread.Sleep(1);
            }
        }