Commit d7e438c8 authored by Deepanjan Roy's avatar Deepanjan Roy Committed by Commit Bot

inspector: Add extra trace arguments to console events

We have a lab metric to track console error messages in telemetry
stories, and when the count changes it is quite difficult to figure
out what the new message is. This CL adds the error message and the url
to the trace event. We will surface this information in the UI for
easier debugging.

Bug: 1086962
Change-Id: Ibeb739c7624941f7437f39e5087fbe574a782cf9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2302837
Commit-Queue: Deep Roy <dproy@chromium.org>
Reviewed-by: default avatarPeter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789993}
parent d8df04e9
......@@ -6,6 +6,7 @@
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/traced_value.h"
namespace blink {
......@@ -48,14 +49,24 @@ const char* MessageSourceToString(mojom::ConsoleMessageSource source) {
return nullptr;
}
std::unique_ptr<TracedValue> MessageTracedValue(ConsoleMessage* message) {
auto value = std::make_unique<TracedValue>();
value->SetString("content", message->Message());
if (!message->Location()->Url().IsEmpty()) {
value->SetString("url", message->Location()->Url());
}
return value;
}
void TraceConsoleMessageEvent(ConsoleMessage* message) {
// Change in this function requires adjustment of Catapult/Telemetry metric
// tracing/tracing/metrics/console_error_metric.html.
// See https://crbug.com/880432
if (message->Level() == mojom::ConsoleMessageLevel::kError) {
TRACE_EVENT_INSTANT1("blink.console", "ConsoleMessage::Error",
TRACE_EVENT_INSTANT2("blink.console", "ConsoleMessage::Error",
TRACE_EVENT_SCOPE_THREAD, "source",
MessageSourceToString(message->Source()));
MessageSourceToString(message->Source()), "message",
MessageTracedValue(message));
}
}
} // anonymous namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment