OpenTelemetry.Exporter.Console 1.16.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package OpenTelemetry.Exporter.Console --version 1.16.0
                    
NuGet\Install-Package OpenTelemetry.Exporter.Console -Version 1.16.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.16.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.16.0" />
                    
Directory.Packages.props
<PackageReference Include="OpenTelemetry.Exporter.Console" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OpenTelemetry.Exporter.Console --version 1.16.0
                    
#r "nuget: OpenTelemetry.Exporter.Console, 1.16.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OpenTelemetry.Exporter.Console@1.16.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OpenTelemetry.Exporter.Console&version=1.16.0
                    
Install as a Cake Addin
#tool nuget:?package=OpenTelemetry.Exporter.Console&version=1.16.0
                    
Install as a Cake Tool

Console Exporter for OpenTelemetry .NET

NuGet NuGet

The console exporter prints data to the Console window. ConsoleExporter supports exporting logs, metrics and traces.

This exporter is intended for debugging and learning purposes. It is not recommended for production use. The output format is not standardized and can change at any time. If a standardized format for exporting telemetry to stdout is desired, upvote on this feature request.

Installation

dotnet add package OpenTelemetry.Exporter.Console

See the individual "getting started" examples depending on the signal being used:

Configuration

See the TestConsoleExporter.cs for an example of how to use the exporter for exporting traces to a collection.

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:

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

Environment variable PeriodicExportingMetricReaderOptions property
OTEL_METRIC_EXPORT_INTERVAL ExportIntervalMilliseconds
OTEL_METRIC_EXPORT_TIMEOUT ExportTimeoutMilliseconds

References

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.