# SPAN start gives abstraction error using ElasticApmTracer

**URL:** <https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513>\
**Category:** APM\
**Tags:** java\
**Created:** [October 14, 2019, 7:29pm UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513 "2019-10-14T19:29:42Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![anjana1](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@anjana1](https://discuss.elastic.co/u/anjana1)\
**Post date:** [October 14, 2019, 7:29pm UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513/1 "2019-10-14T19:29:42Z")

</div>

**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 👎java.lang.AbstractMethodError: co.elastic.apm.opentracing.ApmSpanBuilder.startActive(Z)Lio/opentracing/Scope;

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [October 15, 2019, 9:10am UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513/2 "2019-10-15T09:10:05Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![anjana1](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@anjana1](https://discuss.elastic.co/u/anjana1)\
**Post date:** [October 15, 2019, 3:13pm UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513/3 "2019-10-15T15:13:20Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [October 15, 2019, 3:14pm UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513/4 "2019-10-15T15:14:25Z")

</div>

> [@anjana1](#):
>
> My open tracing api is version 0.33 I believe

Can you verify?

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [October 15, 2019, 3:19pm UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513/5 "2019-10-15T15:19:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anjana1](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@anjana1](https://discuss.elastic.co/u/anjana1)\
**Post date:** [October 15, 2019, 5:54pm UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513/6 "2019-10-15T17:54:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [October 16, 2019, 3:48am UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513/7 "2019-10-16T03:48:41Z")

</div>

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`](https://www.elastic.co/guide/en/apm/agent/java/current/config-logging.html#config-log-level) to `DEBUG` (or `TRACE`) and track internal transaction/span creation and lifecycle management.

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [October 16, 2019, 3:51am UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513/8 "2019-10-16T03:51:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anjana1](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@anjana1](https://discuss.elastic.co/u/anjana1)\
**Post date:** [October 16, 2019, 4:09am UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513/9 "2019-10-16T04:09:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [October 16, 2019, 4:16am UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513/10 "2019-10-16T04:16:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anjana1](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@anjana1](https://discuss.elastic.co/u/anjana1)\
**Post date:** [October 16, 2019, 4:56am UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513/11 "2019-10-16T04:56:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [October 16, 2019, 6:44am UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513/12 "2019-10-16T06:44:33Z")

</div>

Using it through `-javaagent` is what I meant by "install" 🙂  
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`).

---

<div class="post-metadata">

**Author:** ![anjana1](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@anjana1](https://discuss.elastic.co/u/anjana1)\
**Post date:** [October 16, 2019, 3:13pm UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513/13 "2019-10-16T15:13:58Z")

</div>

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 .

---

<div class="post-metadata">

**Author:** ![anjana1](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@anjana1](https://discuss.elastic.co/u/anjana1)\
**Post date:** [October 16, 2019, 7:14pm UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513/14 "2019-10-16T19:14:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 6, 2019, 3:14pm UTC](https://discuss.elastic.co/t/span-start-gives-abstraction-error-using-elasticapmtracer/203513/15 "2019-11-06T15:14:52Z")

</div>

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