简体   繁体   中英

Is it possible to collect response data (body) from an API requests in azure?

I am hosting models on azure and I would like to collect responses (body) from our API calls. So far I am able to collect the API requests data, but I would also like to collect the response which is sent to the 'client'. How can I do this in Azure?

We tried several things (monitoring --> logs but they do only collect the requests and response signal ( 200 , 400 or 500 ), but somehow nothing is logging our response body.

Do I have to configure this somehow coding?

eg request: location_from = 'ab', location_to = 'ba', material = 'sand' response: predictive_duration = 10,5 hours

There are multiple ways to achieve that. You can:

1-Use an AOP framework and log before (received parameters) and after (response) from your APIs.

1.1-You can achieve the same thing using the Decorator design pattern

2-You can implement ITelemetryInitializer + Application Insights to log response code / response body from your apis:

https://docs.microsoft.com/en-us/azure/azure-monitor/app/api-filtering-sampling#add-properties-itelemetryinitializer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM