Skip to content

Commit

Permalink
Add PeriodicExporterOptions for console exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
reese-lee committed Nov 20, 2021
1 parent 05cdc2c commit 6d4fde9
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public static MeterProviderBuilder AddConsoleExporter(this MeterProviderBuilder

var exporter = new ConsoleMetricExporter(options);

var reader = options.MetricExportIntervalMilliseconds == Timeout.Infinite
var reader = options.MetricReaderExportType == MetricReaderExportType.Simple
? new BaseExportingMetricReader(exporter)
: new PeriodicExportingMetricReader(exporter, options.MetricExportIntervalMilliseconds);
: new PeriodicExportingMetricReader(exporter, options.PeriodicExporterOptions.ExportIntervalMilliseconds);

reader.PreferredAggregationTemporality = options.AggregationTemporality;

Expand Down
8 changes: 3 additions & 5 deletions src/OpenTelemetry.Exporter.Console/ConsoleExporterOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// limitations under the License.
// </copyright>

using System.Threading;
using OpenTelemetry.Metrics;

namespace OpenTelemetry.Exporter
Expand All @@ -26,10 +25,9 @@ public class ConsoleExporterOptions
/// </summary>
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>.
/// </summary>
public int MetricExportIntervalMilliseconds { get; set; } = Timeout.Infinite;
public MetricReaderExportType MetricReaderExportType { get; set; } = MetricReaderExportType.Simple;

public PeriodicExporterOptions PeriodicExporterOptions { get; set; } = new PeriodicExporterOptions();

/// <summary>
/// Gets or sets the AggregationTemporality used for Histogram
Expand Down
24 changes: 24 additions & 0 deletions src/OpenTelemetry/Metrics/MetricReaderExportType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// <copyright file="MetricReaderExportType.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 enum MetricReaderExportType
{
Simple,
Periodic,
}
}
20 changes: 20 additions & 0 deletions src/OpenTelemetry/Metrics/PeriodicExporterOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// <copyright file="PeriodicExporterOptions.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>

public class PeriodicExporterOptions
{
public int ExportIntervalMilliseconds { get; set; } = 60000;
}

0 comments on commit 6d4fde9

Please sign in to comment.