Requires a null check. `transaction` can be null. _Originally posted by @aheubusch in https://github.com/elastic/apm-agent-dotnet/pull/2427#discussion_r1961853629_