Spans won't be shown in APM -> Services/Traces

I'm working on a Framework 4.8 web application (C#) and using the latest NuGet packages:

  • Elastic.Apm.AspNetFullFramework
  • Elastic.Apm.NetCoreAll

I start new spans via Transaction.StartSpan (Agent.Tracer.CurrentTransaction). There is a transaction; I wrapped this transaction in a scoped service and manually end the transaction in the Dispose method. Everything works fine: I see the transactions and the created spans of different types (custom). Every span has End() called.

However, when I open Observability → APM → Services → Transactions, there are no spans or only very few, and only of the type db.mssql.query.

I am using the latest versions of APM Server, Elasticsearch, and Kibana via Docker.
Data views: APM
Index pattern: traces-apm*,apm-*,logs-apm*,apm-*,metrics-apm*,apm-*

Example:


When i investigate the transaction in Discover, there are 59 spans started ...

What am I doing wrong?

Is it due to the Kibana configuration (and how can it be properly configured?) or is it due to the code?