apm-agent-java
apm-agent-java copied to clipboard
Elastic APM Java agent cannot automatically infer the class name / object name for a span when using Scala and @CaptureSpan
Describe the bug
According to the documentation @CaptureSpan
will automatically set the name of the span to Classname#methodname
. When using Scala 2, this works fine for classes but not for objects. For objects, only the #methodname
is inferred but the Classname
is just missing.
Steps to reproduce
- Use Scala 2.12.18 and
co.elastic.apm:apm-agent-api:1.50.0
. - Create a Scala class and object:
import co.elastic.apm.api.{CaptureSpan, ElasticApm, Transaction}
class Example {
@CaptureSpan
def myClassMethod() = println("Example#myClassMethod")
}
object Example {
@CaptureSpan
def myObjectMethod() = println("Example#myObjectMethod")
}
ElasticApm.startTransaction()
(new Example).myClassMethod()
Example.myObjectMethod()
ElasticApm.stopTransaction()
- Run the code.
- Check your Elastic APM instance for the captured spans.
Expected behavior
Two spans are captured with the names:
-
Example#myClassMethod
-
Example#myObjectMethod
Debug logs
n/a