Commit 206d37b9 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

Emit trace event on console error messages from JS.

This is needed to implement a new metric that measures
health of Web Page Replay archives.

Bug: chromium:880432

Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I59aed22e4671e491fc3a30d04fbdce1643404b32
Reviewed-on: https://chromium-review.googlesource.com/1204570
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarPavel Feldman <pfeldman@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55716}
parent d2924020
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "src/inspector/v8-inspector-session-impl.h" #include "src/inspector/v8-inspector-session-impl.h"
#include "src/inspector/v8-runtime-agent-impl.h" #include "src/inspector/v8-runtime-agent-impl.h"
#include "src/inspector/v8-stack-trace-impl.h" #include "src/inspector/v8-stack-trace-impl.h"
#include "src/tracing/trace-event.h"
#include "include/v8-inspector.h" #include "include/v8-inspector.h"
...@@ -477,12 +478,34 @@ V8ConsoleMessageStorage::V8ConsoleMessageStorage(V8InspectorImpl* inspector, ...@@ -477,12 +478,34 @@ V8ConsoleMessageStorage::V8ConsoleMessageStorage(V8InspectorImpl* inspector,
V8ConsoleMessageStorage::~V8ConsoleMessageStorage() { clear(); } V8ConsoleMessageStorage::~V8ConsoleMessageStorage() { clear(); }
namespace {
void TraceV8ConsoleMessageEvent(V8MessageOrigin origin, ConsoleAPIType type) {
// Change in this function requires adjustment of Catapult/Telemetry metric
// tracing/tracing/metrics/console_error_metric.html.
// See https://crbug.com/880432
if (origin == V8MessageOrigin::kException) {
TRACE_EVENT_INSTANT0("v8.console", "V8ConsoleMessage::Exception",
TRACE_EVENT_SCOPE_THREAD);
} else if (type == ConsoleAPIType::kError) {
TRACE_EVENT_INSTANT0("v8.console", "V8ConsoleMessage::Error",
TRACE_EVENT_SCOPE_THREAD);
} else if (type == ConsoleAPIType::kAssert) {
TRACE_EVENT_INSTANT0("v8.console", "V8ConsoleMessage::Assert",
TRACE_EVENT_SCOPE_THREAD);
}
}
} // anonymous namespace
void V8ConsoleMessageStorage::addMessage( void V8ConsoleMessageStorage::addMessage(
std::unique_ptr<V8ConsoleMessage> message) { std::unique_ptr<V8ConsoleMessage> message) {
int contextGroupId = m_contextGroupId; int contextGroupId = m_contextGroupId;
V8InspectorImpl* inspector = m_inspector; V8InspectorImpl* inspector = m_inspector;
if (message->type() == ConsoleAPIType::kClear) clear(); if (message->type() == ConsoleAPIType::kClear) clear();
TraceV8ConsoleMessageEvent(message->origin(), message->type());
inspector->forEachSession( inspector->forEachSession(
contextGroupId, [&message](V8InspectorSessionImpl* session) { contextGroupId, [&message](V8InspectorSessionImpl* session) {
if (message->origin() == V8MessageOrigin::kConsole) if (message->origin() == V8MessageOrigin::kConsole)
......
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