bug 807435 - telemetry for ocsp success/failure and elapsed time r=bsmith r=honzab

This commit is contained in:
Patrick McManus 2012-11-22 11:43:27 -05:00
parent 37f5399c50
commit 64542079df
2 changed files with 60 additions and 1 deletions

View File

@ -7,6 +7,7 @@
#include "nsNSSCallbacks.h"
#include "mozilla/Telemetry.h"
#include "mozilla/TimeStamp.h"
#include "nsNSSIOLayer.h"
#include "nsIWebProgressListener.h"
@ -47,6 +48,7 @@ public:
nsCOMPtr<nsHTTPListener> mListener;
bool mResponsibleForDoneSignal;
TimeStamp mStartTime;
};
nsHTTPDownloadEvent::nsHTTPDownloadEvent()
@ -128,8 +130,10 @@ nsHTTPDownloadEvent::Run()
rv = NS_NewStreamLoader(getter_AddRefs(mListener->mLoader),
mListener);
if (NS_SUCCEEDED(rv))
if (NS_SUCCEEDED(rv)) {
mStartTime = TimeStamp::Now();
rv = hchan->AsyncOpen(mListener->mLoader, nullptr);
}
if (NS_FAILED(rv)) {
mListener->mResponsibleForDoneSignal = false;
@ -367,6 +371,13 @@ nsNSSHttpRequestSession::internal_send_receive_attempt(bool &retryable_error,
bool running_on_main_thread = NS_IsMainThread();
if (running_on_main_thread)
{
// The result of running this on the main thread
// is a series of small timeouts mixed with spinning the
// event loop - this is always dangerous as there is so much main
// thread code that does not expect to be called re-entrantly. Your
// app really shouldn't do that.
NS_WARNING("Security network blocking I/O on Main Thread");
// let's process events quickly
wait_interval = PR_MicrosecondsToInterval(50);
}
@ -418,6 +429,31 @@ nsNSSHttpRequestSession::internal_send_receive_attempt(bool &retryable_error,
}
}
if (!event->mStartTime.IsNull()) {
if (request_canceled) {
Telemetry::Accumulate(Telemetry::CERT_VALIDATION_HTTP_REQUEST_RESULT, 0);
Telemetry::AccumulateTimeDelta(
Telemetry::CERT_VALIDATION_HTTP_REQUEST_CANCELED_TIME,
event->mStartTime, TimeStamp::Now());
}
else if (NS_SUCCEEDED(mListener->mResultCode) &&
mListener->mHttpResponseCode == 200) {
Telemetry::Accumulate(Telemetry::CERT_VALIDATION_HTTP_REQUEST_RESULT, 1);
Telemetry::AccumulateTimeDelta(
Telemetry::CERT_VALIDATION_HTTP_REQUEST_SUCCEEDED_TIME,
event->mStartTime, TimeStamp::Now());
}
else {
Telemetry::Accumulate(Telemetry::CERT_VALIDATION_HTTP_REQUEST_RESULT, 2);
Telemetry::AccumulateTimeDelta(
Telemetry::CERT_VALIDATION_HTTP_REQUEST_FAILED_TIME,
event->mStartTime, TimeStamp::Now());
}
}
else {
Telemetry::Accumulate(Telemetry::CERT_VALIDATION_HTTP_REQUEST_RESULT, 3);
}
if (request_canceled)
return SECFailure;

View File

@ -716,6 +716,29 @@
"n_values": 16,
"description": "NPN Results (0=none, 1=negotiated, 2=no-overlap)"
},
"CERT_VALIDATION_HTTP_REQUEST_RESULT": {
"kind": "enumerated",
"n_values": 16,
"description": "HTTP result of OCSP, etc.. (0=canceled, 1=OK, 2=FAILED, 3=internal-error)"
},
"CERT_VALIDATION_HTTP_REQUEST_CANCELED_TIME": {
"kind": "exponential",
"high": "60000",
"n_buckets": 200,
"description": "ms elapsed time of OCSP etc.. that was canceled"
},
"CERT_VALIDATION_HTTP_REQUEST_SUCCEEDED_TIME": {
"kind": "exponential",
"high": "60000",
"n_buckets": 200,
"description": "ms elapsed time of OCSP etc.. that succeeded"
},
"CERT_VALIDATION_HTTP_REQUEST_FAILED_TIME": {
"kind": "exponential",
"high": "60000",
"n_buckets": 200,
"description": "ms elapsed time of OCSP etc.. that failed"
},
"WEBSOCKETS_HANDSHAKE_TYPE": {
"kind": "enumerated",
"n_values": 16,