APM Server version: 7.8.0
APM Agent language and version: java/1.33.0
I wrote an instrumentation plugin for our tibco message bus (commercial/not open) and would like to only create a publish span if there already is a transaction active.
If i always create a transaction, the problem is that a publish generated from the application itself (without external prompt, e.g. Activity-Events (shows to the world that the application is running)) will generate a transaction in APM with the type
unknown and there is no way to change this transaction type within the plugin.
I could not find a way to detect if there already is a transaction active or not.
I tried to simply use
Span.Current()==null but that is not working because
Span.Current() always returns an object only that in the case that there was no previous span it will return a span that is invalid. But i can not find a way to find out if the returned Span is invalid or not.
Has anyone a way for me to detect in a plugin if there is already an active Span or not?