-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
9 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,8 @@ function generateRequestEvent(http:Request request, http:FilterContext context) | |
requestStream.applicationOwner = authContext.subscriber; | ||
requestStream.tier = authContext.tier; | ||
requestStream.continuedOnThrottleOut = !authContext.stopOnQuotaReach; | ||
requestStream.apiPublisher = authContext.apiPublisher; | ||
requestStream.keyType = authContext.keyType; | ||
} | ||
requestStream.userAgent = request.userAgent; | ||
requestStream.clientIp = getClientIp(request); | ||
|
@@ -67,14 +69,11 @@ function generateRequestEvent(http:Request request, http:FilterContext context) | |
|
||
//todo: hostname verify | ||
requestStream.hostName = "localhost"; //todo:get the host properl | ||
//todo:check if apiPublisher comes in keyValidation context | ||
requestStream.apiPublisher = "[email protected]"; //todo:get publisher properly | ||
requestStream.method = request.method; | ||
//todo:verify resourcepath and resourceTemplate | ||
requestStream.resourceTemplate = "resourcePath"; | ||
requestStream.resourcePath = getResourceConfigAnnotation | ||
(reflect:getResourceAnnotations(context.serviceType, context.resourceName)).path; | ||
requestStream.keyType = "PRODUCTION"; | ||
//todo:random uuid taken from throttle filter | ||
requestStream.correlationID = "71c60dbd-b2be-408d-9e2e-4fd11f60cfbc"; | ||
requestStream.requestCount = 1; | ||
|
@@ -106,18 +105,18 @@ function getEventData(EventDTO dto) returns string { | |
function writeEventToFile(EventDTO eventDTO) { | ||
//todo:batch events to reduce IO cost | ||
int currentTime = getCurrentTime(); | ||
if (initializingTime == 0 ) { | ||
if (initializingTime == 0) { | ||
initializingTime = getCurrentTime(); | ||
} | ||
if ( currentTime - initializingTime > 60*1000*10) { | ||
if (currentTime - initializingTime > 60*1000*10) { | ||
var result = rotateFile("api-usage-data.dat"); | ||
initializingTime = getCurrentTime(); | ||
match result { | ||
string name => { | ||
log:printInfo("File rotated successfully."); | ||
} | ||
error err => { | ||
log:printError("Error occurred while rotating the file: " + err.message); | ||
log:printError("Error occurred while rotating the file: ", err = err); | ||
} | ||
} | ||
} | ||
|
@@ -136,10 +135,10 @@ function writeEventToFile(EventDTO eventDTO) { | |
} finally { | ||
match charChannel.close() { | ||
error sourceCloseError => { | ||
log:printError("Error occured while closing the channel: " + sourceCloseError.message); | ||
log:printError("Error occured while closing the channel: ", err = sourceCloseError); | ||
} | ||
() => { | ||
log:printInfo("Source channel closed successfully."); | ||
log:printDebug("Source channel closed successfully."); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters