/// <summary> /// Emit the provided log event to the sink. /// </summary> /// <param name="logEvent">The log event to write.</param> public void Emit(LogEvent logEvent) { var table = _cloudTableProvider.GetCloudTable(_storageAccount, _storageTableName, _bypassTableCreationValidation); var op = TableOperation.Insert(AzureTableStorageEntityFactory.CreateEntityWithProperties(logEvent, _formatProvider, _additionalRowKeyPostfix, _keyGenerator, _propertyColumns)); table.ExecuteAsync(op).SyncContextSafeWait(_waitTimeoutMilliseconds); }
/// <summary> /// Emit the provided log event to the sink. /// </summary> /// <param name="logEvent">The log event to write.</param> public void Emit(LogEvent logEvent) { var op = TableOperation.Insert( AzureTableStorageEntityFactory.CreateEntityWithProperties(logEvent, _formatProvider, _additionalRowKeyPostfix)); _table.ExecuteAsync(op).SyncContextSafeWait(_waitTimeoutMilliseconds); }
protected override async Task EmitBatchAsync(IEnumerable <LogEvent> events) { var table = _cloudTableProvider.GetCloudTable(_storageAccount, _storageTableName, _bypassTableCreationValidation); string lastPartitionKey = null; TableBatchOperation operation = null; var insertsPerOperation = 0; foreach (var logEvent in events) { var tableEntity = AzureTableStorageEntityFactory.CreateEntityWithProperties(logEvent, _formatProvider, _additionalRowKeyPostfix, _keyGenerator, _propertyColumns); // If partition changed, store the new and force an execution if (lastPartitionKey != tableEntity.PartitionKey) { lastPartitionKey = tableEntity.PartitionKey; // Force a new execution insertsPerOperation = _maxAzureOperationsPerBatch; } // If reached max operations per batch, we need a new batch operation if (insertsPerOperation == _maxAzureOperationsPerBatch) { // If there is an operation currently in use, execute it if (operation != null) { await table.ExecuteBatchAsync(operation).ConfigureAwait(false); } // Create a new batch operation and zero count operation = new TableBatchOperation(); insertsPerOperation = 0; } // Add current entry to the batch operation.Add(TableOperation.InsertOrMerge(tableEntity)); insertsPerOperation++; } // Execute last batch await table.ExecuteBatchAsync(operation).ConfigureAwait(false); }
protected override async Task EmitBatchAsync(IEnumerable <LogEvent> events) { string lastPartitionKey = null; TableBatchOperation operation = null; int insertsPerOperation = 0; foreach (var logEvent in events) { var tableEntity = AzureTableStorageEntityFactory.CreateEntityWithProperties(logEvent, _formatProvider, _additionalRowKeyPostfix); // If partition changed, store the new and force an execution if (lastPartitionKey != tableEntity.PartitionKey) { lastPartitionKey = tableEntity.PartitionKey; // Force a new execution insertsPerOperation = _maxAzureOperationsPerBatch; } // If reached max operations per batch, we need a new batch operation if (insertsPerOperation == _maxAzureOperationsPerBatch) { // If there is an operation currently in use, execute it if (operation != null) { await _table.ExecuteBatchAsync(operation); } // Create a new batch operation and zero count operation = new TableBatchOperation(); insertsPerOperation = 0; } // Add current entry to the batch operation.Add(TableOperation.Insert(tableEntity)); insertsPerOperation++; } // Execute last batch await _table.ExecuteBatchAsync(operation); }
/// <summary> /// Emit the provided log event to the sink. /// </summary> /// <param name="logEvent">The log event to write.</param> public void Emit(LogEvent logEvent) { _table.Execute(TableOperation.Insert(AzureTableStorageEntityFactory.CreateEntityWithProperties(logEvent, _formatProvider, _additionalRowKeyPostfix))); }