track client & server payload sizes
This commit is contained in:
parent
f67d618413
commit
09c36a87b3
|
@ -4,6 +4,9 @@ syntax = "proto3";
|
||||||
|
|
||||||
package httppb;
|
package httppb;
|
||||||
|
|
||||||
|
// todo: try this
|
||||||
|
// import "google/rpc/status.proto";
|
||||||
|
// google.rpc.Status error = 13;
|
||||||
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
||||||
|
|
||||||
message HttpRequest { // HttpRequest represents the essential fields of an incoming HTTP request.
|
message HttpRequest { // HttpRequest represents the essential fields of an incoming HTTP request.
|
||||||
|
@ -15,10 +18,12 @@ message HttpRequest { // HttpRequest repres
|
||||||
string IP = 6; // The remote IP address of the client, after resolving proxies.
|
string IP = 6; // The remote IP address of the client, after resolving proxies.
|
||||||
string host = 7; // The host on which the URL is sought (www.wit.com)
|
string host = 7; // The host on which the URL is sought (www.wit.com)
|
||||||
string hostname = 8; // The hostname of the client if passed from the client (mylaptop.fun.me)
|
string hostname = 8; // The hostname of the client if passed from the client (mylaptop.fun.me)
|
||||||
bytes body = 9; // The request body as raw bytes.
|
string namespace = 9; // This is the pb namespace ("go.wit.com/lib/protobuf/virtpb")
|
||||||
string namespace = 10; // When the body is a pb (always!). This is the pb namespace ("go.wit.com/lib/protobuf/virtpb")
|
google.protobuf.Timestamp ctime = 10; // create time of the patch
|
||||||
google.protobuf.Timestamp ctime = 11; // create time of the patch
|
bytes clientData = 11; // the client payload
|
||||||
repeated string errors = 12; // When the body is a pb (always!). This is the pb namespace ("go.wit.com/lib/protobuf/virtpb")
|
int64 clientDataLen = 12; // len(body)
|
||||||
|
bytes serverData = 13; // the server response
|
||||||
|
int64 serverDataLen = 14; // len(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
message HttpRequests { // `autogenpb:marshal` `autogenpb:mutex`
|
message HttpRequests { // `autogenpb:marshal` `autogenpb:mutex`
|
||||||
|
|
5
post.go
5
post.go
|
@ -54,7 +54,10 @@ func DoPost(baseURL string, route string, data []byte) (*HttpRequest, error) {
|
||||||
|
|
||||||
reqPB, err := ReqToPB(req)
|
reqPB, err := ReqToPB(req)
|
||||||
reqPB.URL = finalURL.String()
|
reqPB.URL = finalURL.String()
|
||||||
reqPB.Body = body
|
reqPB.ClientData = data
|
||||||
|
reqPB.ClientDataLen = int64(len(data))
|
||||||
|
reqPB.ServerData = body
|
||||||
|
reqPB.ServerDataLen = int64(len(body))
|
||||||
|
|
||||||
return reqPB, nil
|
return reqPB, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,8 @@ func ReqToPB(r *http.Request) (*HttpRequest, error) {
|
||||||
Headers: headers,
|
Headers: headers,
|
||||||
IP: getClientIP(r),
|
IP: getClientIP(r),
|
||||||
Host: r.Host,
|
Host: r.Host,
|
||||||
Body: msg,
|
ClientData: msg,
|
||||||
|
ClientDataLen: int64(len(msg)),
|
||||||
Hostname: r.Header.Get("hostname"),
|
Hostname: r.Header.Get("hostname"),
|
||||||
}
|
}
|
||||||
pb.Route = cleanURL(r.URL.Path)
|
pb.Route = cleanURL(r.URL.Path)
|
||||||
|
|
Loading…
Reference in New Issue