# How to send a debug message to elastic APM Real User Monitoring from my application?

**URL:** <https://discuss.elastic.co/t/how-to-send-a-debug-message-to-elastic-apm-real-user-monitoring-from-my-application/238505>\
**Category:** APM\
**Tags:** rum\
**Created:** [June 24, 2020, 2:48pm UTC](https://discuss.elastic.co/t/how-to-send-a-debug-message-to-elastic-apm-real-user-monitoring-from-my-application/238505 "2020-06-24T14:48:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pablodarde](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pablodarde/32/71028_2.png) [@pablodarde](https://discuss.elastic.co/u/pablodarde)\
**Post date:** [June 24, 2020, 2:48pm UTC](https://discuss.elastic.co/t/how-to-send-a-debug-message-to-elastic-apm-real-user-monitoring-from-my-application/238505/1 "2020-06-24T14:48:41Z")

</div>

I have a JavaScript application and configured Elastic APM/RUM on that. As soon as I start to interact with the application some metrics start sending to APM Server (page\_load for example). I want to know if it's possible to send a specific text message to APM Server after a browser event.

In my code, I'm intercepting the payload in `amp.addFilter` and editing the payload. However, I think the best way would be using the `amp.addTransaction`, but I'm not sure.

```auto
    elasticApm.addFilter(function (payload) {
      payload.myDebugMessage = debugMessage

      if (payload.errors) {
        payload.errors.forEach(function (error) {
           error.exception.message = error.exception.message.replace('secret', '[REDACTED]')
        })
      }
      
      if (payload.transactions) {
       payload.transactions.forEach(function (tr) {
         tr.spans.forEach(function (span) {
           if (span.context && span.context.http && span.context.http.url) {
             var url = new URL(span.context.http.url)
             if (url.searchParams.get('token')) {
               url.searchParams.set('token', 'REDACTED')
             }
             
             span.context.http.url = url.toString()
           }
         })
       })
     }
     
     // Make sure to return the payload
     return payload
    })

```

---

<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:** [July 13, 2020, 6:14am UTC](https://discuss.elastic.co/t/how-to-send-a-debug-message-to-elastic-apm-real-user-monitoring-from-my-application/238505/2 "2020-07-13T06:14:09Z")

</div>

Hi @pablodarde. Welcome to the community!

You can use [`startTransaction`](https://www.elastic.co/guide/en/apm/agent/rum-js/current/agent-api.html#apm-start-transaction) API to start a new transaction manually. Don't forget to call [`transaction.end()`](https://www.elastic.co/guide/en/apm/agent/rum-js/current/transaction-api.html#transaction-end).

---

<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:** [August 3, 2020, 2:14am UTC](https://discuss.elastic.co/t/how-to-send-a-debug-message-to-elastic-apm-real-user-monitoring-from-my-application/238505/3 "2020-08-03T02:14:12Z")

</div>

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