Skip to content

Commit

Permalink
Create EcsDocument from IEcsEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
mrapavy committed Dec 21, 2023
1 parent 6892d11 commit f6ec2eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/SerilogEcsLogging/Logging/EcsDocument.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Elastic.CommonSchema;
using System.Reflection;
using Elastic.CommonSchema;

namespace SerilogEcsLogging.Logging;

Expand Down Expand Up @@ -32,10 +33,15 @@ public EcsDocument(IEcsEvent ev)
};
}

if (ev.ServiceState != null)
{
Service = new Service { State = ev.ServiceState.ToString() };
}
Service = new Service {
State = ev.ServiceState?.ToString(),
Name = Assembly.GetExecutingAssembly().GetName().Name,
Version = Assembly.GetExecutingAssembly().GetName().Version?.ToString(),
Type = ev.EventModule,
Address = System.Net.Dns.GetHostName()
};

Host = new Host { Hostname = Service.Address };

TransactionId = ev.TransactionId;
TraceId = ev.TraceId;
Expand Down
2 changes: 1 addition & 1 deletion src/SerilogEcsLogging/SerilogEcsLogging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>mrapavy</Authors>
<PackageProjectUrl>https://github.com/mrapavy/serilog-ecs-logging</PackageProjectUrl>
<Version>1.1.3</Version>
<Version>1.1.4</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit f6ec2eb

Please sign in to comment.