Discard traces with no exit spans

Hello there,
is it possible to discard traces which have no spans assigned to them?
I am currently (manually) integrating APM in my .NET Framework WinForms application and I see a lot of traces which have no spans (which is correct and not the issue). Those traces have no value to me because I am only interested in traces which have exit spans for HTTP-calls or DB calls.

I haven't seen a setting in the APM agent or the server to discard souch traces automatically.
I looked into the Elastic.Apm.Api - but i haven't found a way to discard souch traces before they are sent to the APM server (IExecutionSegment.IsSampled is write protected). The only way i could think of is that i add a label no_spans if CurrentTransaction.SpanCount == 0 and somehow discard souch traces in an ingest pipeline.

Would this be a valid way or are there other ways I haven't seen?

Thanks :slightly_smiling_face:

Found the solution.
It's pretty easy: You can use

Elastic.Apm.Agent.AddFilter((ITransaction e) => e.SpanCount.Started < 1 ? null : e);

This Delegate gets called when the Agent is sending the traces. If the transaction, span, ... is set to null, it isn't sent to the server.