@@ -2,6 +2,7 @@ import { WorkerPool } from "gatsby-worker"
2
2
import { chunk } from "lodash"
3
3
import reporter from "gatsby-cli/lib/reporter"
4
4
import { cpuCoreCount } from "gatsby-core-utils"
5
+ import { Span } from "opentracing"
5
6
6
7
import { IGroupedQueryIds } from "../../services"
7
8
import { initJobsMessagingInMainProcess } from "../jobs/worker-messaging"
@@ -46,16 +47,27 @@ function handleRunQueriesInWorkersQueueError(e: Error): never {
46
47
export async function runQueriesInWorkersQueue (
47
48
pool : GatsbyWorkerPool ,
48
49
queryIds : IGroupedQueryIds ,
49
- chunkSize = queriesChunkSize
50
+ opts ?: {
51
+ chunkSize ?: number
52
+ parentSpan ?: Span
53
+ }
50
54
) : Promise < void > {
51
55
const activity = reporter . createProgress (
52
56
`run queries in workers` ,
53
- queryIds . staticQueryIds . length + queryIds . pageQueryIds . length
57
+ queryIds . staticQueryIds . length + queryIds . pageQueryIds . length ,
58
+ 0 ,
59
+ { parentSpan : opts ?. parentSpan }
54
60
)
55
61
activity . start ( )
56
62
try {
57
- const staticQuerySegments = chunk ( queryIds . staticQueryIds , chunkSize )
58
- const pageQuerySegments = chunk ( queryIds . pageQueryIds , chunkSize )
63
+ const staticQuerySegments = chunk (
64
+ queryIds . staticQueryIds ,
65
+ opts ?. chunkSize ?? queriesChunkSize
66
+ )
67
+ const pageQuerySegments = chunk (
68
+ queryIds . pageQueryIds ,
69
+ opts ?. chunkSize ?? queriesChunkSize
70
+ )
59
71
60
72
pool . all . setComponents ( )
61
73
@@ -90,8 +102,11 @@ export async function runQueriesInWorkersQueue(
90
102
}
91
103
}
92
104
93
- export async function mergeWorkerState ( pool : GatsbyWorkerPool ) : Promise < void > {
94
- const activity = reporter . activityTimer ( `Merge worker state` )
105
+ export async function mergeWorkerState (
106
+ pool : GatsbyWorkerPool ,
107
+ parentSpan ?: Span
108
+ ) : Promise < void > {
109
+ const activity = reporter . activityTimer ( `Merge worker state` , { parentSpan } )
95
110
activity . start ( )
96
111
97
112
for ( const { workerId } of pool . getWorkerInfo ( ) ) {
0 commit comments