Skip to content

Commit ddff3d6

Browse files
committed
core(tracehouse): merge tracing-processor with trace-of-tab
1 parent 7ba6776 commit ddff3d6

17 files changed

+781
-729
lines changed

docs/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ driver.sendCommand('Security.enable');
3939

4040
## Understanding a Trace
4141

42-
`lighthouse-core/lib/tracehouse/trace-of-tab.js` and `lighthouse-core/lib/tracehouse/tracing-processor.js` provide the core transformation of a trace into more meaningful objects. Each raw trace event has a monotonically increasing timestamp in microseconds, a thread ID, a process ID, a duration in microseconds (potentially), and other applicable metadata properties such as the event type, the task name, the frame, etc. [Learn more about trace events](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview).
42+
`lighthouse-core/lib/tracehouse/trace-processor.js` provides the core transformation of a trace into more meaningful objects. Each raw trace event has a monotonically increasing timestamp in microseconds, a thread ID, a process ID, a duration in microseconds (potentially), and other applicable metadata properties such as the event type, the task name, the frame, etc. [Learn more about trace events](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview).
4343

4444
### Example Trace Event
4545
```js

lighthouse-core/computed/metrics/cumulative-long-queuing-delay.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
const makeComputedArtifact = require('../computed-artifact.js');
99
const ComputedMetric = require('./metric.js');
1010
const LHError = require('../../lib/lh-error.js');
11-
const TracingProcessor = require('../../lib/tracehouse/tracing-processor.js');
11+
const TracingProcessor = require('../../lib/tracehouse/trace-processor.js');
1212
const LanternCumulativeLongQueuingDelay = require('./lantern-cumulative-long-queuing-delay.js');
1313
const TimetoInteractive = require('./interactive.js');
1414

lighthouse-core/computed/metrics/estimated-input-latency.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
const makeComputedArtifact = require('../computed-artifact.js');
99
const ComputedMetric = require('./metric.js');
1010
const LHError = require('../../lib/lh-error.js');
11-
const TracingProcessor = require('../../lib/tracehouse/tracing-processor.js');
11+
const TracingProcessor = require('../../lib/tracehouse/trace-processor.js');
1212
const LanternEstimatedInputLatency = require('./lantern-estimated-input-latency.js');
1313

1414
const ROLLING_WINDOW_SIZE = 5000;

lighthouse-core/computed/metrics/first-cpu-idle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
const makeComputedArtifact = require('../computed-artifact.js');
99
const ComputedMetric = require('./metric.js');
10-
const TracingProcessor = require('../../lib/tracehouse/tracing-processor.js');
10+
const TracingProcessor = require('../../lib/tracehouse/trace-processor.js');
1111
const LHError = require('../../lib/lh-error.js');
1212
const LanternFirstCPUIdle = require('./lantern-first-cpu-idle.js');
1313

lighthouse-core/computed/metrics/interactive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const ComputedMetric = require('./metric.js');
1010
const LanternInteractive = require('./lantern-interactive.js');
1111

1212
const NetworkRecorder = require('../../lib/network-recorder.js');
13-
const TracingProcessor = require('../../lib/tracehouse/tracing-processor.js');
13+
const TracingProcessor = require('../../lib/tracehouse/trace-processor.js');
1414
const LHError = require('../../lib/lh-error.js');
1515

1616
const REQUIRED_QUIET_WINDOW = 5000;

lighthouse-core/computed/metrics/max-potential-fid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const makeComputedArtifact = require('../computed-artifact.js');
99
const MetricArtifact = require('./metric.js');
1010
const LanternMaxPotentialFID = require('./lantern-max-potential-fid.js');
1111
const LHError = require('../../lib/lh-error.js');
12-
const TracingProcessor = require('../../lib/tracehouse/tracing-processor.js');
12+
const TracingProcessor = require('../../lib/tracehouse/trace-processor.js');
1313

1414
class MaxPotentialFID extends MetricArtifact {
1515
/**

lighthouse-core/computed/metrics/metric.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
'use strict';
77

8-
const TracingProcessor = require('../../lib/tracehouse/tracing-processor.js');
8+
const TracingProcessor = require('../../lib/tracehouse/trace-processor.js');
99
const TraceOfTab = require('../trace-of-tab.js');
1010
const NetworkRecords = require('../network-records.js');
1111

lighthouse-core/computed/page-dependency-graph.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const makeComputedArtifact = require('./computed-artifact.js');
99
const NetworkNode = require('../lib/dependency-graph/network-node.js');
1010
const CPUNode = require('../lib/dependency-graph/cpu-node.js');
1111
const NetworkAnalyzer = require('../lib/dependency-graph/simulator/network-analyzer.js');
12-
const TracingProcessor = require('../lib/tracehouse/tracing-processor.js');
12+
const TracingProcessor = require('../lib/tracehouse/trace-processor.js');
1313
const NetworkRequest = require('../lib/network-request.js');
1414
const TraceOfTab = require('./trace-of-tab.js');
1515
const NetworkRecords = require('./network-records.js');

lighthouse-core/computed/trace-of-tab.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,34 @@
66
'use strict';
77

88
const makeComputedArtifact = require('./computed-artifact.js');
9-
const TraceOfTab_ = require('../lib/tracehouse/trace-of-tab.js');
9+
const LHError = require('../lib/lh-error.js');
10+
const TraceProcessor = require('../lib/tracehouse/trace-processor.js');
11+
12+
// TraceProcessor throws generic errors, but we'd like our special localized and code-specific LHError
13+
// objects to be thrown instead.
14+
class LHTraceProcessor extends TraceProcessor {
15+
/**
16+
* @return {Error}
17+
*/
18+
static createNoNavstartError() {
19+
return new LHError(LHError.errors.NO_NAVSTART);
20+
}
21+
22+
/**
23+
* @return {Error}
24+
*/
25+
static createNoFirstContentfulPaintError() {
26+
return new LHError(LHError.errors.NO_FCP);
27+
}
28+
29+
/**
30+
* @return {Error}
31+
*/
32+
static createNoTracingStartedError() {
33+
return new LHError(LHError.errors.NO_TRACING_STARTED);
34+
}
35+
}
36+
1037

1138
class TraceOfTab {
1239
/**
@@ -16,7 +43,7 @@ class TraceOfTab {
1643
* @return {Promise<LH.Artifacts.TraceOfTab>}
1744
*/
1845
static async compute_(trace) {
19-
return TraceOfTab_.compute(trace);
46+
return LHTraceProcessor.computeTraceOfTab(trace);
2047
}
2148
}
2249

lighthouse-core/lib/minify-trace.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
* See the following files for necessary events:
1313
* - lighthouse-core/computed/page-dependency-graph.js
1414
* - lighthouse-core/lib/dependency-graph/cpu-node.js
15-
* - lighthouse-core/lib/tracehouse/trace-of-tab.js
16-
* - lighthouse-core/lib/tracehouse/tracing-processor.js
15+
* - lighthouse-core/lib/tracehouse/trace-processor.js
1716
*/
1817

19-
const TracingProcessor = require('./tracehouse/tracing-processor.js');
18+
const TracingProcessor = require('./tracehouse/trace-processor.js');
2019

2120
const toplevelTaskNames = new Set([
2221
'RunTask', // m71+

0 commit comments

Comments
 (0)