Catch exception from Metric collect, stop daily publish from metrics branch (#2180)

* Remove daily nuget publish from metrics

* catch exception from collect
This commit is contained in:
Cijo Thomas 2021-07-23 09:15:44 -07:00 committed by GitHub
parent 9bd4fccfa4
commit 6a31c669be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 15 deletions

View File

@ -2,7 +2,7 @@
################### IMPORTANT ###################
# DON'T RENAME THIS FILE UNLESS WE START
# RELEASING THE VERSION 2.*
################### IMPORTANT ###################
################### IMPORTANT ###################
#################################################
name: Pack and publish to Myget
@ -24,7 +24,7 @@ jobs:
strategy:
matrix:
os: [windows-latest]
branches: [main,metrics]
branches: [main]
steps:
- uses: actions/checkout@v2

View File

@ -19,8 +19,6 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.Metrics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using OpenTelemetry.Resources;
namespace OpenTelemetry.Metrics
@ -140,14 +138,22 @@ namespace OpenTelemetry.Metrics
{
lock (this.collectLock)
{
// Record all observable instruments
this.listener.RecordObservableInstruments();
var metricItem = new MetricItem();
foreach (var kv in this.AggregatorStores)
MetricItem metricItem = null;
try
{
var metrics = kv.Key.Collect(isDelta);
metricItem.Metrics.AddRange(metrics);
// Record all observable instruments
this.listener.RecordObservableInstruments();
metricItem = new MetricItem();
foreach (var kv in this.AggregatorStores)
{
var metrics = kv.Key.Collect(isDelta);
metricItem.Metrics.AddRange(metrics);
}
}
catch (Exception)
{
// TODO: Log
}
return metricItem;

View File

@ -42,8 +42,11 @@ namespace OpenTelemetry.Metrics
if (this.getMetrics != null)
{
var metricsToExport = this.getMetrics(this.isDelta);
Batch<MetricItem> batch = new Batch<MetricItem>(metricsToExport);
this.exporter.Export(batch);
if (metricsToExport != null)
{
Batch<MetricItem> batch = new Batch<MetricItem>(metricsToExport);
this.exporter.Export(batch);
}
}
}

View File

@ -77,8 +77,11 @@ namespace OpenTelemetry.Metrics
if (this.getMetrics != null)
{
var metricsToExport = this.getMetrics(isDelta);
Batch<MetricItem> batch = new Batch<MetricItem>(metricsToExport);
this.exporter.Export(batch);
if (metricsToExport != null)
{
Batch<MetricItem> batch = new Batch<MetricItem>(metricsToExport);
this.exporter.Export(batch);
}
}
}
}