Skip to content

Commit 5d0d088

Browse files
committed
Match the signature of OpenTelemetry.SuppressInstrumentationScope.Begin() to keep configuration uncluttered
1 parent aafb957 commit 5d0d088

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/Serilog.Sinks.OpenTelemetry/OpenTelemetryLoggerConfigurationExtensions.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static class OpenTelemetryLoggerConfigurationExtensions
4343
/// Send log events to an OTLP exporter.
4444
/// </summary>
4545
/// <param name="loggerSinkConfiguration">
46-
/// The `WriteTo` configuration object.
46+
/// The <c>WriteTo</c> configuration object.
4747
/// </param>
4848
/// <param name="configure">The configuration callback.</param>
4949
/// <param name="ignoreEnvironment">If false the configuration will be overridden with values
@@ -70,7 +70,9 @@ public static LoggerConfiguration OpenTelemetry(
7070
protocol: options.Protocol,
7171
headers: new Dictionary<string, string>(options.Headers),
7272
httpMessageHandler: options.HttpMessageHandler ?? CreateDefaultHttpMessageHandler(),
73-
onBeginSuppressInstrumentation: options.OnBeginSuppressInstrumentation);
73+
onBeginSuppressInstrumentation: options.OnBeginSuppressInstrumentation != null ?
74+
() => options.OnBeginSuppressInstrumentation(true)
75+
: null);
7476

7577
ILogEventSink? logsSink = null, tracesSink = null;
7678

@@ -104,7 +106,7 @@ public static LoggerConfiguration OpenTelemetry(
104106
/// Send log events to an OTLP exporter.
105107
/// </summary>
106108
/// <param name="loggerSinkConfiguration">
107-
/// The `WriteTo` configuration object.
109+
/// The <c>WriteTo</c> configuration object.
108110
/// </param>
109111
/// <param name="endpoint">
110112
/// The full URL of the OTLP exporter endpoint.
@@ -157,7 +159,7 @@ public static LoggerConfiguration OpenTelemetry(
157159
/// Audit to an OTLP exporter, waiting for each event to be acknowledged, and propagating errors to the caller.
158160
/// </summary>
159161
/// <param name="loggerAuditSinkConfiguration">
160-
/// The `AuditTo` configuration object.
162+
/// The <c>AuditTo</c> configuration object.
161163
/// </param>
162164
/// <param name="configure">The configuration callback.</param>
163165
public static LoggerConfiguration OpenTelemetry(
@@ -175,7 +177,9 @@ public static LoggerConfiguration OpenTelemetry(
175177
protocol: options.Protocol,
176178
headers: new Dictionary<string, string>(options.Headers),
177179
httpMessageHandler: options.HttpMessageHandler ?? CreateDefaultHttpMessageHandler(),
178-
onBeginSuppressInstrumentation: options.OnBeginSuppressInstrumentation);
180+
onBeginSuppressInstrumentation: options.OnBeginSuppressInstrumentation != null ?
181+
() => options.OnBeginSuppressInstrumentation(true)
182+
: null);
179183

180184
ILogEventSink? logsSink = null, tracesSink = null;
181185

src/Serilog.Sinks.OpenTelemetry/Sinks/OpenTelemetry/OpenTelemetrySinkOptions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,7 @@ public string? TracesEndpoint
167167
/// <example>
168168
/// options.OnBeginSuppressInstrumentation = OpenTelemetry.SuppressInstrumentationScope.Begin;
169169
/// </example>
170-
public Func<IDisposable>? OnBeginSuppressInstrumentation { get; set; }
170+
/// <remarks>This callback accepts a <c langword="bool"/> in order to match the signature of the OpenTelemetry SDK method
171+
/// that is typically assigned to it. The sink always provides the callback with the value <c langword="true" />.</remarks>
172+
public Func<bool, IDisposable>? OnBeginSuppressInstrumentation { get; set; }
171173
}

0 commit comments

Comments
 (0)