/// <summary>
        /// Registers a ConsoleActivity exporter.
        /// </summary>
        /// <param name="builder">Open Telemetry builder to use.</param>
        /// <param name="configure">Exporter configuration options.</param>
        /// <returns>The instance of <see cref="OpenTelemetryBuilder"/> to chain the calls.</returns>
        public static OpenTelemetryBuilder UseConsoleActivityExporter(this OpenTelemetryBuilder builder, Action <ConsoleActivityExporterOptions> configure)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            var exporterOptions = new ConsoleActivityExporterOptions();

            configure(exporterOptions);
            var consoleExporter = new ConsoleActivityExporter(exporterOptions);

            return(builder.SetProcessorPipeline(pipeline => pipeline.SetExporter(consoleExporter)));
        }
Example #2
0
        /// <summary>
        /// Enables the OpenTelemetry Protocol (OTLP) exporter.
        /// </summary>
        /// <param name="builder">Open Telemetry builder to use.</param>
        /// <param name="configure">Exporter configuration options.</param>
        /// <returns>The instance of <see cref="OpenTelemetryBuilder"/> to chain the calls.</returns>
        public static OpenTelemetryBuilder UseOpenTelemetryProtocolActivityExporter(this OpenTelemetryBuilder builder, Action <ExporterOptions> configure)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            return(builder.SetProcessorPipeline(pipeline =>
            {
                var exporterOptions = new ExporterOptions();
                configure(exporterOptions);

                var activityExporter = new OtlpActivityExporter(exporterOptions);
                pipeline.SetExporter(activityExporter);
            }));
        }