-
Notifications
You must be signed in to change notification settings - Fork 17.5k
/
telemetrystats.go
51 lines (46 loc) · 1.41 KB
/
telemetrystats.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !cmd_go_bootstrap
package telemetrystats
import (
"cmd/go/internal/base"
"cmd/go/internal/cfg"
"cmd/go/internal/modload"
"cmd/internal/telemetry/counter"
)
func Increment() {
incrementConfig()
incrementVersionCounters()
}
// incrementConfig increments counters for the configuration
// the command is running in.
func incrementConfig() {
if !modload.WillBeEnabled() {
counter.Inc("go/mode:gopath")
} else if workfile := modload.FindGoWork(base.Cwd()); workfile != "" {
counter.Inc("go/mode:workspace")
} else {
counter.Inc("go/mode:module")
}
counter.Inc("go/platform/target/goos:" + cfg.Goos)
counter.Inc("go/platform/target/goarch:" + cfg.Goarch)
switch cfg.Goarch {
case "386":
counter.Inc("go/platform/target/go386:" + cfg.GO386)
case "amd64":
counter.Inc("go/platform/target/goamd64:" + cfg.GOAMD64)
case "arm":
counter.Inc("go/platform/target/goarm:" + cfg.GOARM)
case "arm64":
counter.Inc("go/platform/target/goarm64:" + cfg.GOARM64)
case "mips":
counter.Inc("go/platform/target/gomips:" + cfg.GOMIPS)
case "ppc64":
counter.Inc("go/platform/target/goppc64:" + cfg.GOPPC64)
case "riscv64":
counter.Inc("go/platform/target/goriscv64:" + cfg.GORISCV64)
case "wasm":
counter.Inc("go/platform/target/gowasm:" + cfg.GOWASM)
}
}