Add PeriodicExporterOptions for console exporter (#2648)
This commit is contained in:
parent
bc0e8afd96
commit
cb4bedaf33
|
|
@ -134,7 +134,13 @@ namespace Examples.AspNetCore
|
|||
builder.AddOtlpExporter();
|
||||
break;
|
||||
default:
|
||||
builder.AddConsoleExporter();
|
||||
builder.AddConsoleExporter(options =>
|
||||
{
|
||||
// The ConsoleMetricExporter defaults to a manual collect cycle.
|
||||
// This configuration causes metrics to be exported to stdout on a 10s interval.
|
||||
options.MetricReaderType = MetricReaderType.Periodic;
|
||||
options.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 10000;
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -77,7 +77,8 @@ namespace Examples.Console
|
|||
providerBuilder
|
||||
.AddConsoleExporter(o =>
|
||||
{
|
||||
o.MetricExportIntervalMilliseconds = options.DefaultCollectionPeriodMilliseconds;
|
||||
o.MetricReaderType = MetricReaderType.Periodic;
|
||||
o.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = options.DefaultCollectionPeriodMilliseconds;
|
||||
o.AggregationTemporality = options.IsDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
OpenTelemetry.Exporter.ConsoleExporterOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality
|
||||
OpenTelemetry.Exporter.ConsoleExporterOptions.AggregationTemporality.set -> void
|
||||
OpenTelemetry.Exporter.ConsoleExporterOptions.MetricExportIntervalMilliseconds.get -> int
|
||||
OpenTelemetry.Exporter.ConsoleExporterOptions.MetricExportIntervalMilliseconds.set -> void
|
||||
OpenTelemetry.Exporter.ConsoleExporterOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType
|
||||
OpenTelemetry.Exporter.ConsoleExporterOptions.MetricReaderType.set -> void
|
||||
OpenTelemetry.Exporter.ConsoleExporterOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions
|
||||
OpenTelemetry.Exporter.ConsoleExporterOptions.PeriodicExportingMetricReaderOptions.set -> void
|
||||
OpenTelemetry.Exporter.ConsoleMetricExporter
|
||||
OpenTelemetry.Exporter.ConsoleMetricExporter.ConsoleMetricExporter(OpenTelemetry.Exporter.ConsoleExporterOptions options) -> void
|
||||
OpenTelemetry.Metrics.ConsoleExporterMetricsExtensions
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
OpenTelemetry.Exporter.ConsoleExporterOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality
|
||||
OpenTelemetry.Exporter.ConsoleExporterOptions.AggregationTemporality.set -> void
|
||||
OpenTelemetry.Exporter.ConsoleExporterOptions.MetricExportIntervalMilliseconds.get -> int
|
||||
OpenTelemetry.Exporter.ConsoleExporterOptions.MetricExportIntervalMilliseconds.set -> void
|
||||
OpenTelemetry.Exporter.ConsoleExporterOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType
|
||||
OpenTelemetry.Exporter.ConsoleExporterOptions.MetricReaderType.set -> void
|
||||
OpenTelemetry.Exporter.ConsoleExporterOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions
|
||||
OpenTelemetry.Exporter.ConsoleExporterOptions.PeriodicExportingMetricReaderOptions.set -> void
|
||||
OpenTelemetry.Exporter.ConsoleMetricExporter
|
||||
OpenTelemetry.Exporter.ConsoleMetricExporter.ConsoleMetricExporter(OpenTelemetry.Exporter.ConsoleExporterOptions options) -> void
|
||||
OpenTelemetry.Metrics.ConsoleExporterMetricsExtensions
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
* Added configuration options for `MetricReaderType` to allow for configuring
|
||||
the `ConsoleMetricExporter` to export either manually or periodically.
|
||||
([#2648](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2648))
|
||||
|
||||
## 1.2.0-beta2
|
||||
|
||||
Released 2021-Nov-19
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
// </copyright>
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using OpenTelemetry.Exporter;
|
||||
using OpenTelemetry.Internal;
|
||||
|
||||
|
|
@ -39,9 +38,9 @@ namespace OpenTelemetry.Metrics
|
|||
|
||||
var exporter = new ConsoleMetricExporter(options);
|
||||
|
||||
var reader = options.MetricExportIntervalMilliseconds == Timeout.Infinite
|
||||
var reader = options.MetricReaderType == MetricReaderType.Manual
|
||||
? new BaseExportingMetricReader(exporter)
|
||||
: new PeriodicExportingMetricReader(exporter, options.MetricExportIntervalMilliseconds);
|
||||
: new PeriodicExportingMetricReader(exporter, options.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds);
|
||||
|
||||
reader.PreferredAggregationTemporality = options.AggregationTemporality;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System.Threading;
|
||||
using OpenTelemetry.Metrics;
|
||||
|
||||
namespace OpenTelemetry.Exporter
|
||||
|
|
@ -27,9 +26,14 @@ namespace OpenTelemetry.Exporter
|
|||
public ConsoleExporterOutputTargets Targets { get; set; } = ConsoleExporterOutputTargets.Console;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the metric export interval in milliseconds. The default value is <c>Timeout.Infinite</c>.
|
||||
/// Gets or sets the <see cref="MetricReaderType" /> to use. Defaults to <c>MetricReaderType.Manual</c>.
|
||||
/// </summary>
|
||||
public int MetricExportIntervalMilliseconds { get; set; } = Timeout.Infinite;
|
||||
public MetricReaderType MetricReaderType { get; set; } = MetricReaderType.Manual;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="PeriodicExportingMetricReaderOptions" /> options. Ignored unless <c>MetricReaderType</c> is <c>Periodic</c>.
|
||||
/// </summary>
|
||||
public PeriodicExportingMetricReaderOptions PeriodicExportingMetricReaderOptions { get; set; } = new PeriodicExportingMetricReaderOptions();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the AggregationTemporality used for Histogram
|
||||
|
|
|
|||
|
|
@ -70,6 +70,9 @@ OpenTelemetry.Metrics.MetricReader.PreferredAggregationTemporality.set -> void
|
|||
OpenTelemetry.Metrics.MetricReader.Shutdown(int timeoutMilliseconds = -1) -> bool
|
||||
OpenTelemetry.Metrics.MetricReader.SupportedAggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality
|
||||
OpenTelemetry.Metrics.MetricReader.SupportedAggregationTemporality.set -> void
|
||||
OpenTelemetry.Metrics.MetricReaderType
|
||||
OpenTelemetry.Metrics.MetricReaderType.Manual = 0 -> OpenTelemetry.Metrics.MetricReaderType
|
||||
OpenTelemetry.Metrics.MetricReaderType.Periodic = 1 -> OpenTelemetry.Metrics.MetricReaderType
|
||||
OpenTelemetry.Metrics.MetricStreamConfiguration
|
||||
OpenTelemetry.Metrics.MetricStreamConfiguration.Description.get -> string
|
||||
OpenTelemetry.Metrics.MetricStreamConfiguration.Description.set -> void
|
||||
|
|
@ -87,6 +90,10 @@ OpenTelemetry.Metrics.MetricType.LongSum = 26 -> OpenTelemetry.Metrics.MetricTyp
|
|||
OpenTelemetry.Metrics.MetricTypeExtensions
|
||||
OpenTelemetry.Metrics.PeriodicExportingMetricReader
|
||||
OpenTelemetry.Metrics.PeriodicExportingMetricReader.PeriodicExportingMetricReader(OpenTelemetry.BaseExporter<OpenTelemetry.Metrics.Metric> exporter, int exportIntervalMilliseconds = 60000, int exportTimeoutMilliseconds = 30000) -> void
|
||||
OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions
|
||||
OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions.PeriodicExportingMetricReaderOptions() -> void
|
||||
OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds.get -> int
|
||||
OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds.set -> void
|
||||
OpenTelemetry.ReadOnlyTagCollection
|
||||
OpenTelemetry.ReadOnlyTagCollection.Count.get -> int
|
||||
OpenTelemetry.ReadOnlyTagCollection.Enumerator
|
||||
|
|
|
|||
|
|
@ -70,6 +70,9 @@ OpenTelemetry.Metrics.MetricReader.PreferredAggregationTemporality.set -> void
|
|||
OpenTelemetry.Metrics.MetricReader.Shutdown(int timeoutMilliseconds = -1) -> bool
|
||||
OpenTelemetry.Metrics.MetricReader.SupportedAggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality
|
||||
OpenTelemetry.Metrics.MetricReader.SupportedAggregationTemporality.set -> void
|
||||
OpenTelemetry.Metrics.MetricReaderType
|
||||
OpenTelemetry.Metrics.MetricReaderType.Manual = 0 -> OpenTelemetry.Metrics.MetricReaderType
|
||||
OpenTelemetry.Metrics.MetricReaderType.Periodic = 1 -> OpenTelemetry.Metrics.MetricReaderType
|
||||
OpenTelemetry.Metrics.MetricStreamConfiguration
|
||||
OpenTelemetry.Metrics.MetricStreamConfiguration.Description.get -> string
|
||||
OpenTelemetry.Metrics.MetricStreamConfiguration.Description.set -> void
|
||||
|
|
@ -87,6 +90,10 @@ OpenTelemetry.Metrics.MetricType.LongSum = 26 -> OpenTelemetry.Metrics.MetricTyp
|
|||
OpenTelemetry.Metrics.MetricTypeExtensions
|
||||
OpenTelemetry.Metrics.PeriodicExportingMetricReader
|
||||
OpenTelemetry.Metrics.PeriodicExportingMetricReader.PeriodicExportingMetricReader(OpenTelemetry.BaseExporter<OpenTelemetry.Metrics.Metric> exporter, int exportIntervalMilliseconds = 60000, int exportTimeoutMilliseconds = 30000) -> void
|
||||
OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions
|
||||
OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions.PeriodicExportingMetricReaderOptions() -> void
|
||||
OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds.get -> int
|
||||
OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds.set -> void
|
||||
OpenTelemetry.ReadOnlyTagCollection
|
||||
OpenTelemetry.ReadOnlyTagCollection.Count.get -> int
|
||||
OpenTelemetry.ReadOnlyTagCollection.Enumerator
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
// <copyright file="MetricReaderType.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Type of <see cref="MetricReader" /> to be used.
|
||||
/// </summary>
|
||||
public enum MetricReaderType
|
||||
{
|
||||
/// <summary>
|
||||
/// Use the <see cref="BaseExportingMetricReader" />.
|
||||
/// This requires manually invoking <c>MetricReader.Collect()</c> to export metrics.
|
||||
/// </summary>
|
||||
Manual,
|
||||
|
||||
/// <summary>
|
||||
/// Use the <see cref="PeriodicExportingMetricReader" />.
|
||||
/// <c>MetricReader.Collect()</c> will be invoked on a defined interval.
|
||||
/// </summary>
|
||||
Periodic,
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// <copyright file="PeriodicExportingMetricReaderOptions.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
public class PeriodicExportingMetricReaderOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the metric export interval in milliseconds. The default value is <c>60000</c>.
|
||||
/// </summary>
|
||||
public int ExportIntervalMilliseconds { get; set; } = 60000;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue