# PHP APM Agent, Custom Labels are not captured

**URL:** https://discuss.elastic.co/t/php-apm-agent-custom-labels-are-not-captured/305414
**Category:** APM
**Tags:** php
**Created:** [May 23, 2022, 3:46pm UTC](https://discuss.elastic.co/t/php-apm-agent-custom-labels-are-not-captured/305414 "2022-05-23T15:46:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![vasudeva](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vasudeva](https://discuss.elastic.co/u/vasudeva)
#### Post date: [May 23, 2022, 3:46pm UTC](https://discuss.elastic.co/t/php-apm-agent-custom-labels-are-not-captured/305414/1 "2022-05-23T15:46:36Z")

</div>

**Kibana version** :7.17.0

**Elasticsearch version** :7.17.0

**APM Server version** :7.17.0

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

**Browser version** :

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

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

**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)**: Custom Labels are not included for non sampled transactions but we are expecting labels for non sampled transactions, following is sample code added in PHP application :$transaction-\>context()-\>setLabel('my label with string value', 'some text');

**Steps to reproduce** :

1. Added custom labels to PHP application and ran the application.
2. Searched APM transactions from Kibana App and found transactions but no labels and these transactions are non sampled.
3. Seen the labels for sampled transactions.

**Errors in browser console (if relevant)**:NA

**Provide logs and/or server output (if relevant)**:NA

---

<div class="post-metadata">

### Author: ![Sergey\_Kleyman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sergey_kleyman/32/39333_2.png) [@Sergey\_Kleyman](https://discuss.elastic.co/u/Sergey_Kleyman)
#### Post date: [May 24, 2022, 11:37am UTC](https://discuss.elastic.co/t/php-apm-agent-custom-labels-are-not-captured/305414/2 "2022-05-24T11:37:50Z")

</div>

Hi @vasudeva - welcome to the forum!

The behavior you described is by design - per [the online documentation](https://www.elastic.co/guide/en/apm/guide/current/sampling.html#head-based-sampling):

> ... will drop contextual information to reduce the transfer and storage size of the trace

The labels are part of the contextual information that is not captured for non-sampled transactions.

---

<div class="post-metadata">

### Author: ![vasudeva](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vasudeva](https://discuss.elastic.co/u/vasudeva)
#### Post date: [May 24, 2022, 4:34pm UTC](https://discuss.elastic.co/t/php-apm-agent-custom-labels-are-not-captured/305414/3 "2022-05-24T16:34:11Z")

</div>

Thank you for your response and this behavior is same for all agents regardless of languages like Java, Go etc..?

---

<div class="post-metadata">

### Author: ![Sergey\_Kleyman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sergey_kleyman/32/39333_2.png) [@Sergey\_Kleyman](https://discuss.elastic.co/u/Sergey_Kleyman)
#### Post date: [May 26, 2022, 1:52pm UTC](https://discuss.elastic.co/t/php-apm-agent-custom-labels-are-not-captured/305414/4 "2022-05-26T13:52:42Z")

</div>

You are welcome. Yes, this behavior should be the same for all the agents.

---

<div class="post-metadata">

### Author: ![vasudeva](https://avatars.discourse-cdn.com/v4/letter/v/7993a0/32.png) [@vasudeva](https://discuss.elastic.co/u/vasudeva)
#### Post date: [June 6, 2022, 1:39pm UTC](https://discuss.elastic.co/t/php-apm-agent-custom-labels-are-not-captured/305414/5 "2022-06-06T13:39:08Z")

</div>

Ok, also observed that the custom labels are still missing for some transactions which are sampled true and when it's transaction.result=HTTP 3xx, is it expected behavior and why?

---

<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: [June 27, 2022, 9:40am UTC](https://discuss.elastic.co/t/php-apm-agent-custom-labels-are-not-captured/305414/6 "2022-06-27T09:40:07Z")

</div>

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