Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 23 additions & 1 deletion src/OpenTelemetry.Exporter.Console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,33 @@ You can configure the `ConsoleExporter` through `Options` types properties
and environment variables.
The `Options` type setters take precedence over the environment variables.

### MetricReaderOptions (metrics)

For metrics, `AddConsoleExporter()` pairs the exporter with a
`PeriodicExportingMetricReader`. Use `MetricReaderOptions` to configure
temporality and export interval/timeout:

```csharp
var meterProvider = Sdk.CreateMeterProviderBuilder()
// rest of config not shown here.
.AddConsoleExporter((_, metricReaderOptions) =>
{
metricReaderOptions.TemporalityPreference = MetricReaderTemporalityPreference.Delta;

metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 10_000;
metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportTimeoutMilliseconds = 5_000;
})
.Build();
```

See [`TestMetrics.cs`](../../examples/Console/TestMetrics.cs) for a runnable
example.

## Environment Variables

The following environment variables can be used to override the default
values of the `PeriodicExportingMetricReaderOptions`
(following the [OpenTelemetry specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.12.0/specification/sdk-environment-variables.md#periodic-exporting-metricreader).
(following the [OpenTelemetry specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#periodic-exporting-metricreader)).

| Environment variable | `PeriodicExportingMetricReaderOptions` property |
| ------------------------------| ------------------------------------------------|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,20 +394,24 @@ appBuilder.Services.Configure<LogRecordExportProcessorOptions>(
### MetricReaderOptions

The `MetricReaderOptions` class may be used to configure reader settings for
metrics:
metrics (e.g. `TemporalityPreference` and `PeriodicExportingMetricReaderOptions`):

```csharp
// Set via delegate using code:
appBuilder.Services.AddOpenTelemetry()
.WithMetrics(builder => builder.AddOtlpExporter((exporterOptions, readerOptions) =>
{
readerOptions.TemporalityPreference = MetricReaderTemporalityPreference.Delta;
readerOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 10_000;
readerOptions.PeriodicExportingMetricReaderOptions.ExportTimeoutMilliseconds = 5_000;
}));

// Set via Options API using code:
appBuilder.Services.Configure<MetricReaderOptions>(o =>
{
o.TemporalityPreference = MetricReaderTemporalityPreference.Delta;
o.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 10_000;
o.PeriodicExportingMetricReaderOptions.ExportTimeoutMilliseconds = 5_000;
});

// Set via Options API using configuration:
Expand Down