private static MeterProviderBuilder AddConsoleExporter(
            MeterProviderBuilder builder,
            ConsoleExporterOptions exporterOptions,
            MetricReaderOptions metricReaderOptions,
            Action <ConsoleExporterOptions> configureExporter,
            Action <ConsoleExporterOptions, MetricReaderOptions> configureExporterAndMetricReader)
        {
            if (configureExporterAndMetricReader != null)
            {
                configureExporterAndMetricReader.Invoke(exporterOptions, metricReaderOptions);
            }
            else
            {
                configureExporter?.Invoke(exporterOptions);
            }

            var metricExporter = new ConsoleMetricExporter(exporterOptions);

            var metricReader = PeriodicExportingMetricReaderHelper.CreatePeriodicExportingMetricReader(
                metricExporter,
                metricReaderOptions,
                DefaultExportIntervalMilliseconds,
                DefaultExportTimeoutMilliseconds);

            return(builder.AddReader(metricReader));
        }
Exemplo n.º 2
0
        internal static object Run(ConsoleOptions options)
        {
            // map test project settings to ConsoleExporterSetting
            var exporterOptions = new ConsoleExporterOptions
            {
                Pretty = options.Pretty
            };

            // create exporter
            var exporter = new ConsoleExporter(exporterOptions);

            // Create tracer
            using var tracerFactory = TracerFactory.Create(builder => {
                builder.AddProcessorPipeline(p => p.SetExporter(exporter));
            });
            var tracer = tracerFactory.GetTracer("console-test");

            using (tracer.StartActiveSpan("parent", out var parent))
            {
                tracer.CurrentSpan.SetAttribute("key", 123);
                tracer.CurrentSpan.AddEvent("test-event");

                using (tracer.StartActiveSpan("child", out var child))
                {
                    child.SetAttribute("key", "value");
                }
            }

            return(null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds Console Exporter as a configuration to the OpenTelemetry ILoggingBuilder.
        /// </summary>
        /// <param name="loggerOptions"><see cref="OpenTelemetryLoggerOptions"/> options to use.</param>
        /// <param name="configure">Exporter configuration options.</param>
        /// <returns>The instance of <see cref="OpenTelemetryLoggerOptions"/> to chain the calls.</returns>
        public static OpenTelemetryLoggerOptions AddConsoleExporter(this OpenTelemetryLoggerOptions loggerOptions, Action <ConsoleExporterOptions> configure = null)
        {
            Guard.Null(loggerOptions, nameof(loggerOptions));

            var options = new ConsoleExporterOptions();

            configure?.Invoke(options);
            return(loggerOptions.AddProcessor(new SimpleLogRecordExportProcessor(new ConsoleLogRecordExporter(options))));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds Console Exporter as a configuration to the OpenTelemetry ILoggingBuilder.
        /// </summary>
        /// <param name="loggerOptions"><see cref="OpenTelemetryLoggerOptions"/> options to use.</param>
        /// <param name="configure">Exporter configuration options.</param>
        /// <returns>The instance of <see cref="OpenTelemetryLoggerOptions"/> to chain the calls.</returns>
        public static OpenTelemetryLoggerOptions AddConsoleExporter(this OpenTelemetryLoggerOptions loggerOptions, Action <ConsoleExporterOptions> configure = null)
        {
            if (loggerOptions == null)
            {
                throw new ArgumentNullException(nameof(loggerOptions));
            }

            var options = new ConsoleExporterOptions();

            configure?.Invoke(options);
            return(loggerOptions.AddProcessor(new SimpleExportProcessor <LogRecord>(new ConsoleExporter <LogRecord>(options))));
        }
Exemplo n.º 5
0
        public static TracerProviderBuilder AddConsoleExporter(this TracerProviderBuilder builder, Action <ConsoleExporterOptions> configure = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var options = new ConsoleExporterOptions();

            configure?.Invoke(options);
            return(builder.AddProcessor(new SimpleExportActivityProcessor(new ConsoleExporter(options))));
        }
Exemplo n.º 6
0
        public static MeterProviderBuilder AddConsoleExporter(this MeterProviderBuilder builder, Action <ConsoleExporterOptions> configure = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var options = new ConsoleExporterOptions();

            configure?.Invoke(options);
            return(builder.AddMetricProcessor(new PushMetricProcessor(new ConsoleMetricExporter(options), options.MetricExportIntervalMilliseconds, options.IsDelta)));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Registers a ConsoleActivity exporter to a processing pipeline.
        /// </summary>
        /// <param name="builder"><see cref="OpenTelemetryBuilder"/> builder to use.</param>
        /// <param name="configure">Exporter configuration options.</param>
        /// <param name="processorConfigure">Activity processor configuration.</param>
        /// <returns>The instance of <see cref="OpenTelemetryBuilder"/> to chain the calls.</returns>
        public static OpenTelemetryBuilder UseConsoleExporter(this OpenTelemetryBuilder builder, Action <ConsoleExporterOptions> configure = null, Action <ActivityProcessorPipelineBuilder> processorConfigure = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            return(builder.AddProcessorPipeline(pipeline =>
            {
                var exporterOptions = new ConsoleExporterOptions();
                configure?.Invoke(exporterOptions);

                var consoleExporter = new ConsoleExporter(exporterOptions);
                processorConfigure?.Invoke(pipeline);
                pipeline.SetExporter(consoleExporter);
            }));
        }
        public static MeterProviderBuilder AddConsoleExporter(this MeterProviderBuilder builder, Action <ConsoleExporterOptions> configure = null)
        {
            Guard.Null(builder, nameof(builder));

            var options = new ConsoleExporterOptions();

            configure?.Invoke(options);

            var exporter = new ConsoleMetricExporter(options);

            var reader = options.MetricExportIntervalMilliseconds == Timeout.Infinite
                ? new BaseExportingMetricReader(exporter)
                : new PeriodicExportingMetricReader(exporter, options.MetricExportIntervalMilliseconds);

            reader.PreferredAggregationTemporality = options.AggregationTemporality;

            return(builder.AddReader(reader));
        }
 private static TracerProviderBuilder AddConsoleExporter(TracerProviderBuilder builder, ConsoleExporterOptions options, Action <ConsoleExporterOptions> configure = null)
 {
     configure?.Invoke(options);
     return(builder.AddProcessor(new SimpleActivityExportProcessor(new ConsoleActivityExporter(options))));
 }
Exemplo n.º 10
0
 protected ConsoleExporter(ConsoleExporterOptions options)
 {
     this.options = options ?? new ConsoleExporterOptions();
 }