# APM missing custom spans and incorrect name

**URL:** <https://discuss.elastic.co/t/apm-missing-custom-spans-and-incorrect-name/336325>\
**Category:** APM\
**Tags:** docker, php\
**Created:** [June 19, 2023, 4:48am UTC](https://discuss.elastic.co/t/apm-missing-custom-spans-and-incorrect-name/336325 "2023-06-19T04:48:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francis\_Lewis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/francis_lewis/32/122414_2.png) [@Francis\_Lewis](https://discuss.elastic.co/u/Francis_Lewis)\
**Post date:** [June 19, 2023, 4:48am UTC](https://discuss.elastic.co/t/apm-missing-custom-spans-and-incorrect-name/336325/1 "2023-06-19T04:48:40Z")

</div>

**Kibana version** : 6.8.0

**APM Server version** :

**APM Agent language and version** : PHP 1.8.3

**Browser version** : Google Chrome 114

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

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

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**: Using Docker locally and in AWS, I'm seeing 2 different behaviors when using Elastic APM. My code starts out making sure the transaction exists:

```auto
<?php
		$this->transaction = ElasticApm::getCurrentTransaction();
		if (!$this->transaction) {
			$this->transaction = ElasticApm::beginTransaction('other', $type);
		}

		$this->transactionId = $this->transaction->getId();

```

When running stepthrough debugger, beginTransaction is never hit. Not exactly how the documentation says to do it, but when I do run start, I get an error message stating that the transaction already exists. Ok, not exactly how the document says to do it, but I can deal with that.

Next up, we figure out the page parts for the request, then set the transaction name:

```auto
<?php
    $parts = [
        // name, filter, default
	$request->getQuery('page', null, 'cli'),
	$request->getQuery('content', null, 'default'),
    ];

    Di::getElastic()->setName(implode('/', $parts));

```

The set name function runs this:

```auto
<?php
		$name = preg_replace('#(?=.*?\d)(?=.*?[a-zA-Z])[a-zA-Z\d]{12}#i', ':e_id', $name);
		$type = Di::getRequest()->getMethod();
		$this->transaction->setName($type . ' ' . $name);

```

Great! Locally, this is showing up in APM as:  
`GET appdetail/show`

In AWS, I'm seeing this:  
`GET appdetail/show/a4dm3v0tqsvt/1`

So why is it not changing the name of the transaction from the default?

Next problem:  
I created span logging for AWS services. These are showing up beautifully when running locally. When running in AWS, only the default span services (e.g. MySQL) are shown.

Screenshot of the name change issue:

 ![Transactions_and_Transactions](https://us1.discourse-cdn.com/elastic/original/3X/b/0/b06d4e30ab0000e71bdb9af37c4870ffb00368e9.jpeg)

Screenshot of the span issue in comments.

---

<div class="post-metadata">

**Author:** ![Francis\_Lewis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/francis_lewis/32/122414_2.png) [@Francis\_Lewis](https://discuss.elastic.co/u/Francis_Lewis)\
**Post date:** [June 19, 2023, 4:49am UTC](https://discuss.elastic.co/t/apm-missing-custom-spans-and-incorrect-name/336325/2 "2023-06-19T04:49:29Z")

</div>

Screenshot of missing spans:

 ![GET_appdetail_show_and_GET__appdetail_show_a4dm3v0tqsvt_1](https://us1.discourse-cdn.com/elastic/original/3X/d/8/d8b9cfeb2f87356551db9260c4d5cc99b5a69fd2.jpeg)

---

<div class="post-metadata">

**Author:** ![Francis\_Lewis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/francis_lewis/32/122414_2.png) [@Francis\_Lewis](https://discuss.elastic.co/u/Francis_Lewis)\
**Post date:** [June 19, 2023, 7:25pm UTC](https://discuss.elastic.co/t/apm-missing-custom-spans-and-incorrect-name/336325/3 "2023-06-19T19:25:59Z")

</div>

Turns out this was because the environment variables in apache were removed on the server. I removed them locally and starting seeing the same behavior, where it wasn't setting the name or getting all of the spans. Put the environment variables back into apache on the server and all was good. Case closed!  
It still bothers me that the spreadsheet shows that S3, DynamoDB, Redis, and other services are supported, but there is no icon or prefix for those. Only database as far as I can tell.

---

<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:** [July 17, 2023, 7:26pm UTC](https://discuss.elastic.co/t/apm-missing-custom-spans-and-incorrect-name/336325/4 "2023-07-17T19:26:03Z")

</div>

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