github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/opt/telemetry.go (about) 1 // Copyright 2019 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package opt 12 13 import ( 14 "github.com/cockroachdb/cockroach/pkg/server/telemetry" 15 "github.com/cockroachdb/cockroach/pkg/sql/sqltelemetry" 16 "github.com/cockroachdb/errors" 17 ) 18 19 // OpTelemetryCounters stores telemetry counters for operators marked with the 20 // "Telemetry" tag. All other operators have nil values. 21 var OpTelemetryCounters [NumOperators]telemetry.Counter 22 23 func init() { 24 for _, op := range TelemetryOperators { 25 OpTelemetryCounters[op] = sqltelemetry.OptNodeCounter(op.String()) 26 } 27 } 28 29 // JoinTypeToUseCounter returns the JoinTypeXyzUseCounter for the given join 30 // operator. 31 func JoinTypeToUseCounter(op Operator) telemetry.Counter { 32 switch op { 33 case InnerJoinOp: 34 return sqltelemetry.JoinTypeInnerUseCounter 35 case LeftJoinOp, RightJoinOp: 36 return sqltelemetry.JoinTypeLeftUseCounter 37 case FullJoinOp: 38 return sqltelemetry.JoinTypeFullUseCounter 39 case SemiJoinOp: 40 return sqltelemetry.JoinTypeSemiUseCounter 41 case AntiJoinOp: 42 return sqltelemetry.JoinTypeAntiUseCounter 43 default: 44 panic(errors.AssertionFailedf("unhandled join op %s", op)) 45 } 46 }