Skip to content

Commit

Permalink
Report error on run start (#135)
Browse files Browse the repository at this point in the history
* Catch and report errors when starting extraction run.

* Add better logging on startup
  • Loading branch information
einarmo authored Oct 26, 2021
1 parent 25510de commit 0eeb6e9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ExtractorUtils/ExtractionRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -69,15 +70,27 @@ public void Start()

private async Task Run()
{
var pipe = await _destination.CogniteClient.ExtPipes.RetrieveAsync(
new[] { Identity.Create(_config.PipelineId) }, true, _source.Token).ConfigureAwait(false);
IEnumerable<ExtPipe> pipe;
try
{
pipe = await _destination.CogniteClient.ExtPipes.RetrieveAsync(
new[] { Identity.Create(_config.PipelineId) }, true, _source.Token).ConfigureAwait(false);
}
catch (Exception ex)
{
_log.LogError("Failed to fetch extraction pipeline with ExternalId: {id}, this extractor will not report status: {msg}",
_config.PipelineId, ex.Message);
return;
}

if (!pipe.Any())
{
_log.LogError("Did not find extraction pipeline with ExternalId: {id}, this extractor will not report status",
_config.PipelineId);
return;
}

_log.LogInformation("Begin reporting extraction runs to pipeline with id {id}. Continuous: {cont}", _config.PipelineId, Continuous);
if (Continuous)
{
try
Expand Down

0 comments on commit 0eeb6e9

Please sign in to comment.