-
Notifications
You must be signed in to change notification settings - Fork 17
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
1 parent
0f99aca
commit 60c54a2
Showing
7 changed files
with
69 additions
and
12 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
42 changes: 42 additions & 0 deletions
42
core/src/main/java/com/flipkart/gjex/core/filter/GrpcAccessLogFilter.java
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.flipkart.gjex.core.filter; | ||
|
||
import com.flipkart.gjex.core.logging.Logging; | ||
import com.google.protobuf.GeneratedMessageV3; | ||
import io.grpc.Metadata; | ||
|
||
public class GrpcAccessLogFilter <R extends GeneratedMessageV3, | ||
S extends GeneratedMessageV3> implements Filter<R, S>, Logging { | ||
private long startTime = 0; | ||
private ServerRequestParams serverRequestParams; | ||
@Override | ||
public Filter<R,S> getInstance(){ | ||
return new GrpcAccessLogFilter<>(); | ||
} | ||
|
||
@Override | ||
public void doProcessRequest(R request) { | ||
this.startTime = System.currentTimeMillis(); | ||
} | ||
|
||
@Override | ||
public void doFilterRequest(ServerRequestParams serverRequestParams, Metadata headers) { | ||
this.serverRequestParams = serverRequestParams; | ||
} | ||
|
||
@Override | ||
public void doProcessResponseHeaders(Metadata responseHeaders) {} | ||
|
||
@Override | ||
public void doProcessResponse(S response) { | ||
String size = null; | ||
if (response != null){ | ||
size = String.valueOf(response.getSerializedSize()); | ||
} | ||
StringBuilder sb = new StringBuilder() | ||
.append(serverRequestParams.getClientIp()).append(" ") | ||
.append(serverRequestParams.getMethodName()).append(" ") | ||
.append(size).append(" ") | ||
.append(System.currentTimeMillis()-startTime); | ||
error(sb.toString()); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
Grpc: | ||
server.port: 50051 | ||
server.executorThreads : 4 | ||
enableAccessLogs: true | ||
|
||
Dashboard: | ||
service.port: 9999 | ||
|
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
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