Merged PR 15341: Added timer data collection using SRP_Stopwatch to each verb method. Logging...
Added timer data collection using SRP_Stopwatch to each verb method. Logging all time metrics
This commit is contained in:
parent
59f7461a13
commit
fc40b9b654
@ -44,9 +44,20 @@ $insert SCANS_EQUATES
|
|||||||
$insert RDS_EQUATES
|
$insert RDS_EQUATES
|
||||||
$insert SCAN_SETUP
|
$insert SCAN_SETUP
|
||||||
|
|
||||||
Declare Function Scan_Services, Database_Services, QA_Services, Datetime, RDS_Services, SRP_Array
|
Declare Function Scan_Services, Database_Services, QA_Services, Datetime, RDS_Services, SRP_Array, SRP_Stopwatch
|
||||||
Declare Subroutine Scan_Services, Database_Services, QA_Services, obj_WO_Mat_Log
|
Declare function Logging_Services, Environment_Services
|
||||||
|
Declare Subroutine Scan_Services, Database_Services, QA_Services, obj_WO_Mat_Log, SRP_Stopwatch
|
||||||
|
Declare Subroutine Logging_Services
|
||||||
|
|
||||||
|
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ScanAPI\APIResponseTime'; //Define the directory where the log will be saved to. This happens the first time of the day that the log is written to.
|
||||||
|
LogDate = Oconv(Date(), 'D4/')
|
||||||
|
LogTime = Oconv(Time(), 'MTS')
|
||||||
|
LoggingDTM = LogDate : ' ' : LogTime ; // Logging DTM
|
||||||
|
|
||||||
|
LogFileName = LogDate[7, 4] : '-' : LogDate[1, 2] : '-' : LogDate[4, 2] : ' ScanAPIResponseTimes.csv'; //Define the file name that will get created.
|
||||||
|
Headers = 'Logging DTM' : @FM : 'API' : @FM : 'ResponseTime' : @FM : 'ScanID' : @FM : 'ScanData' : @VM : 'StatusCode' ; //Define the column names in the log file, delimited by a Field Mark.
|
||||||
|
objLog = Logging_Services('NewLog', LogPath, LogFileName, CRLF$, ',', Headers, '', False$, False$); //Actually creates the log.
|
||||||
|
|
||||||
GoToAPI else
|
GoToAPI else
|
||||||
// The specific resource endpoint doesn't have a API handler yet.
|
// The specific resource endpoint doesn't have a API handler yet.
|
||||||
HTTP_Services('SetResponseStatus', 200, 'This is a valid endpoint but a web API handler has not yet been created.')
|
HTTP_Services('SetResponseStatus', 200, 'This is a valid endpoint but a web API handler has not yet been created.')
|
||||||
@ -61,7 +72,8 @@ Return Response OR ''
|
|||||||
|
|
||||||
|
|
||||||
API scan.POST
|
API scan.POST
|
||||||
|
SRP_Stopwatch('Reset')
|
||||||
|
SRP_Stopwatch('Start', 'SCAN_POST_RESPONSE_TIME')
|
||||||
ScanID = Scan_Services('CreateScansRow')
|
ScanID = Scan_Services('CreateScansRow')
|
||||||
If Error_Services('NoError') then
|
If Error_Services('NoError') then
|
||||||
StatusCode = 201
|
StatusCode = 201
|
||||||
@ -70,46 +82,92 @@ API scan.POST
|
|||||||
Message = Error_Services('GetMessage')
|
Message = Error_Services('GetMessage')
|
||||||
HTTP_Services('SetResponseStatus', 500, Message)
|
HTTP_Services('SetResponseStatus', 500, Message)
|
||||||
end
|
end
|
||||||
|
SRP_Stopwatch('Stop', 'SCAN_POST_RESPONSE_TIME')
|
||||||
|
TotalPostResponseTime = SRP_Stopwatch('GetData', 'SCAN_POST_RESPONSE_TIME')
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||||
|
LogData<2> = 'SCAN.POST'
|
||||||
|
LogData<3> = TotalPostResponseTime
|
||||||
|
LogData<4> = ScanID
|
||||||
|
LogData<5> = ''
|
||||||
|
ResponseStatusCode = ''
|
||||||
|
If Assigned(StatusCode) then
|
||||||
|
ResponseStatusCode = StatusCode
|
||||||
|
end
|
||||||
|
LogData<6> = ResponseStatusCode
|
||||||
|
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
|
||||||
end api
|
end api
|
||||||
|
|
||||||
|
|
||||||
API scan.ID.POST
|
API scan.ID.POST
|
||||||
|
SRP_Stopwatch('Reset')
|
||||||
|
SRP_Stopwatch('Start', 'SCAN_ID_POST_RESPONSE_TIME')
|
||||||
ScanID = EndpointSegment
|
ScanID = EndpointSegment
|
||||||
|
|
||||||
// The resource will have been put into the POST string.
|
// The resource will have been put into the POST string.
|
||||||
Body = HTTP_Services('GetHTTPPostString')
|
Body = HTTP_Services('GetHTTPPostString')
|
||||||
If Body NE '' then
|
If Body NE '' then
|
||||||
// The POST string will have been encoded so use percent (URL) decoding.
|
// The POST string will have been encoded so use percent (URL) decoding.
|
||||||
ScanJSON = HTTP_Services('DecodePercentString', Body)
|
ScanJSON = HTTP_Services('DecodePercentString', Body)
|
||||||
Scan_Services('ProcessScanData', ScanID, ScanJSON)
|
Scan_Services('ProcessScanData', ScanID, ScanJSON)
|
||||||
If Error_Services('NoError') then
|
If Error_Services('NoError') then
|
||||||
StatusCode = 200
|
StatusCode = 200
|
||||||
GoSub CreateHALItem
|
GoSub CreateHALItem
|
||||||
end else
|
end else
|
||||||
Message = Error_Services('GetMessage')
|
Message = Error_Services('GetMessage')
|
||||||
HTTP_Services('SetResponseStatus', 400, Message)
|
HTTP_Services('SetResponseStatus', 400, Message)
|
||||||
end
|
end
|
||||||
end else
|
end else
|
||||||
HTTP_Services('SetResponseStatus', 400, 'JSON object is missing from the request.')
|
HTTP_Services('SetResponseStatus', 400, 'JSON object is missing from the request.')
|
||||||
end
|
end
|
||||||
|
SRP_Stopwatch('Stop', 'SCAN_ID_POST_RESPONSE_TIME')
|
||||||
|
TotalPostResponseTime = SRP_Stopwatch('GetData', 'SCAN_ID_POST_RESPONSE_TIME')
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||||
|
LogData<2> = 'SCAN.ID.POST'
|
||||||
|
LogData<3> = TotalPostResponseTime
|
||||||
|
LogData<4> = ScanID
|
||||||
|
If Assigned(ScanJson) then
|
||||||
|
ThisScanDataToLog = ScanJson
|
||||||
|
end else
|
||||||
|
ThisScanDataToLog = Body
|
||||||
|
end
|
||||||
|
LogData<5> = ThisScanDataToLog
|
||||||
|
ResponseStatusCode = ''
|
||||||
|
If Assigned(StatusCode) then
|
||||||
|
ResponseStatusCode = StatusCode
|
||||||
|
end
|
||||||
|
LogData<6> = ResponseStatusCode
|
||||||
|
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
|
||||||
end api
|
end api
|
||||||
|
|
||||||
|
|
||||||
API scan.ID.HEAD
|
API scan.ID.HEAD
|
||||||
API scan.ID.GET
|
API scan.ID.GET
|
||||||
|
SRP_Stopwatch('Reset')
|
||||||
|
SRP_Stopwatch('Start', 'SCAN_ID_GET_RESPONSE_TIME')
|
||||||
ScanID = EndpointSegment
|
ScanID = EndpointSegment
|
||||||
StatusCode = 200
|
StatusCode = 200
|
||||||
GoSub CreateHALItem
|
GoSub CreateHALItem
|
||||||
|
SRP_Stopwatch('Stop', 'SCAN_ID_POST_RESPONSE_TIME')
|
||||||
|
TotalGetResponseTime = SRP_Stopwatch('GetData', 'SCAN_ID_GET_RESPONSE_TIME')
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||||
|
LogData<2> = 'SCAN.ID.GET'
|
||||||
|
LogData<3> = TotalGetResponseTime
|
||||||
|
LogData<4> = ScanID
|
||||||
|
LogData<5> = ''
|
||||||
|
ResponseStatusCode = ''
|
||||||
|
If Assigned(StatusCode) then
|
||||||
|
ResponseStatusCode = StatusCode
|
||||||
|
end
|
||||||
|
LogData<6> = ResponseStatusCode
|
||||||
|
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
|
||||||
end api
|
end api
|
||||||
|
|
||||||
|
|
||||||
API scan.ID.DELETE
|
API scan.ID.DELETE
|
||||||
|
SRP_Stopwatch('Reset')
|
||||||
|
SRP_Stopwatch('Start', 'SCAN_ID_DELETE_RESPONSE_TIME')
|
||||||
ScanID = EndpointSegment
|
ScanID = EndpointSegment
|
||||||
|
|
||||||
ScanRow = Database_Services('ReadDataRow', 'SCANS', ScanID)
|
ScanRow = Database_Services('ReadDataRow', 'SCANS', ScanID)
|
||||||
@ -129,7 +187,20 @@ API scan.ID.DELETE
|
|||||||
Message = Error_Services('GetMessage')
|
Message = Error_Services('GetMessage')
|
||||||
HTTP_Services('SetResponseStatus', 404, Message)
|
HTTP_Services('SetResponseStatus', 404, Message)
|
||||||
end
|
end
|
||||||
|
SRP_Stopwatch('Stop', 'SCAN_ID_DELETE_RESPONSE_TIME')
|
||||||
|
TotalDeleteResponseTime = SRP_Stopwatch('GetData', 'SCAN_ID_DELETE_RESPONSE_TIME')
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||||
|
LogData<2> = 'SCAN.ID.DELETE'
|
||||||
|
LogData<3> = TotalDeleteResponseTime
|
||||||
|
LogData<4> = ScanID
|
||||||
|
LogData<5> = ''
|
||||||
|
ResponseStatusCode = ''
|
||||||
|
If Assigned(StatusCode) then
|
||||||
|
ResponseStatusCode = StatusCode
|
||||||
|
end
|
||||||
|
LogData<6> = ResponseStatusCode
|
||||||
|
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
|
||||||
end api
|
end api
|
||||||
|
|
||||||
|
|
||||||
@ -138,9 +209,11 @@ API scan.ID.PATCH
|
|||||||
// This is where scans are ultimately accepted for final processing. We will need to determine which type
|
// This is where scans are ultimately accepted for final processing. We will need to determine which type
|
||||||
// of scan this is (i.e. Location, Pre-Epi + Load, or Unload). This will be determined by the data coming in and the
|
// of scan this is (i.e. Location, Pre-Epi + Load, or Unload). This will be determined by the data coming in and the
|
||||||
// current status of the lot. For example a Location scan would only have an RDS, location code, and username.
|
// current status of the lot. For example a Location scan would only have an RDS, location code, and username.
|
||||||
|
SRP_Stopwatch('Reset')
|
||||||
|
SRP_Stopwatch('Start', 'SCAN_ID_PATCH_RESPONSE_TIME')
|
||||||
|
|
||||||
ScanID = EndpointSegment
|
ScanID = EndpointSegment
|
||||||
|
SRP_Stopwatch('Start', 'IDPatchResponseTime')
|
||||||
// First confirm that this is a valid Scan ID.
|
// First confirm that this is a valid Scan ID.
|
||||||
jsonScan = Scan_Services('GetScansRow', ScanID, True$)
|
jsonScan = Scan_Services('GetScansRow', ScanID, True$)
|
||||||
If Error_Services('NoError') then
|
If Error_Services('NoError') then
|
||||||
@ -181,12 +254,27 @@ API scan.ID.PATCH
|
|||||||
Message = Error_Services('GetMessage')
|
Message = Error_Services('GetMessage')
|
||||||
HTTP_Services('SetResponseStatus', 404, Message)
|
HTTP_Services('SetResponseStatus', 404, Message)
|
||||||
end
|
end
|
||||||
|
SRP_Stopwatch('Stop', 'SCAN_ID_PATCH_RESPONSE_TIME')
|
||||||
|
TotalPatchResponseTime = SRP_Stopwatch('GetData', 'SCAN_ID_PATCH_RESPONSE_TIME')
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||||
|
LogData<2> = 'SCAN.ID.PATCH'
|
||||||
|
LogData<3> = TotalPatchResponseTime
|
||||||
|
LogData<4> = ScanID
|
||||||
|
LogData<5> = ''
|
||||||
|
ResponseStatusCode = ''
|
||||||
|
If Assigned(StatusCode) then
|
||||||
|
ResponseStatusCode = StatusCode
|
||||||
|
end
|
||||||
|
LogData<6> = ResponseStatusCode
|
||||||
|
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
|
||||||
end api
|
end api
|
||||||
|
|
||||||
|
|
||||||
API scan.ID.PUT
|
API scan.ID.PUT
|
||||||
|
|
||||||
|
SRP_Stopwatch('Reset')
|
||||||
|
SRP_Stopwatch('Start', 'SCAN_ID_PUT_RESPONSE_TIME')
|
||||||
ScanID = EndpointSegment
|
ScanID = EndpointSegment
|
||||||
|
|
||||||
// The resource will have been put into the POST string.
|
// The resource will have been put into the POST string.
|
||||||
@ -237,6 +325,20 @@ API scan.ID.PUT
|
|||||||
end else
|
end else
|
||||||
HTTP_Services('SetResponseStatus', 400, 'JSON object is missing from the request.')
|
HTTP_Services('SetResponseStatus', 400, 'JSON object is missing from the request.')
|
||||||
end
|
end
|
||||||
|
SRP_Stopwatch('Stop', 'SCAN_ID_PUT_RESPONSE_TIME')
|
||||||
|
TotalPutResponseTime = SRP_Stopwatch('GetData', 'SCAN_ID_PUT_RESPONSE_TIME')
|
||||||
|
LogData = ''
|
||||||
|
LogData<1> = LoggingDTM;//Defined at entry of subroutine
|
||||||
|
LogData<2> = 'SCAN.ID.PUT'
|
||||||
|
LogData<3> = TotalPutResponseTime
|
||||||
|
LogData<4> = ScanID
|
||||||
|
LogData<5> = ''
|
||||||
|
ResponseStatusCode = ''
|
||||||
|
If Assigned(StatusCode) then
|
||||||
|
ResponseStatusCode = StatusCode
|
||||||
|
end
|
||||||
|
LogData<6> = ResponseStatusCode
|
||||||
|
Logging_Services('AppendLog', objLog, LogData, @RM, @FM, False$)
|
||||||
|
|
||||||
end api
|
end api
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user