in src/Elastic.Apm.SerilogEnricher/ElasticApmEnricher.cs [18:43]
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
if (!Agent.IsConfigured) return;
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("ElasticApmServiceName", Agent.Config.ServiceName));
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("ElasticApmServiceVersion", Agent.Config.ServiceVersion));
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("ElasticApmServiceNodeName", Agent.Config.ServiceNodeName));
if (Agent.Config.GlobalLabels != null)
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty("ElasticApmGlobalLabels", Agent.Config.GlobalLabels));
if (!Agent.Config.Enabled) return;
if (Agent.Tracer is null) return;
if (Agent.Tracer.CurrentTransaction is null) return;
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty(
"ElasticApmTransactionId", Agent.Tracer.CurrentTransaction.Id));
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty(
"ElasticApmTraceId", Agent.Tracer.CurrentTransaction.TraceId));
if (Agent.Tracer.CurrentSpan != null)
{
logEvent.AddPropertyIfAbsent(propertyFactory.CreateProperty(
"ElasticApmSpanId", Agent.Tracer.CurrentSpan.Id));
}
}