Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added settings option [includedData] to ConfigurationExtensions. #133

Merged
merged 9 commits into from
May 7, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public static LoggerConfiguration OpenTelemetry(
/// A attributes of the resource attached to the logs generated by the sink. The values must be simple primitive
/// values: integers, doubles, strings, or booleans. Other values will be silently ignored.
/// </param>
/// <param name="includedData">
/// Which fields should be included in the log events generated by the sink.
/// </param>
/// <param name="restrictedToMinimumLevel">
/// The minimum level for events passed through the sink. Ignored when <paramref name="levelSwitch"/> is specified.
/// </param>
Expand All @@ -100,6 +103,7 @@ public static LoggerConfiguration OpenTelemetry(
OtlpProtocol protocol = OpenTelemetrySinkOptions.DefaultProtocol,
IDictionary<string, string>? headers = null,
IDictionary<string, object>? resourceAttributes = null,
IncludedData? includedData = null,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
LoggingLevelSwitch? levelSwitch = null)
{
Expand All @@ -109,6 +113,7 @@ public static LoggerConfiguration OpenTelemetry(
{
options.Endpoint = endpoint;
options.Protocol = protocol;
options.IncludedData = includedData ?? options.IncludedData;
options.RestrictedToMinimumLevel = restrictedToMinimumLevel;
options.LevelSwitch = levelSwitch;
headers?.AddTo(options.Headers);
Expand Down Expand Up @@ -167,20 +172,25 @@ public static LoggerConfiguration OpenTelemetry(
/// A attributes of the resource attached to the logs generated by the sink. The values must be simple primitive
/// values: integers, doubles, strings, or booleans. Other values will be silently ignored.
/// </param>
/// <param name="includedData">
/// Which fields should be included in the log events generated by the sink.
/// </param>
/// <returns>Logger configuration, allowing configuration to continue.</returns>
public static LoggerConfiguration OpenTelemetry(
this LoggerAuditSinkConfiguration loggerAuditSinkConfiguration,
string endpoint = OpenTelemetrySinkOptions.DefaultEndpoint,
OtlpProtocol protocol = OpenTelemetrySinkOptions.DefaultProtocol,
IDictionary<string, string>? headers = null,
IDictionary<string, object>? resourceAttributes = null)
IDictionary<string, object>? resourceAttributes = null,
IncludedData? includedData = null)
{
if (loggerAuditSinkConfiguration == null) throw new ArgumentNullException(nameof(loggerAuditSinkConfiguration));

return loggerAuditSinkConfiguration.OpenTelemetry(options =>
{
options.Endpoint = endpoint;
options.Protocol = protocol;
options.IncludedData = includedData ?? options.IncludedData;
headers?.AddTo(options.Headers);
resourceAttributes?.AddTo(options.ResourceAttributes);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
{
public static Serilog.LoggerConfiguration OpenTelemetry(this Serilog.Configuration.LoggerAuditSinkConfiguration loggerAuditSinkConfiguration, System.Action<Serilog.Sinks.OpenTelemetry.OpenTelemetrySinkOptions> configure) { }
public static Serilog.LoggerConfiguration OpenTelemetry(this Serilog.Configuration.LoggerSinkConfiguration loggerSinkConfiguration, System.Action<Serilog.Sinks.OpenTelemetry.BatchedOpenTelemetrySinkOptions> configure) { }
public static Serilog.LoggerConfiguration OpenTelemetry(this Serilog.Configuration.LoggerAuditSinkConfiguration loggerAuditSinkConfiguration, string endpoint = "http://localhost:4317", Serilog.Sinks.OpenTelemetry.OtlpProtocol protocol = 0, System.Collections.Generic.IDictionary<string, string>? headers = null, System.Collections.Generic.IDictionary<string, object>? resourceAttributes = null) { }
public static Serilog.LoggerConfiguration OpenTelemetry(this Serilog.Configuration.LoggerSinkConfiguration loggerSinkConfiguration, string endpoint = "http://localhost:4317", Serilog.Sinks.OpenTelemetry.OtlpProtocol protocol = 0, System.Collections.Generic.IDictionary<string, string>? headers = null, System.Collections.Generic.IDictionary<string, object>? resourceAttributes = null, Serilog.Events.LogEventLevel restrictedToMinimumLevel = 0, Serilog.Core.LoggingLevelSwitch? levelSwitch = null) { }
public static Serilog.LoggerConfiguration OpenTelemetry(this Serilog.Configuration.LoggerAuditSinkConfiguration loggerAuditSinkConfiguration, string endpoint = "http://localhost:4317", Serilog.Sinks.OpenTelemetry.OtlpProtocol protocol = 0, System.Collections.Generic.IDictionary<string, string>? headers = null, System.Collections.Generic.IDictionary<string, object>? resourceAttributes = null, Serilog.Sinks.OpenTelemetry.IncludedData? includedData = default) { }
public static Serilog.LoggerConfiguration OpenTelemetry(this Serilog.Configuration.LoggerSinkConfiguration loggerSinkConfiguration, string endpoint = "http://localhost:4317", Serilog.Sinks.OpenTelemetry.OtlpProtocol protocol = 0, System.Collections.Generic.IDictionary<string, string>? headers = null, System.Collections.Generic.IDictionary<string, object>? resourceAttributes = null, Serilog.Sinks.OpenTelemetry.IncludedData? includedData = default, Serilog.Events.LogEventLevel restrictedToMinimumLevel = 0, Serilog.Core.LoggingLevelSwitch? levelSwitch = null) { }
}
}
namespace Serilog.Sinks.OpenTelemetry
Expand Down