I am using HttpClient in my Xamarin app. Using Crittercism for Instrumentation. I tried using LogNetworkRequest in Crittercism but I am not sure how to use it.
Crittercism.LogNetworkRequest(
"GET",
"http://www.abc123def456.com",
2000, // latency in milliseconds
10000, // bytesRead
100, // bytesSent
HttpStatusCode.OK,
WebExceptionStatus.Success);
How should I set parameters like Latency, BytesRead,BytesSent?
This is my code which makes call to REST
protected override async Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request,
CancellationToken cancellationToken)
{
var httpResponseMessage = await base.SendAsync(request,cancellationToken);
}
The question is how to hook up call to LogNetworkRequest in my implementation.
I used a StopWatch to record latency. For recording BytesSent and Received used following code:
var requestBytes = await request.Content.ReadAsByteArrayAsync ();
networkRequestInfo.BytesSent = requestBytes.Length;