ecs-dotnet
ecs-dotnet copied to clipboard
[FEATURE] Enrich APM integrations with APM Service name
The ecs-logging spec defines a service.name
property that can be populated with the APM agent service name. ECS .NET APM integrations should populate this value.
Possible Implementation
The APM .NET agent does not currently expose the Service name of the agent instance on the Agent
static class. First, we should decide what should be exposed, and how to expose it. For example, it may not make sense to expose the whole Service
, but just the name.
Hello @russcam Please isn't the Agent.Config Object containing the ServiceName. I think we could use Agent.Config.ServiceName
to get the Service name if I'm missing something here please lemme know
@alfkonee yes, you are right. And since the discovered name is part of ParseServiceName(...)
, in case a service name is not explicitly set, then using Agent.Config.ServiceName
would be the easiest way to get it
@russcam In that case which field key do we enrich the logs with to add this linking is it just service.name
cus it thats it's I could create a PR for the Serilog Enrichment (Maybe NLog too[Not very Familiar])
Coming from Java to .NET, stumbled about this issue as well. I miss a way to set the service.name, service.version and service.environment . Any way to accomplish? Using NLog
Hello @russcam is it related to the fact we can't see Service Name in APM ? https://discuss.elastic.co/t/apm-net-agent-see-the-service-name-in-the-logs-for-correlated-transactions/311137 If yes is there a workaround ? Thank you for your help
Just posting this here as well if you are using EcsTextFormatter
with Serilog today you could use:
var config = new EcsTextFormatterConfiguration()
.MapCustom((ecsDoc, log) =>
{
ecsDoc.Service = new Service { Name = Agent.Config.ServiceName };
return ecsDoc;
});
var formatter = new EcsTextFormatter(config);
We will make sure this works OOTB in the next update though.
https://github.com/elastic/ecs-dotnet/pull/209 should address this now.