SPAN start gives abstraction error using ElasticApmTracer

Kibana version: 7.3.2

Elasticsearch version: 7.3.2

APM Server version: 7.3.2

APM Agent language and version: java 1.9.0

Fresh install or upgraded from other version? fresh install

Hi
I am trying to use open tracing API in my application to trace events. Can Kibana visualize the events captured by the open API spans ? I was able to trace my application using the native elastic API , but I want to make it work with open tracing API.

I have used the ElasticApmTracer but when I try to use the below line
span = tracer.buildSpan(eventName).startActive(false).span();

I am able to get SpanBuilder , scope manager but I am not able to start the span as start method is an inner interface of the main Tracer inteface .

How can i start my span after using the elasticAPm bridge

There is an example also provided in the elastic website as below

Tracer tracer = new ElasticApmTracer();
try (Scope scope = tracer.buildSpan("say-hello").startActive(true)) {
scope.span().setTag("hello-to", helloTo);
}

But the startActive method always throws the below error.

Pls assist

Error :-1:java.lang.AbstractMethodError: co.elastic.apm.opentracing.ApmSpanBuilder.startActive(Z)Lio/opentracing/Scope;

Hi and thanks for the question.

In 1.9.0 we upgraded our OpenTracing support to version 0.33, where this API was removed (rather than being marked deprecated). Since you are using an older OpenTracing version, your compiler maps this method invocation to the Tracer.SpanBuilder#startActive interface method and the runtime fails to invoke the co.elastic.apm.opentracing.ApmSpanBuilder#startActive implementation.

There are several options:

  1. Downgrade the Elastic Java agent OpenTracing bridge dependency to 1.8.0
  2. Upgrade your OpenTracing dependency to 0.33 and avoid using invalid APIs. Since you are using the startActive APM with false, this shouldn't be big problem as you already finish spans manually. You will need to use the other activation APIs.
  3. Cast the SpanBuilder returned from buildSpan to co.elastic.apm.opentracing.ApmSpanBuilder before invoking startActive

Thanks for the response . My open tracing api is version 0.33 I believe .

Also I cannot use Apmspanbuilder class in my code as the scope is default for that java class and it does not have access outside it’s own package correct ?

Can you verify?

Your code shouldn't compile with 0.33 using this API, as it does not exist in this version...

1 Like

I updated the version to 0.33 .

I used the below code to capture the open trace spans
Tracer tracer = new ElasticApmTracer();
Span span = tracer.buildSpan(eventName).start();

But Kibana is not getting any traces or events .
I have opentracing-api-0.33.0,opentracing-noop-0.33.0,opentracing-util-0.33.0,apm-opentracing-1.9.0 , apm-agent-api-1.9.0 in the class path.

Could you pls let me know why Kibana wouldnt get the events

Make sure you properly close all scopes and finish all spans. Usually, when there are no errors in the agent logs, these issues are related to improper management of the tracing objects.
You can also set log_level to DEBUG (or TRACE) and track internal transaction/span creation and lifecycle management.

1 Like

Also, I see you mentioned apm-agent-api-1.9.0.
If your code is using a mix of our API and OpenTracing, that may be difficult to properly maintain.

Sorry I did not use elastic span and transaction . I will remove that . Not mixing them up. Where can we see the logs ? In kibanaUI? Or is it written in a folder .. thanks again

Did you also install the agent itself? Note that the OpenTracing bridge classes are noop, the agent must be installed in order to make them active.

Once the agent is installed, if you did not configure it to do otherwise, it would write to the application logs.

1 Like

No I am using the apm agent as a java plugin in my application .. like .. javaagent . I am not using agent as a service. Hope it answers your question

Using it through -javaagent is what I meant by "install" :slight_smile:
OK, so you should see agent messages being logged alongside the application logs. If you see errors- please share. Otherwise, try to follow them and see whether there are activated transactions/spans not being deactivated (meaning- unclosed scopes) or spans/transactions not being ended (through OpenTracing finish).

1 Like

Sure let me try to trace logs . Also I have not closed the span . I was thinking the open trace Api will automatically take care of it . Do we need to use “scope”as wel cos I just used a tracer and directly started the span . Thanks for all the inputs much appreciate that . I will keep you posted in a few hours about the logs .

I just added the span.finish alone and the events started showing up in Kibana.
Thanks , That was quick :slight_smile: .

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.