Use Seq.Syntax
for message templating/property substitution?
#68
Labels
Seq.Syntax
for message templating/property substitution?
#68
While Seq has always supported nested structures in properties, the more recent versions make heavier use of this via the
@Resource
object populated from OpenTelemetry resource attributes.These kinds of events frequently carry important information nested under
@Resource
, for example@Resource.ApplicationName
in the example presented at: datalust/seq-tickets#1937.The app doesn't currently support substituting nested property paths into messages, nor including them as attachments in the comma-separated list -
a.b
is interpreted as a property with a dot in its name@Properties['a.b']
.While it would be possible to come up with a more elaborate syntax here, Seq.App.Mail.Smtp, Seq.App.Mail.Microsoft365, and Seq.App.HttpRequest now use a common Seq.Syntax package to deal with this.
Seq.Syntax provides templating along the lines of:
The great things about Seq.Syntax are:
@Level
,@Message
,@Exception
, etc.)Nested.Properties
and@Properties['irregular-names']
using identical syntax to Seq itself... in fact, nearly 100% of Seq's expression language is covered, so
Substring()
,if
, ... etc. all work.We're also aiming for syntax highlighting and autocomplete in a future Seq version for app settings tagged with
Syntax="template"
orSyntax="expression"
, and on this basis we think it'll become commonplace to use with Seq apps (replacing the mix of Handlebars and custom syntaxes the app ecosystem uses today).The downsides, and why there's a
?
in the title and not an all-out pitch here are:ISubscribeToAsync<LogEvent>
instead of theISubscribToAsync<LogEventData>
implementation the app uses right now; bringing in a dependency on Serilog'sLogEvent
is not ideal, though it's also something we want to break upstream, so should hopefully only be a matter of time, and{braces}
instead of[square brackets]
for property substitutions - this would mean some busywork and potential breakage for consumers updating to the new (2.0.0) version, andIncludedProperties
app setting, dotted property names likea.b
today would need to be rewritten as@Properties['a.b']
to avoid them being interpreted differently after then change.So definitely some drawbacks and support load.
The alternatives (besides preserving the status quo) I think are:
@Resource
and/or nested property names,Neither seem great but both are reasonable I guess, if the drawbacks are too great.
See also #25 (comment)
The text was updated successfully, but these errors were encountered: