serilog/serilog-sinks-opentelemetry

Configuration to set MessageTemplate as the log record body

danelson opened this issue · 3 comments

Consider a log like the following:

Log.LogInformation("This is a log with {data}", "This is a very long string that I don't want duplicated between an attribute and the log record body...")

The data property is duplicated between the log record body and the data attribute. This increases the cost of data transport and the cost of storage in the backend.

I would like an option where the "message template" is set to the log record body instead of the "rendered message" so that data is not duplicated. This would be like omitting the rendered message when using Serilog.Sinks.Console.

Naively I think that IncludedData could be updated to include an option such as IncludedData.MessageTemplateAsLogBody.

One partial workaround would be to modify the log record using the OpenTelemetry collector, but not everyone uses the collector and the initial data transport still happens.

Thanks for the suggestion; definitely deserves some thought 👍

Well OpenTelemetry .NET just shipped 1.6.0 which makes the OTLP Log Exporter stable. It includes the option IncludeFormattedMessage (link).

Merged in #104