# Trace custom header injected through filter in transaction details

**URL:** <https://discuss.elastic.co/t/trace-custom-header-injected-through-filter-in-transaction-details/252373>\
**Category:** APM\
**Tags:** java\
**Created:** [October 16, 2020, 4:56pm UTC](https://discuss.elastic.co/t/trace-custom-header-injected-through-filter-in-transaction-details/252373 "2020-10-16T16:56:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alain\_Bod](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alain_bod/32/77345_2.png) [@Alain\_Bod](https://discuss.elastic.co/u/Alain_Bod)\
**Post date:** [October 16, 2020, 4:56pm UTC](https://discuss.elastic.co/t/trace-custom-header-injected-through-filter-in-transaction-details/252373/1 "2020-10-16T16:56:43Z")

</div>

**Kibana version** : 7.4.2

**Elasticsearch version** : 7.4.2

**APM Server version** : 7.4.2

**APM Agent language and version** : java 1.18.1 (Manual setup with `-javaagent` flag)

We have plugged the java APM agent to our dropwizard application.  
In this application we have a `ContainerRequestFilter` executed after the resource is matched that injects custom HTTP headers in the request (through `ContainerRequestContext.getHeaders().add()` method). They are perfectly passed on to our code that follows.  
However we can't see these headers in the Transaction details view in Kibana (we only see the request headers sent by the client). Is that possible to see them without calling the java APM API in our code (we'd like to avoid including specific code)?

Thanks in advance,

---

<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 19, 2020, 6:55am UTC](https://discuss.elastic.co/t/trace-custom-header-injected-through-filter-in-transaction-details/252373/2 "2020-10-19T06:55:08Z")

</div>

Welcome to our forum!

It appears that the transactions are created before your `ContainerRequestFilter` gets executed, which is why the headers added by it are not visible.

> [@Alain\_Bod](#):
>
> Is that possible to see them without calling the java APM API in our code (we'd like to avoid including specific code)?

I'm afraid the public API is the way to go. I understand why you don't want to add such a dependency to your application. One thing I can suggest is adding another filter **after** the one that adds the headers, and use the API to add the new headers to the Transaction as labels. This way, you can isolate it from your application code (including your current filter code), so it is the only one with the API dependency. It worth to mention also that the API jar is noop as long as there is no APM agent attached, meaning - it will have no effect on your application whatsoever in the absence of the Java agent.

I hope this helps.

---

<div class="post-metadata">

**Author:** ![Alain\_Bod](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alain_bod/32/77345_2.png) [@Alain\_Bod](https://discuss.elastic.co/u/Alain_Bod)\
**Post date:** [October 19, 2020, 7:36am UTC](https://discuss.elastic.co/t/trace-custom-header-injected-through-filter-in-transaction-details/252373/3 "2020-10-19T07:36:49Z")

</div>

Thank you for your reply, we'll go for that option then.  
However, we'll add the extra headers as labels, right? I don't see in the Transaction API a way to add headers.

---

<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 19, 2020, 9:23am UTC](https://discuss.elastic.co/t/trace-custom-header-injected-through-filter-in-transaction-details/252373/4 "2020-10-19T09:23:27Z")

</div>

> [@Alain\_Bod](#):
>
> we'll add the extra headers as labels, right?

That's right, but label keys are indexed, so they will have the same functionality as headers provide.  
Good luck!

---

<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 9, 2020, 5:23am UTC](https://discuss.elastic.co/t/trace-custom-header-injected-through-filter-in-transaction-details/252373/5 "2020-11-09T05:23:33Z")

</div>

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