You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2019/12/04 16:05:10 UTC

[GitHub] [openwhisk] neerajmangal commented on issue #4726: Recording metrics for action result response statusCode in user-events service.

neerajmangal commented on issue #4726: Recording metrics for action result response statusCode in user-events service. 
URL: https://github.com/apache/openwhisk/pull/4726#issuecomment-561712098
 
 
   Thanks @rabbah, @chetanmeh and @selfxp for the feedback. Based on your feedback, I modified below - 
   
   - More defensive checks when parsing the result response. 
     - if the result response contains an `error` field, check if it has `statusCode` defined by the user, as other fields are discarded if the `error` field is present in result response. 
        ```json
        "result": {
               "error": {
                   "body": "Authentication credentials are invalid.",
                   "statusCode": 401
               }
           }
        ````
     - else check if `statusCode` is set by the user without the `error` field in the result response.
        ```json
        "result": {
                   "body": "Authentication credentials are invalid.",
                   "statusCode": 401
           }
        ````
     - `statusCode` value is being checked for valid integer (401) and string value ("401").
     -  If there is any issue in getting the `intValue` (i.e. `statusCode` like "i401" or any string "xyz") return set `userDefinedStatusCode as `400` bad request. 
     - Using `value.convertTo[BigInt].intValue()` takes care of `JSNumber` and `JSString` type. I tried alternate approach like handling the status code for webaction https://github.com/apache/openwhisk/blob/master/core/controller/src/main/scala/org/apache/openwhisk/core/controller/WebActions.scala#L234, but for normal action use case it will miss a case where return `statusCode` is a valid integer (like "1") but not a http statusCode.
   -  Changed `actionStatusCode` to `userDefinedStatusCode` as `statusCode` is not limited to http status codes. Please let me know if you have any better suggestions. 
   -  Other tests and doc changes per feedback. 
   
   Please let me know your feedback. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services