Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/Elastic.CommonSchema.Serilog/LogEventConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,13 @@ private static Event GetEvent(LogEvent e)
var hasElapsedMs = e.TryGetScalarPropertyValue(SpecialKeys.Elapsed, out var elapsedMsObj)
|| e.TryGetScalarPropertyValue(SpecialKeys.ElapsedMilliseconds, out elapsedMsObj);

var elapsedMs = hasElapsedMs ? (double?)Convert.ToDouble(elapsedMsObj!.Value) : null;
var elapsedMs = hasElapsedMs ?
elapsedMsObj!.Value is TimeSpan ts
? ts.TotalMilliseconds
: elapsedMsObj.Value is double d
? d
: elapsedMsObj.Value is long l ? l : ToDouble()
: null;

var evnt = new Event
{
Expand Down Expand Up @@ -300,6 +306,19 @@ private static Event GetEvent(LogEvent e)
}

return evnt;

double? ToDouble()
{
try
{
return Convert.ToDouble(elapsedMsObj.Value);
}
catch
{
// ignored
}
return null;
}
}

private static Agent? GetAgent(LogEvent e)
Expand Down
Loading