Skip to content

Commit

Permalink
Add MetricReaderType to OtlpExporterOptions (#2674)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanwest authored Nov 24, 2021
1 parent cabb847 commit f4915ea
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 14 deletions.
3 changes: 2 additions & 1 deletion examples/Console/TestMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ internal static object Run(MetricsOptions options)
providerBuilder
.AddOtlpExporter(o =>
{
o.MetricExportIntervalMilliseconds = options.DefaultCollectionPeriodMilliseconds;
o.MetricReaderType = MetricReaderType.Periodic;
o.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = options.DefaultCollectionPeriodMilliseconds;
o.AggregationTemporality = options.IsDelta ? AggregationTemporality.Delta : AggregationTemporality.Cumulative;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ OpenTelemetry.Exporter.OtlpExporterOptions.ExportProcessorType.get -> OpenTeleme
OpenTelemetry.Exporter.OtlpExporterOptions.ExportProcessorType.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.Headers.get -> string
OpenTelemetry.Exporter.OtlpExporterOptions.Headers.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.MetricExportIntervalMilliseconds.get -> int
OpenTelemetry.Exporter.OtlpExporterOptions.MetricExportIntervalMilliseconds.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType
OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions
OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.OtlpExporterOptions() -> void
OpenTelemetry.Exporter.OtlpExporterOptions.Protocol.get -> OpenTelemetry.Exporter.OtlpExportProtocol
OpenTelemetry.Exporter.OtlpExporterOptions.Protocol.set -> void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ OpenTelemetry.Exporter.OtlpTraceExporter.OtlpTraceExporter(OpenTelemetry.Exporte
OpenTelemetry.Trace.OtlpTraceExporterHelperExtensions
override OpenTelemetry.Exporter.OtlpTraceExporter.Export(in OpenTelemetry.Batch<System.Diagnostics.Activity> activityBatch) -> OpenTelemetry.ExportResult
override OpenTelemetry.Exporter.OtlpTraceExporter.OnShutdown(int timeoutMilliseconds) -> bool
static OpenTelemetry.Trace.OtlpTraceExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Exporter.OtlpExporterOptions> configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Trace.OtlpTraceExporterHelperExtensions.AddOtlpExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action<OpenTelemetry.Exporter.OtlpExporterOptions> configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
OpenTelemetry.Exporter.OtlpExporterOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality
OpenTelemetry.Exporter.OtlpExporterOptions.AggregationTemporality.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.MetricExportIntervalMilliseconds.get -> int
OpenTelemetry.Exporter.OtlpExporterOptions.MetricExportIntervalMilliseconds.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType
OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions
OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.Protocol.get -> OpenTelemetry.Exporter.OtlpExportProtocol
OpenTelemetry.Exporter.OtlpExporterOptions.Protocol.set -> void
OpenTelemetry.Exporter.OtlpExportProtocol
Expand All @@ -12,4 +14,4 @@ OpenTelemetry.Exporter.OtlpMetricExporter.OtlpMetricExporter(OpenTelemetry.Expor
OpenTelemetry.Metrics.OtlpMetricExporterExtensions
override OpenTelemetry.Exporter.OtlpMetricExporter.Export(in OpenTelemetry.Batch<OpenTelemetry.Metrics.Metric> metrics) -> OpenTelemetry.ExportResult
override OpenTelemetry.Exporter.OtlpMetricExporter.OnShutdown(int timeoutMilliseconds) -> bool
static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action<OpenTelemetry.Exporter.OtlpExporterOptions> configure = null) -> OpenTelemetry.Metrics.MeterProviderBuilder
static OpenTelemetry.Metrics.OtlpMetricExporterExtensions.AddOtlpExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action<OpenTelemetry.Exporter.OtlpExporterOptions> configure = null) -> OpenTelemetry.Metrics.MeterProviderBuilder
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
OpenTelemetry.Exporter.OtlpExporterOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality
OpenTelemetry.Exporter.OtlpExporterOptions.AggregationTemporality.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.MetricExportIntervalMilliseconds.get -> int
OpenTelemetry.Exporter.OtlpExporterOptions.MetricExportIntervalMilliseconds.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType
OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions
OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.Protocol.get -> OpenTelemetry.Exporter.OtlpExportProtocol
OpenTelemetry.Exporter.OtlpExporterOptions.Protocol.set -> void
OpenTelemetry.Exporter.OtlpExportProtocol
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
OpenTelemetry.Exporter.OtlpExporterOptions.AggregationTemporality.get -> OpenTelemetry.Metrics.AggregationTemporality
OpenTelemetry.Exporter.OtlpExporterOptions.AggregationTemporality.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.MetricExportIntervalMilliseconds.get -> int
OpenTelemetry.Exporter.OtlpExporterOptions.MetricExportIntervalMilliseconds.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.get -> OpenTelemetry.Metrics.MetricReaderType
OpenTelemetry.Exporter.OtlpExporterOptions.MetricReaderType.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.get -> OpenTelemetry.Metrics.PeriodicExportingMetricReaderOptions
OpenTelemetry.Exporter.OtlpExporterOptions.PeriodicExportingMetricReaderOptions.set -> void
OpenTelemetry.Exporter.OtlpExporterOptions.Protocol.get -> OpenTelemetry.Exporter.OtlpExportProtocol
OpenTelemetry.Exporter.OtlpExporterOptions.Protocol.set -> void
OpenTelemetry.Exporter.OtlpExportProtocol
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* Added configuration options for `MetricReaderType` to allow for configuring
the `OtlpMetricExporter` to export either manually or periodically.
([#2674](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2674))

## 1.2.0-beta2

Released 2021-Nov-19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,14 @@ public OtlpExporterOptions()
public BatchExportProcessorOptions<Activity> BatchExportProcessorOptions { get; set; } = new BatchExportActivityProcessorOptions();

/// <summary>
/// Gets or sets the metric export interval in milliseconds. The default value is 60000.
/// Gets or sets the <see cref="MetricReaderType" /> to use. Defaults to <c>MetricReaderType.Periodic</c>.
/// </summary>
public int MetricExportIntervalMilliseconds { get; set; } = 60000;
public MetricReaderType MetricReaderType { get; set; } = MetricReaderType.Periodic;

/// <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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ private static MeterProviderBuilder AddOtlpExporter(MeterProviderBuilder builder
options.AppendExportPath(initialEndpoint, OtlpExporterOptions.MetricsExportPath);

var metricExporter = new OtlpMetricExporter(options);
var metricReader = new PeriodicExportingMetricReader(metricExporter, options.MetricExportIntervalMilliseconds);

var metricReader = options.MetricReaderType == MetricReaderType.Manual
? new BaseExportingMetricReader(metricExporter)
: new PeriodicExportingMetricReader(metricExporter, options.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds);

metricReader.Temporality = options.AggregationTemporality;
return builder.AddReader(metricReader);
}
Expand Down

0 comments on commit f4915ea

Please sign in to comment.