public Task OpenAsync(string correlationId) { _timer.Start(); _logger.Trace(correlationId, "Dummy controller opened"); return(Task.Delay(0)); }
public async Task OpenAsync(string correlationId) { if (_opened == true) { return; } // Create filter if it doesn't exist if (!Directory.Exists(_path)) { Directory.CreateDirectory(_path); } // Restart cleanup process if (_cleanupInterval != null) { _cleanupInterval.Stop(); } _cleanupInterval = new FixedRateTimer( () => { Cleanup(null); }, (int)_cleanupTimeout, (int)_cleanupTimeout ); _cleanupInterval.Start(); _opened = true; await Task.Delay(0); }
public async Task OpenAsync(string correlationId) { if (IsOpened()) { return; } var connection = await _connectionResolver.ResolveAsync(correlationId); var uri = new Uri(connection.Uri); try { // Create client var settings = new ConnectionConfiguration(uri) .RequestTimeout(TimeSpan.FromMinutes(2)) .ThrowExceptions(true); _client = new ElasticLowLevelClient(settings); // Create index if it doesn't exist await CreateIndex(correlationId, true); if (_timer == null) { _timer = new FixedRateTimer(OnTimer, _interval, _interval); _timer.Start(); } } catch { // Do nothing if elastic search client was not initialized _errorConsoleLogger.Error(correlationId, $"Failed to initialize Elastic Search Logger with uri='{uri}'"); } }
public Task OpenAsync(string correlationId) { if (Enabled) { _timer?.Start(); _logger.Info(correlationId, $"OpenAsync: ThroughputMonitor is started for '{InternalCollectionNames}' collection(s)."); } else { _logger.Info(correlationId, $"OpenAsync: ThroughputMonitor is disabled for '{InternalCollectionNames}' collection(s)."); } return(Task.Delay(0)); }
/// <summary> /// Opens the component. /// </summary> /// <param name="correlationId">(optional) transaction id to trace execution through call chain.</param> public async Task OpenAsync(string correlationId) { if (IsOpen()) { return; } var awsConnection = await _connectionResolver.ResolveAsync(correlationId); // Assign service name awsConnection.Service = "logs"; awsConnection.ResourceType = "log-group"; if (!string.IsNullOrEmpty(awsConnection.Resource)) { _group = awsConnection.Resource; } // Undefined stream creates a random stream on every connect if (string.IsNullOrEmpty(_stream)) { _stream = IdGenerator.NextLong(); } // Validate connection params var err = awsConnection.Validate(correlationId); if (err != null) { throw err; } // Create client var region = RegionEndpoint.GetBySystemName(awsConnection.Region); var config = new AmazonCloudWatchLogsConfig() { RegionEndpoint = region }; _client = new AmazonCloudWatchLogsClient(awsConnection.AccessId, awsConnection.AccessKey, config); // Create a log group if needed try { await _client.CreateLogGroupAsync( new CreateLogGroupRequest { LogGroupName = _group } ); } catch (ResourceAlreadyExistsException) { // Ignore. Everything is ok } // Create or read log stream try { await _client.CreateLogStreamAsync( new CreateLogStreamRequest { LogGroupName = _group, LogStreamName = _stream } ); _lastToken = null; } catch (ResourceAlreadyExistsException) { var response = await _client.DescribeLogStreamsAsync( new DescribeLogStreamsRequest { LogGroupName = _group, LogStreamNamePrefix = _stream } ); if (response.LogStreams.Count > 0) { _lastToken = response.LogStreams[0].UploadSequenceToken; } } if (_timer == null) { _timer = new FixedRateTimer(OnTimer, _interval, _interval); _timer.Start(); } }