# How to set distributed tracing setting in RUM agent?

**URL:** <https://discuss.elastic.co/t/how-to-set-distributed-tracing-setting-in-rum-agent/217329>\
**Category:** APM\
**Tags:** rum\
**Created:** [January 31, 2020, 8:59am UTC](https://discuss.elastic.co/t/how-to-set-distributed-tracing-setting-in-rum-agent/217329 "2020-01-31T08:59:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yungyoung\_Ok](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yungyoung_ok/32/43465_2.png) [@Yungyoung\_Ok](https://discuss.elastic.co/u/Yungyoung_Ok)\
**Post date:** [January 31, 2020, 8:59am UTC](https://discuss.elastic.co/t/how-to-set-distributed-tracing-setting-in-rum-agent/217329/1 "2020-01-31T08:59:45Z")

</div>

**Kibana version** :7.5.2

**Elasticsearch version** :7.5.2

**APM Server version** :7.5.2

**APM Agent language and version** :RUM agent 4.7.0

**Browser version** :chrome 79.0.3945.130

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:

i want to trace both frontend with backend using distributed tracing.  
like this...

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/c/2c1dc2902d728b96899132c2e4ec9c23cc601638.png)

But RUM agent is only show frontend tracing.

here is my config

1. RUM agent config  
elasticApm.init({  
serviceName:'service-name1',  
serviceUrl: '[http://apm-server-ip:8200](http://apm-server-ip:8200)',  
pageLoadTransactionName: pageName,  
distributedTracingOrigins: ['[http://localhost:8080](http://localhost:8080)']  
})

2. Java agent config  
service\_name=service-name2  
application\_packages=my.package.name  
server\_urls=http://apm-server-ip:8200  
span\_frames\_min\_duration=-1ms  
use\_path\_as\_transaction\_name=true

3. HTTP response  
response.setHeader("Acess-Control-Allow-Origin","_")  
response.setHeader("Acess-Control-Allow-Methods","_")  
response.setHeader("Acess-Control-Allow-Headers","\*")

**Errors in browser console (if relevant)**:  
And my console  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/c/4ceb7f427046db9db1558a604cbf1c45ec521a2a.png)

Currently both web-server and WAS is tomcat. (Same origin)  
In this case, Do I need to add that setting?  
like this...

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/9/b9e1caf9d1588ec7db607db81443e419c59b535b.png)

if i have to set this setting, how to i can set this setting?  
I try to set this setting in Ajax, but chrome is shown like this.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/7/6718e271cd15749df0ea951c734f1ae035730ca4.png)

---

<div class="post-metadata">

**Author:** ![Hamidreza](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hamidreza/32/21369_2.png) [@Hamidreza](https://discuss.elastic.co/u/Hamidreza)\
**Post date:** [February 3, 2020, 12:57pm UTC](https://discuss.elastic.co/t/how-to-set-distributed-tracing-setting-in-rum-agent/217329/2 "2020-02-03T12:57:25Z")

</div>

Hi @Yungyoung_Ok,

Thanks using Elastic APM.

Would you please provide the requests that fail in your browser ? (You can copy them from the Networks tab in your browser's devtools). Please make sure to remove any sensitive or personal information from the requests though.

Also, which origin your web application is served from? (the address that you see in the browser address bar)

Cheers,  
Hamid

---

<div class="post-metadata">

**Author:** ![Yungyoung\_Ok](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yungyoung_ok/32/43465_2.png) [@Yungyoung\_Ok](https://discuss.elastic.co/u/Yungyoung_Ok)\
**Post date:** [February 4, 2020, 1:50am UTC](https://discuss.elastic.co/t/how-to-set-distributed-tracing-setting-in-rum-agent/217329/3 "2020-02-04T01:50:28Z")

</div>

1. 

I added that setting to ajax for distribution tracking.  
And I checked the above error on the console.

```
xmlHttpRequest.setRequestHeader("Origin","*");
xmlHttpRequest.setRequestHeader("Access-Control-Request-Headers","Origin, X-Requested-With, elastic-apm-traceparent")
xmlHttpRequest.setRequestHeader("Access-Control-Request-Method","POST");

```

1. my web server&was is tomcat.  
Connect to localhost: 8080 in a browser.  
I think, this setting is the same origin.  
is it right?  
Do I need to add the same origin setting in my current situation?  
If so, how do I solve the above error(refused to set unsafe...)?

How can I set it up like the picture below?  
The picture below was captured at [demo.elastic.co](http://demo.elastic.co).

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1a57e2c66d432912770e848f0edc9a70978ad355.png)

---

<div class="post-metadata">

**Author:** ![Hamidreza](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hamidreza/32/21369_2.png) [@Hamidreza](https://discuss.elastic.co/u/Hamidreza)\
**Post date:** [February 11, 2020, 1:26pm UTC](https://discuss.elastic.co/t/how-to-set-distributed-tracing-setting-in-rum-agent/217329/4 "2020-02-11T13:26:48Z")

</div>

It seems that you are adding those headers manually in your frontend application and that's why the browser is showing those errors. In other words having `xmlHttpRequest.setRequestHeader("Origin","*");` is not valid. These headers are automatically added by the browser to the OPTIONS request that the browser sends before the original POST request.

Only your backend (Java) application should be able to respond appropriately with the headers stated in our documentation.

Does this help answer your question?

---

<div class="post-metadata">

**Author:** ![Yungyoung\_Ok](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yungyoung_ok/32/43465_2.png) [@Yungyoung\_Ok](https://discuss.elastic.co/u/Yungyoung_Ok)\
**Post date:** [February 12, 2020, 12:30am UTC](https://discuss.elastic.co/t/how-to-set-distributed-tracing-setting-in-rum-agent/217329/5 "2020-02-12T00:30:08Z")

</div>

Yes, thank you!  
I solved the problem.

My js page reads several js internally, which seems to have conflicted with other js.  
Declaring rum.js read first solved the problem.

---

<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:** [March 3, 2020, 8:30pm UTC](https://discuss.elastic.co/t/how-to-set-distributed-tracing-setting-in-rum-agent/217329/6 "2020-03-03T20:30:19Z")

</div>

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