cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

This product reached the end of support date on March 31, 2021.

How to capture two values from the object return by particular method.

amruta_sardeshm
Participant

I have put sensor for one method which returns object.To capture values returned by that object , I have mention accessor for the method(as seen in attached file).I am able to mention only one accessor for one method, but I want to capture two values returned by that object for same method. Can you suggest solution for the same.method-accessor.png

3 REPLIES 3

adam_gardner
Dynatrace Champion
Dynatrace Champion

Hi Amruta, as per the documentation, only one accessor can be used per argument or return value.

However, have a look at the purepath (be sure to click "show all nodes") and see if you could perhaps capture one ID from one method call return value and the other from a different (but similar) method.

Alternatively, I've had success with capturing one thing from the argument and the other from the return (you can use two different accessors for arg & return on the same method).

amruta_sardeshm
Participant

Hi Adam, Thanks for the response.

As per your first option, I looked at the purepath to see if there is any similar method so that I can capture one value from one method and one from other method, but there is no such similar method in the tree in my case.

Also I tried your second option, But I want to capture error code and error message and already I have captured error code from the return value of method and there is no error message value in the argument of similar method, So I am not able to capture error message from argument of the similar method.

rob_vollum
Dynatrace Pro
Dynatrace Pro

If you have ownership of the code, there is a way you can "fake" it. I've used this technique many times when what I want is not represented easily in the code.

To fake it: create a new method that takes two arguments and returns one value. Call that method from your existing method, passing the two arguments. Then in the new method, the only thing it does is return one of the arguments. Now you can put a sensor on that method, grab one argument, and also grab the return value.

Not perfect, but perhaps it will work for you.

Rob