internal OpenTelemetryLoggerProvider(OpenTelemetryLoggerOptions options) { Guard.ThrowIfNull(options, nameof(options)); this.Options = options; this.Resource = options.ResourceBuilder.Build(); foreach (var processor in options.Processors) { this.AddProcessor(processor); } }
/// <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 SimpleLogRecordExportProcessor(new ConsoleLogRecordExporter(options)))); }
public static OpenTelemetryLoggerOptions AddInMemoryExporter(this OpenTelemetryLoggerOptions loggerOptions, ICollection <LogRecord> exportedItems) { if (loggerOptions == null) { throw new ArgumentNullException(nameof(loggerOptions)); } if (exportedItems == null) { throw new ArgumentNullException(nameof(exportedItems)); } return(loggerOptions.AddProcessor(new SimpleLogRecordExportProcessor(new InMemoryExporter <LogRecord>(exportedItems)))); }
private static OpenTelemetryLoggerOptions AddOtlpExporter(OpenTelemetryLoggerOptions loggerOptions, OtlpExporterOptions exporterOptions, Action <OtlpExporterOptions> configure = null) { configure?.Invoke(exporterOptions); var otlpExporter = new OtlpLogExporter(exporterOptions); if (exporterOptions.ExportProcessorType == ExportProcessorType.Simple) { return(loggerOptions.AddProcessor(new SimpleLogRecordExportProcessor(otlpExporter))); } else { return(loggerOptions.AddProcessor(new BatchLogRecordExportProcessor( otlpExporter, exporterOptions.BatchExportProcessorOptions.MaxQueueSize, exporterOptions.BatchExportProcessorOptions.ScheduledDelayMilliseconds, exporterOptions.BatchExportProcessorOptions.ExporterTimeoutMilliseconds, exporterOptions.BatchExportProcessorOptions.MaxExportBatchSize))); } }
/// <summary> /// Adds OTLP 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 AddOtlpExporter(this OpenTelemetryLoggerOptions loggerOptions, Action <OtlpExporterOptions> configure = null) { Guard.Null(loggerOptions); return(AddOtlpExporter(loggerOptions, new OtlpExporterOptions(), configure)); }