Skip to content

Commit 42eb997

Browse files
authored
Merge pull request #302 from KodrAus/feat/trace-support
Support ingesting span events
2 parents 56c6a24 + ac15fdc commit 42eb997

25 files changed

+118
-310
lines changed

Build.Docker.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ $archs = @(
1313
@{ rid = "arm64"; platform = "linux/arm64/v8" }
1414
)
1515

16+
$endToEndVersion = "preview"
17+
1618
function Execute-Tests
1719
{
1820
& dotnet test ./test/SeqCli.Tests/SeqCli.Tests.csproj -c Release -f $framework /p:Configuration=Release /p:VersionPrefix=$version
1921
if ($LASTEXITCODE -ne 0) { exit 1 }
2022

2123
cd ./test/SeqCli.EndToEnd/
22-
docker pull datalust/seq:latest
24+
docker pull "datalust/seq:$endToEndVersion"
25+
docker tag "datalust/seq:$endToEndVersion" datalust/seq:latest
2326
& dotnet run -f $framework -- --docker-server
2427
if ($LASTEXITCODE -ne 0)
2528
{

src/SeqCli/Cli/Commands/IngestCommand.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ protected override async Task<int> Run()
8787
foreach (var (name, value) in _properties.Properties)
8888
enrichers.Add(new ScalarPropertyEnricher(name, value));
8989

90-
if (_level != null)
91-
enrichers.Add(new ScalarPropertyEnricher(SurrogateLevelProperty.PropertyName, _level));
92-
9390
Func<LogEvent, bool>? filter = null;
9491
if (_filter != null)
9592
{

src/SeqCli/Cli/Commands/PrintCommand.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ var theme
7575
var outputConfiguration = new LoggerConfiguration()
7676
.MinimumLevel.Is(LevelAlias.Minimum)
7777
.Enrich.With<RedundantEventTypeRemovalEnricher>()
78-
.Enrich.With<SurrogateLevelRemovalEnricher>()
7978
.WriteTo.Console(
8079
outputTemplate: _template ?? OutputFormatFeature.DefaultOutputTemplate,
8180
theme: theme,

src/SeqCli/Cli/Commands/SearchCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ LogEvent ToSerilogEvent(EventEntity evt)
108108
new MessageTemplate(evt.MessageTemplateTokens.Select(ToMessageTemplateToken)),
109109
evt.Properties
110110
.Select(p => CreateProperty(p.Name, p.Value))
111-
.Concat(new[] { new LogEventProperty(SurrogateLevelProperty.PropertyName, new ScalarValue(evt.Level)) }));
111+
);
112112
}
113113

114114
static MessageTemplateToken ToMessageTemplateToken(MessageTemplateTokenPart token)

src/SeqCli/Cli/Features/OutputFormatFeature.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ public Logger CreateOutputLogger()
7777

7878
if (_json)
7979
{
80-
outputConfiguration.WriteTo.Console(new SurrogateLevelAwareCompactJsonFormatter());
80+
outputConfiguration.WriteTo.Console(OutputFormatter.Json);
8181
}
8282
else
8383
{
84-
outputConfiguration.Enrich.With<SurrogateLevelRemovalEnricher>();
8584
outputConfiguration.WriteTo.Console(
8685
outputTemplate: DefaultOutputTemplate,
8786
theme: Theme,

src/SeqCli/Ingestion/JsonLogEventReader.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,14 @@ public static LogEvent ReadFromJObject(JObject jObject)
7070

7171
if (jObject.TryGetValue("@l", out var levelToken))
7272
{
73+
var originalLevel = levelToken.Value<string>()!;
7374
jObject.Remove("@l");
7475

75-
var serilogLevel = LevelMapping.ToSerilogLevel(levelToken.Value<string>()!);
76+
var serilogLevel = LevelMapping.ToSerilogLevel(originalLevel);
7677
if (serilogLevel != LogEventLevel.Information)
7778
jObject.Add("@l", new JValue(serilogLevel.ToString()));
78-
79-
jObject.Add(SurrogateLevelProperty.PropertyName, levelToken);
80-
}
81-
else
82-
{
83-
jObject.Add(SurrogateLevelProperty.PropertyName, new JValue("Information"));
79+
80+
jObject.Add(LevelMapping.SurrogateLevelProperty, originalLevel);
8481
}
8582

8683
return LogEventReader.ReadFromJObject(jObject);

src/SeqCli/Ingestion/LogShipper.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,14 @@
2121
using Newtonsoft.Json;
2222
using Seq.Api;
2323
using SeqCli.Api;
24-
using SeqCli.Levels;
24+
using SeqCli.Output;
2525
using Serilog;
2626
using Serilog.Events;
2727

2828
namespace SeqCli.Ingestion;
2929

3030
static class LogShipper
3131
{
32-
static readonly SurrogateLevelAwareCompactJsonFormatter Formatter = new SurrogateLevelAwareCompactJsonFormatter();
33-
3432
public static async Task<int> ShipEvents(
3533
SeqConnection connection,
3634
string? apiKey,
@@ -157,7 +155,7 @@ static async Task<bool> SendBatchAsync(
157155
using (var builder = new StringWriter())
158156
{
159157
foreach (var evt in batch)
160-
Formatter.Format(evt, builder);
158+
OutputFormatter.Json.Format(evt, builder);
161159

162160
content = new StringContent(builder.ToString(), Encoding.UTF8, ApiConstants.ClefMediaType);
163161
}

src/SeqCli/Levels/LevelMapping.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ namespace SeqCli.Levels;
2020

2121
public static class LevelMapping
2222
{
23+
// Use a "hygienic" name for the original level value to avoid collisions
24+
internal static readonly string SurrogateLevelProperty = $"_SeqcliOriginalLevel_{Guid.NewGuid():N}";
25+
2326
static readonly Dictionary<string, (string, LogEventLevel)> LevelsByName =
2427
new(StringComparer.OrdinalIgnoreCase)
2528
{

src/SeqCli/Levels/SurrogateLevelAwareCompactJsonFormatter.cs

Lines changed: 0 additions & 134 deletions
This file was deleted.

src/SeqCli/Levels/SurrogateLevelProperty.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)