/// <summary>
        /// Initializes a new instance of the <see cref="SumoLogicSink"/> class.
        /// </summary>
        /// <param name="log">The log service.</param>
        /// <param name="httpMessageHandler">HTTP message handler.</param>
        /// <param name="connection">Connection configuration.</param>
        /// <param name="source">Event source describer.</param>
        /// <param name="formatter">Text formatter.</param>
        public SumoLogicSink(
            ILog log,
            HttpMessageHandler httpMessageHandler,
            SumoLogicConnection connection,
            SumoLogicSource source,
            ITextFormatter formatter)
        {
            if (connection is null)
            {
                throw new ArgumentNullException(nameof(connection));
            }

            this.source    = source ?? throw new ArgumentNullException(nameof(source));
            this.formatter = formatter ?? throw new ArgumentNullException(nameof(formatter));

            this.logService = log ?? new DummyLog();

            this.messageSender = new SumoLogicMessageSender(httpMessageHandler, this.logService)
            {
                Url               = connection.Uri,
                ClientName        = connection.ClientName,
                ConnectionTimeout = connection.ConnectionTimeout,
                RetryInterval     = connection.RetryInterval,
            };
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SumoLogicSink"/> class.
        /// </summary>
        /// <param name="log">The log service.</param>
        /// <param name="httpMessageHandler">HTTP message handler.</param>
        /// <param name="connection">Connection configuration.</param>
        /// <param name="source">Event source describer.</param>
        /// <param name="formatter">Text formatter.</param>
        public SumoLogicSink(
            ILog log,
            HttpMessageHandler httpMessageHandler,
            SumoLogicConnection connection,
            SumoLogicSource source,
            ITextFormatter formatter)
        {
            if (connection is null)
            {
                throw new ArgumentNullException(nameof(connection));
            }

            if (source is null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            _formatter = formatter ?? throw new ArgumentNullException(nameof(formatter));
            _log       = log ?? new DummyLog();

            _messageSender = MessageSenderFactory.CreateMessageSender(_log, httpMessageHandler, connection);
            _messageQueue  = MessageQueueFactory.CreateMessageQueue(_log, connection);
            SumoLogicMessageSenderBufferFlushingTask flushBufferTask = FlushBufferTaskFactory.CreateFlushBufferTask(
                _log,
                _messageSender,
                _messageQueue,
                connection,
                source);

            _flushBufferTimer = new Timer(
                _ => flushBufferTask.Run(),
                null,
                TimeSpan.FromMilliseconds(0),
                connection.FlushingAccuracy);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BufferedSumoLogicSink"/> class.
        /// </summary>
        /// <param name="log">The log service.</param>
        /// <param name="httpMessageHandler">HTTP message handler.</param>
        /// <param name="connection">Connection configuration.</param>
        /// <param name="source">Event source describer.</param>
        /// <param name="formatter">Text formatter.</param>
        public BufferedSumoLogicSink(
            ILog log,
            HttpMessageHandler httpMessageHandler,
            SumoLogicConnection connection,
            SumoLogicSource source,
            ITextFormatter formatter)
        {
            if (connection is null)
            {
                throw new ArgumentNullException(nameof(connection));
            }

            if (source is null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            this.formatter  = formatter ?? throw new ArgumentNullException(nameof(formatter));
            this.logService = log ?? new DummyLog();

            this.messageSender = new SumoLogicMessageSender(httpMessageHandler, this.logService)
            {
                Url               = connection.Uri,
                ClientName        = connection.ClientName,
                ConnectionTimeout = connection.ConnectionTimeout,
                RetryInterval     = connection.RetryInterval,
            };

            this.messageQueue = new BufferWithFifoEviction <string>(
                connection.MaxQueueSizeBytes,
                new StringLengthCostAssigner(),
                this.logService);

            this.flushBufferTask = new SumoLogicMessageSenderBufferFlushingTask(
                this.messageQueue,
                this.messageSender,
                connection.MaxFlushInterval,
                connection.MessagesPerRequest,
                source.SourceName,
                source.SourceCategory,
                source.SourceHost,
                this.logService);

            this.flushBufferTimer = new Timer(
                _ => flushBufferTask.Run(), // No task await to avoid unhandled exception
                null,
                TimeSpan.FromMilliseconds(0),
                connection.FlushingAccuracy);
        }
 public static SumoLogicMessageSenderBufferFlushingTask CreateFlushBufferTask(
     ILog log,
     SumoLogicMessageSender messageSender,
     BufferWithEviction <string> messageQueue,
     SumoLogicConnection connection,
     SumoLogicSource source) =>
 new SumoLogicMessageSenderBufferFlushingTask(
     messageQueue,
     messageSender,
     connection.MaxFlushInterval,
     connection.MessagesPerRequest,
     source.SourceName,
     source.SourceCategory,
     source.SourceHost,
     log);
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SumoLogicUnbufferedSink"/> class.
        /// </summary>
        /// <param name="log">The log service.</param>
        /// <param name="httpMessageHandler">HTTP message handler.</param>
        /// <param name="connection">Connection configuration.</param>
        /// <param name="source">Event source describer.</param>
        /// <param name="formatter">Text formatter.</param>
        public SumoLogicUnbufferedSink(
            ILog log,
            HttpMessageHandler httpMessageHandler,
            SumoLogicConnection connection,
            SumoLogicSource source,
            ITextFormatter formatter)
        {
            if (connection is null)
            {
                throw new ArgumentNullException(nameof(connection));
            }

            _source    = source ?? throw new ArgumentNullException(nameof(source));
            _formatter = formatter ?? throw new ArgumentNullException(nameof(formatter));

            _log           = log ?? new DummyLog();
            _messageSender = MessageSenderFactory.CreateMessageSender(_log, httpMessageHandler, connection);
        }