ecs-dotnet icon indicating copy to clipboard operation
ecs-dotnet copied to clipboard

[FEATURE] Enrich APM integrations with APM Service name

Open russcam opened this issue 4 years ago • 5 comments

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.

russcam avatar Feb 10 '21 04:02 russcam

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 avatar Jun 05 '22 20:06 alfkonee

@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 avatar Jun 12 '22 11:06 russcam

@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])

alfkonee avatar Jun 26 '22 13:06 alfkonee

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

odin568 avatar Jun 28 '22 10:06 odin568

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

NicolasREY69330 avatar Aug 01 '22 16:08 NicolasREY69330

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.

Mpdreamz avatar Aug 31 '22 18:08 Mpdreamz

https://github.com/elastic/ecs-dotnet/pull/209 should address this now.

Mpdreamz avatar Aug 31 '22 21:08 Mpdreamz