# Unable to see span data from sample program using custom API

**URL:** https://discuss.elastic.co/t/unable-to-see-span-data-from-sample-program-using-custom-api/223723
**Category:** APM
**Tags:** java
**Created:** [March 16, 2020, 9:52am UTC](https://discuss.elastic.co/t/unable-to-see-span-data-from-sample-program-using-custom-api/223723 "2020-03-16T09:52:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Bhagya1218](https://avatars.discourse-cdn.com/v4/letter/b/a183cd/32.png) [@Bhagya1218](https://discuss.elastic.co/u/Bhagya1218)
#### Post date: [March 16, 2020, 9:52am UTC](https://discuss.elastic.co/t/unable-to-see-span-data-from-sample-program-using-custom-api/223723/1 "2020-03-16T09:52:27Z")

</div>

**Kibana version** :6.5.4

**Elasticsearch version** : 6.5.4

**APM Server version** :6.5.4

**APM Agent language and version** :6.5.4

**Browser version** :

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**:

**Fresh install or upgraded from other version?** Fresh

**Is there anything special in your setup?** For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:  
I am trying out a simple program to understand the usage of the APIs.  
I can see the transaction in Kibana APM, but could not get the information related to span

//Code

ElasticApmAttacher.attach();

```
    Transaction transaction = ElasticApm.startTransaction();
    try {
        transaction.setName("transactionName");
       //Do Something

        Span span = ElasticApm.currentSpan().startSpan();
        try (final Scope scope = span.activate()) {
            span.setName("customSpan");
            //Do Something

        } catch (Exception e) {
            span.captureException(e);
            throw e;
        } finally {
            span.end();
        }
    } catch (Exception e) {
        transaction.captureException(e);
    } finally {
        transaction.end();
    }

```

**Errors in browser console (if relevant)**:  
In [http://localhost:8200/intake/v2/events](http://localhost:8200/intake/v2/events) i get this error  
{"accepted":0,"errors":[{"message":"only POST requests are supported"}]}

 ![Transaction](https://us1.discourse-cdn.com/elastic/original/3X/6/b/6ba2653f8be06c29c26ec6f987ae7616f5255c6b.png)

---

<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: [March 16, 2020, 12:11pm UTC](https://discuss.elastic.co/t/unable-to-see-span-data-from-sample-program-using-custom-api/223723/2 "2020-03-16T12:11:31Z")

</div>

Hi and welcome to the forum!  
Since you only created a transaction without [activating](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html#api-span-activate) it, you cannot get it through [`currentSpan()`](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html#api-current-span) (see notes in documentation), so you are not creating a child span as you expect.  
I hope this helps.

---

<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: [April 6, 2020, 8:11am UTC](https://discuss.elastic.co/t/unable-to-see-span-data-from-sample-program-using-custom-api/223723/3 "2020-04-06T08:11:31Z")

</div>

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