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

Capture JSON return value


We have a method in our MVC application and trying to capture a JSON return value of that method . We placed sensor on that method ,but we are unable to capture it . Is it possible to capture a JSON value in a method


Dynatrace Champion
Dynatrace Champion

hi Sruthi,

you can capture both primitive values and complex objects, but when you capture objects, the Agent will automatically call toString()/ToString() on it.

so if you capture an object that has a meaningful toString()/ToString() implementation (e.g. returning the JSON as string) then it will be possible to capture this. however, you will only get it to the maximum string capture length (which is 250 per default and can be increased to 32768).

also you should keep in mind that capturing huge strings can have quite a performance impact, both in traffic and cpu/response time.

HTH, Christian

Hi Shruti, Placing just sensor is not enough. You have to configure the placed sensor rule to capture its return value. By Default the return value is not captured. See in snapshot. You can also use the Accessor if its not simple type or .toString()-able.


Hi Rajesh ,

We have checked the return value

checkbox in sensor settings . Eventhough it is checked , we are getting the data type value in purepath details , not the intented value

For example our intended return value will be





are you sure that this method should return a JSON value?

because based on the captured object it looks like it's some sort of Task that should contain a JsonResult ... probably not at that point in time, but sometime in the future.

are you using async programming here, maybe with async/await or some specific async methods?




Hi Christian ,

Yes , the method that we’re trying to setup the sensor is
an asynchronous method. The output after the asynchronous execution would be a
JSON result.


Shruti, can you share the method signature with us?


actually I don't think it will work this way.

because usually when you work with aync methods it works like this:

  • you get a Task/Future/... object as response that holds the result of the async operation
  • you use this object to periodically poll until finally a result is available

however, what this also means is that at the time when the async method is exited, the result itself is not yet available. otherwise the async operation would not make much sense, right?

however, AppMon captures the return value at the exit of the method, so if the result is not yet available, it would not be possible at all to get it.

I mean, you can try to query the result, which should work with an accessor "get_Result()", assuming that you are using such a Task: however, I'd assume that you won't get the result at that point in time.

I would try to find a later point in time to get to this JSON value. are there maybe any other methods that are then using the actual JSON value?

you could also try instrumenting Task`1.get_Result(), which should be called to get the actual value, if my understanding is correct. however, this could result in *a lot* of instrumented method calls, which might induce significant traffic and performance overhead. so I would *not* recommend that in a production environment.

HTH, Christian


I am finding the same issue. The return value is datatype when accessor is left empty and the return is null with almost any accessor I tried.
Tried to capture this data from multiple methods with same luck.