Skip to content

Commit 54bf52f

Browse files
committed
Updated documentation with TraceId and SpanId
1 parent 8334b5d commit 54bf52f

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,18 +406,22 @@ By default (and consistent with the SQL DDL to create a table shown earlier) the
406406
- `StandardColumn.Exception`
407407
- `StandardColumn.Properties`
408408

409-
There is one additional Standard Column which is not included by default (for backwards-compatibility reasons):
409+
There are the following additional standard columns which are not included by default (for backwards-compatibility reasons):
410410

411411
- `StandardColumn.LogEvent`
412+
- `StandardColumn.TraceId`
413+
- `StandardColumn.SpanId`
412414

413415
You can change this list as long as the underlying table definition is consistent:
414416

415417
```csharp
416418
// we don't need XML data
417419
columnOptions.Store.Remove(StandardColumn.Properties);
418420

419-
// we do want JSON data
421+
// we do want JSON data and OpenTelemetry
420422
columnOptions.Store.Add(StandardColumn.LogEvent);
423+
columnOptions.Store.Add(StandardColumn.TraceId);
424+
columnOptions.Store.Add(StandardColumn.SpanId);
421425
```
422426

423427
In addition to any special properties described below, each Standard Column also has the usual column properties like `ColumnName` as described in the topic [SqlColumn Objects](#sqlcolumn-objects).
@@ -454,7 +458,7 @@ In case `DataLength` is set to a specific value different from -1, any message l
454458

455459
This column stores the log event message with the property placeholders. It defaults to `nvarchar(max)`. The `DataType` property can only be set to character-storage types.
456460

457-
If `DataLength` is set to a value different to -1 longer text will be truncated. See [Message column](#message ) for details.
461+
If `DataLength` is set to a value different to -1 longer text will be truncated. See [Message column](#message) for details.
458462

459463
### Level
460464

@@ -506,10 +510,16 @@ If `OmitElementIfEmpty` is set then if a property is empty, it will not be seria
506510

507511
This column stores log event property values as JSON. Typically you will use either this column or the XML-based `Properties` column, but not both. This column's `DataType` must always be `nvarchar`.
508512

509-
The `ExcludeAddtionalProperties` and `ExcludeStandardColumns` properties are described in the [Custom Property Columns](#custom-property-columns) topic.
513+
By default this column is not used unless it is added to the `ColumnOptions.Store` property as documented [above](#standard-columns).
510514

511515
The content of this column is rendered as JSON by default or with a custom ITextFormatter passed by the caller as parameter `logEventFormatter`. Details can be found in [Sink Configuration](#sink-configuration).
512516

517+
### TraceId and SpanId
518+
519+
These two columns store the OpenTelemetry `TraceId` and `SpanId` log event properties which are documented [here](https://github.com/serilog/serilog/issues/1923). The `DataType` of these columns must be `nvarchar` or `varchar`.
520+
521+
By default these columns are not used unless they are added to the `ColumnOptions.Store` property as documented [above](#standard-columns).
522+
513523
## Custom Property Columns
514524

515525
By default, any log event properties you include in your log statements will be saved to the XML `Properties` column or the JSON `LogEvent` column. But they can also be stored in their own individual columns via the `AdditionalColumns` collection. This adds overhead to write operations but is very useful for frequently-queried properties. Only `ColumnName` is required; the default configuration is `varchar(max)`.
@@ -604,7 +614,7 @@ As the name suggests, `columnOptionSection` is an entire configuration section i
604614
"disableTriggers": true,
605615
"clusteredColumnstoreIndex": false,
606616
"primaryKeyColumnName": "Id",
607-
"addStandardColumns": [ "LogEvent" ],
617+
"addStandardColumns": [ "LogEvent", "TraceId", "SpanId" ],
608618
"removeStandardColumns": [ "MessageTemplate", "Properties" ],
609619
"additionalColumns": [
610620
{ "ColumnName": "EventType", "DataType": "int", "AllowNull": false },
@@ -668,6 +678,8 @@ Keys and values are case-sensitive. Case must match **_exactly_** as shown below
668678
<!-- ColumnOptions parameters -->
669679
<AddStandardColumns>
670680
<add Name="LogEvent"/>
681+
<add Name="TraceId"/>
682+
<add Name="SpanId"/>
671683
</AddStandardColumns>
672684
<RemoveStandardColumns>
673685
<remove Name="Properties"/>

0 commit comments

Comments
 (0)