From 0eeb6e9515623d0f303947880a357932e6efac84 Mon Sep 17 00:00:00 2001 From: Einar Date: Tue, 26 Oct 2021 13:13:55 +0200 Subject: [PATCH] Report error on run start (#135) * Catch and report errors when starting extraction run. * Add better logging on startup --- ExtractorUtils/ExtractionRun.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ExtractorUtils/ExtractionRun.cs b/ExtractorUtils/ExtractionRun.cs index f88be605..bacb29de 100644 --- a/ExtractorUtils/ExtractionRun.cs +++ b/ExtractorUtils/ExtractionRun.cs @@ -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; @@ -69,8 +70,19 @@ 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 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", @@ -78,6 +90,7 @@ private async Task Run() return; } + _log.LogInformation("Begin reporting extraction runs to pipeline with id {id}. Continuous: {cont}", _config.PipelineId, Continuous); if (Continuous) { try