Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MetricReaderType to OtlpExporterOptions #2674

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not required, right? its the default already...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay to leave it to make it obvious in the examples.

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
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