@@ -27,32 +27,58 @@ namespace OpenTelemetry.Logs
2727 /// </summary>
2828 public static class OtlpLogExporterHelperExtensions
2929 {
30+ /// <summary>
31+ /// Adds OTLP Exporter as a configuration to the OpenTelemetry ILoggingBuilder.
32+ /// </summary>
33+ /// <remarks><inheritdoc cref="AddOtlpExporter(OpenTelemetryLoggerOptions, string, Action{OtlpExporterOptions})" path="/remarks"/></remarks>
34+ /// <param name="loggerOptions"><see cref="OpenTelemetryLoggerOptions"/> options to use.</param>
35+ /// <returns>The instance of <see cref="OpenTelemetryLoggerOptions"/> to chain the calls.</returns>
36+ public static OpenTelemetryLoggerOptions AddOtlpExporter ( this OpenTelemetryLoggerOptions loggerOptions )
37+ => AddOtlpExporter ( loggerOptions , name : null , configure : null ) ;
38+
39+ /// <summary>
40+ /// Adds OTLP Exporter as a configuration to the OpenTelemetry ILoggingBuilder.
41+ /// </summary>
42+ /// <remarks><inheritdoc cref="AddOtlpExporter(OpenTelemetryLoggerOptions, string, Action{OtlpExporterOptions})" path="/remarks"/></remarks>
43+ /// <param name="loggerOptions"><see cref="OpenTelemetryLoggerOptions"/> options to use.</param>
44+ /// <param name="configure">Callback action for configuring <see cref="OtlpExporterOptions"/>.</param>
45+ /// <returns>The instance of <see cref="OpenTelemetryLoggerOptions"/> to chain the calls.</returns>
46+ public static OpenTelemetryLoggerOptions AddOtlpExporter (
47+ this OpenTelemetryLoggerOptions loggerOptions ,
48+ Action < OtlpExporterOptions > configure )
49+ => AddOtlpExporter ( loggerOptions , name : null , configure ) ;
50+
3051 /// <summary>
3152 /// Adds OTLP Exporter as a configuration to the OpenTelemetry ILoggingBuilder.
3253 /// </summary>
3354 /// <remarks>
34- /// Note: <see cref="AddOtlpExporter(OpenTelemetryLoggerOptions,
35- /// Action{OtlpExporterOptions})"/> automatically sets <see
55+ /// Note: AddOtlpExporter automatically sets <see
3656 /// cref="OpenTelemetryLoggerOptions.ParseStateValues"/> to <see
3757 /// langword="true"/>.
3858 /// </remarks>
3959 /// <param name="loggerOptions"><see cref="OpenTelemetryLoggerOptions"/> options to use.</param>
40- /// <param name="configure">Exporter configuration options.</param>
60+ /// <param name="name">Name which is used when retrieving options.</param>
61+ /// <param name="configure">Callback action for configuring <see cref="OtlpExporterOptions"/>.</param>
4162 /// <returns>The instance of <see cref="OpenTelemetryLoggerOptions"/> to chain the calls.</returns>
42- public static OpenTelemetryLoggerOptions AddOtlpExporter ( this OpenTelemetryLoggerOptions loggerOptions , Action < OtlpExporterOptions > configure = null )
63+ public static OpenTelemetryLoggerOptions AddOtlpExporter (
64+ this OpenTelemetryLoggerOptions loggerOptions ,
65+ string name ,
66+ Action < OtlpExporterOptions > configure )
4367 {
4468 Guard . ThrowIfNull ( loggerOptions ) ;
4569
4670 loggerOptions . ParseStateValues = true ;
4771
72+ name ??= Options . DefaultName ;
73+
4874 if ( configure != null )
4975 {
50- loggerOptions . ConfigureServices ( services => services . Configure ( configure ) ) ;
76+ loggerOptions . ConfigureServices ( services => services . Configure ( name , configure ) ) ;
5177 }
5278
5379 return loggerOptions . ConfigureProvider ( ( sp , provider ) =>
5480 {
55- var options = sp . GetRequiredService < IOptions < OtlpExporterOptions > > ( ) . Value ;
81+ var options = sp . GetRequiredService < IOptionsSnapshot < OtlpExporterOptions > > ( ) . Get ( name ) ;
5682
5783 AddOtlpExporter ( provider , options , sp ) ;
5884 } ) ;
0 commit comments