@@ -24,6 +24,7 @@ import (
2424 "github.com/cockroachdb/cockroach/pkg/util/ctxgroup"
2525 "github.com/cockroachdb/cockroach/pkg/util/hlc"
2626 "github.com/cockroachdb/cockroach/pkg/util/log"
27+ "github.com/cockroachdb/cockroach/pkg/util/metric"
2728 "github.com/cockroachdb/cockroach/pkg/util/syncutil"
2829 "github.com/cockroachdb/cockroach/pkg/util/tracing"
2930 "github.com/cockroachdb/errors"
@@ -83,16 +84,17 @@ func getInspectQoS(sv *settings.Values) sessiondatapb.QoSLevel {
8384type inspectCheckFactory func (asOf hlc.Timestamp ) inspectCheck
8485
8586type inspectProcessor struct {
86- processorID int32
87- flowCtx * execinfra.FlowCtx
88- spec execinfrapb.InspectSpec
89- cfg * execinfra.ServerConfig
90- checkFactories []inspectCheckFactory
91- spanSrc spanSource
92- loggerBundle * inspectLoggerBundle
93- concurrency int
94- clock * hlc.Clock
95- mu struct {
87+ processorID int32
88+ flowCtx * execinfra.FlowCtx
89+ spec execinfrapb.InspectSpec
90+ cfg * execinfra.ServerConfig
91+ checkFactories []inspectCheckFactory
92+ spanSrc spanSource
93+ loggerBundle * inspectLoggerBundle
94+ concurrency int
95+ clock * hlc.Clock
96+ spansProcessedCtr * metric.Counter
97+ mu struct {
9698 // Guards calls to output.Push because DistSQLReceiver.Push is not
9799 // concurrency safe and progress metadata can be emitted from multiple
98100 // worker goroutines.
@@ -365,6 +367,9 @@ func (p *inspectProcessor) getTimestampForSpan() hlc.Timestamp {
365367func (p * inspectProcessor ) sendSpanCompletionProgress (
366368 ctx context.Context , output execinfra.RowReceiver , completedSpan roachpb.Span , finished bool ,
367369) error {
370+ if p .spansProcessedCtr != nil {
371+ p .spansProcessedCtr .Inc (1 )
372+ }
368373 progressMsg := & jobspb.InspectProcessorProgress {
369374 ChecksCompleted : 0 , // No additional checks completed, just marking span done
370375 Finished : finished ,
@@ -414,17 +419,23 @@ func newInspectProcessor(
414419 if err != nil {
415420 return nil , err
416421 }
422+ var spansProcessedCtr * metric.Counter
423+ if execCfg , ok := flowCtx .Cfg .ExecutorConfig .(* sql.ExecutorConfig ); ok {
424+ inspectMetrics := execCfg .JobRegistry .MetricsStruct ().Inspect .(* InspectMetrics )
425+ spansProcessedCtr = inspectMetrics .SpansProcessed
426+ }
417427
418428 return & inspectProcessor {
419- spec : spec ,
420- processorID : processorID ,
421- flowCtx : flowCtx ,
422- checkFactories : checkFactories ,
423- cfg : flowCtx .Cfg ,
424- spanSrc : newSliceSpanSource (spec .Spans ),
425- loggerBundle : getInspectLogger (flowCtx , spec .JobID ),
426- concurrency : getProcessorConcurrency (flowCtx ),
427- clock : flowCtx .Cfg .DB .KV ().Clock (),
429+ spec : spec ,
430+ processorID : processorID ,
431+ flowCtx : flowCtx ,
432+ checkFactories : checkFactories ,
433+ cfg : flowCtx .Cfg ,
434+ spanSrc : newSliceSpanSource (spec .Spans ),
435+ loggerBundle : getInspectLogger (flowCtx , spec .JobID ),
436+ concurrency : getProcessorConcurrency (flowCtx ),
437+ clock : flowCtx .Cfg .DB .KV ().Clock (),
438+ spansProcessedCtr : spansProcessedCtr ,
428439 }, nil
429440}
430441
0 commit comments