Skip to content

Commit b32fb80

Browse files
improve
1 parent ac0ecab commit b32fb80

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

Extensions/AzureBlob/Cosmos.DataTransfer.AzureBlobStorage/AzureBlobDataSink.cs

+9-10
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public async Task WriteToTargetAsync(Func<Stream, Task> writeToStream, IConfigur
4141

4242
logger.LogInformation("Saving file '{File}' to Azure Blob Container '{ContainerName}'", settings.BlobName, settings.ContainerName);
4343

44-
var lastLogTime = DateTime.MinValue;
44+
var lastLogTime = DateTime.UtcNow;
4545
var logInterval = TimeSpan.FromMinutes(1);
4646
long totalBytes = 0;
4747

@@ -54,32 +54,31 @@ public async Task WriteToTargetAsync(Func<Stream, Task> writeToStream, IConfigur
5454
{
5555
if (DateTime.UtcNow - lastLogTime >= logInterval)
5656
{
57-
logger.LogInformation("Transferred {TotalMiB} bytes to Azure Blob", l/1024/1024);
57+
logger.LogInformation("{BlobName}: transferred {TotalMiB} MiB to Azure Blob", settings.BlobName, l / 1024/1024);
5858
lastLogTime = DateTime.UtcNow;
5959
}
6060

6161
totalBytes = l;
6262
})
6363

6464
}, cancellationToken);
65+
6566
await writeToStream(blobStream);
6667

6768
sw.Stop();
6869

69-
var totalMib = totalBytes / 1024 / 1024;
70-
var rate = totalMib / sw.ElapsedMilliseconds / 1000;
70+
if (totalBytes != 0)
71+
{
72+
var totalMib = totalBytes / 1024 / 1024;
73+
var rate = totalMib / sw.ElapsedMilliseconds / 1000;
7174

72-
logger.LogInformation("Transferred {TotalMiB} Mib to Azure Blob in {TotalTime} minutes ({Rate} MiB/s).", totalMib, sw.ElapsedMilliseconds/1000/60, rate);
75+
logger.LogInformation("{BlobName}: transferred {TotalMiB} Mib to Azure Blob in {TotalTime} minutes ({Rate} MiB/s).", settings.BlobName, totalMib, sw.ElapsedMilliseconds / 1000 / 60, rate);
76+
}
7377
}
7478

7579
public IEnumerable<IDataExtensionSettings> GetSettings()
7680
{
7781
yield return new AzureBlobSinkSettings();
7882
}
79-
80-
private void LogBytes()
81-
{
82-
83-
}
8483
}
8584
}

0 commit comments

Comments
 (0)