APM .net agent see the Service Name in the logs for correlated transactions

Sadly [FEATURE] Enrich APM integrations with APM Service name · Issue #134 · elastic/ecs-dotnet · GitHub still needs addressing so we can do this properly out of the box.

An easier way to do this manually would be:

var config = new EcsTextFormatterConfiguration()
	.MapCustom((ecsDoc, log) =>
	{
		ecsDoc.Service = new Service { Name = Agent.Config.ServiceName };
		return ecsDoc;
	});
var formatter = new EcsTextFormatter(config);

The MapCustom callback allows you to manually mutate the ecs document before its written to Elasticsearch.

Then pass that to ElasticsearchSinkOptions

CustomFormatter = formatter
2 Likes