Capture method arguments and return value

Hi All,

Am totally new to elastic apm as well as elastic search and am trying to evaluate elastic apm and hence subscribed to trail version of elastic cloud. I want to understand whether i can capture any method arguments or return value and if possible then how to do the same.

Regards,
Gopikrishnan

Hi @gopikrishnan, welcome to the forum!

I want to understand whether i can capture any method arguments or return value and if possible then how to do the same

Not automatically. That's going to be pretty expensive to do generally, and would likely end up impacting your application's performance.

You could do this for select transactions by adding some code to record custom context on transactions. For example, see the Java agent's API docs here: Public API | APM Java Agent Reference [1.x] | Elastic

Thanks @axw for the reply.

its mentioned in that link that you cannot build dashboards on top of the data nor its searchable in elastic. So if I want to capture the amount from Fundtransfer transaction and I can only get it through a method argument and even I managed to capture through transaction.addCustomContext but then I cannot plot in dashboard ? Is there any other way I can show this in dashboard.

So if I want to capture the amount from Fundtransfer transaction and I can only get it through a method argument and even I managed to capture through transaction.addCustomContext but then I cannot plot in dashboard ?

That's correct.

Is there any other way I can show this in dashboard.

Yes, you can instead use Transaction.addLabel. You can supply numeric values, and the label fields will be indexed; therefore they can be searched and aggregated, and so are suitable for creating a dashboard.

Thats very insightful.

So using Transaction.addLabel I can capture the amount of Fundtransfer transaction and plot it in dashboard correct ? and likewise I can capture for other transactions as well numeric and string values right?

That's correct. If, for example, you called transaction.addLabel("fundtransfer", 123.45), then the transaction document in Elasticsearch would have a field labels.fundtransfer, with value 123.45. You can then create a dashboard based on that field.

Labels can be numeric, boolean, or string values. You just need to make sure you're consistent with the type for a given label key.

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