# Make ElasticAPM.report return an error or error id instead of true

**URL:** <https://discuss.elastic.co/t/make-elasticapm-report-return-an-error-or-error-id-instead-of-true/196504>\
**Category:** APM\
**Tags:** ruby\
**Created:** [August 23, 2019, 11:03am UTC](https://discuss.elastic.co/t/make-elasticapm-report-return-an-error-or-error-id-instead-of-true/196504 "2019-08-23T11:03:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![greyblake](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/greyblake/32/52890_2.png) [@greyblake](https://discuss.elastic.co/u/greyblake)\
**Post date:** [August 23, 2019, 11:03am UTC](https://discuss.elastic.co/t/make-elasticapm-report-return-an-error-or-error-id-instead-of-true/196504/1 "2019-08-23T11:03:00Z")

</div>

**APM Agent language and version** : Ruby, 2.9.1

### Current status

Hi, currently `ElasticAPM.report` and `ElasticAPM.report_message` return either `nil` or `true`

```auto
ElasticAPM.report(exception)
=> true

```

### Proposal

I would like to propose a change to make it return an instance of`ElasticAPM::Error` instead. Or at least `error.id`.

### Motivation

The reason for this, we'd like to be able to communicate an error id back to a client as part of server error payload. This would allow us to easily identify errors in ELK by id.

### Required code change

The code change to achieve this is very small.  
We just need to modify `ElasticAPM.report` and `ElasticAPM.report_message` methods

> <https://github.com/elastic/apm-agent-ruby/blob/master/lib/elastic_apm/agent.rb#L198>

so they return `error`, instead of `enqueue error`.

What do you think?  
If you give me a green light I can prepare a pull request for this.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [August 23, 2019, 11:23am UTC](https://discuss.elastic.co/t/make-elasticapm-report-return-an-error-or-error-id-instead-of-true/196504/2 "2019-08-23T11:23:06Z")

</div>

I'm not in charge of the Ruby agent but I think it's a great idea which would also work well in the Java agent.

---

<div class="post-metadata">

**Author:** ![mikker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikker/32/22118_2.png) [@mikker](https://discuss.elastic.co/u/mikker)\
**Post date:** [August 26, 2019, 8:15am UTC](https://discuss.elastic.co/t/make-elasticapm-report-return-an-error-or-error-id-instead-of-true/196504/3 "2019-08-26T08:15:32Z")

</div>

Hi Sergey!

I'm not opposed to that. I've opened this PR with the change: [https://github.com/elastic/apm-agent-ruby/pull/507](https://github.com/elastic/apm-agent-ruby/pull/507)

Thanks – and thanks Felix for chiming in.

---

<div class="post-metadata">

**Author:** ![greyblake](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/greyblake/32/52890_2.png) [@greyblake](https://discuss.elastic.co/u/greyblake)\
**Post date:** [August 26, 2019, 9:45am UTC](https://discuss.elastic.co/t/make-elasticapm-report-return-an-error-or-error-id-instead-of-true/196504/4 "2019-08-26T09:45:17Z")

</div>

Thank you! You're awesome!

---

<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:** [September 16, 2019, 5:45am UTC](https://discuss.elastic.co/t/make-elasticapm-report-return-an-error-or-error-id-instead-of-true/196504/5 "2019-09-16T05:45:28Z")

</div>

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