|
| 1 | +// Copyright 2023 The Go Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style |
| 3 | +// license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +package telemetry |
| 6 | + |
| 7 | +import ( |
| 8 | + it "golang.org/x/telemetry/internal/telemetry" |
| 9 | +) |
| 10 | + |
| 11 | +// Mode returns the current telemetry mode. |
| 12 | +// |
| 13 | +// The telemetry mode is a global value that controls both the collection and |
| 14 | +// uploading of telemetry data. When collection is enabled, telemetry counters |
| 15 | +// and stack information are written to the local file system and may be |
| 16 | +// inspected with the [gotelemetry] command. When uploading is enabled, this |
| 17 | +// anonymous data is periodically uploaded to remote servers. |
| 18 | +// |
| 19 | +// Possible mode values are: |
| 20 | +// - "on": both collection and uploading are enabled |
| 21 | +// - "local": telemetry collection is enabled, but uploading is disabled |
| 22 | +// - "off": both collection and uploading are disabled |
| 23 | +// |
| 24 | +// If an error occurs while reading the telemetry mode from the file system, |
| 25 | +// Mode returns the default value "local". |
| 26 | +// |
| 27 | +// [gotelemetry]: https://pkg.go.dev/golang.org/x/telemetry/cmd/gotelemetry |
| 28 | +func Mode() string { |
| 29 | + return it.Mode() |
| 30 | +} |
| 31 | + |
| 32 | +// SetMode sets the global telemetry mode to the given value. |
| 33 | +// |
| 34 | +// See the documentation of [Mode] for a description of the supported mode |
| 35 | +// values. |
| 36 | +// |
| 37 | +// An error is returned if the provided mode value is invalid, or if an error |
| 38 | +// occurs while persisting the mode value to the file system. |
| 39 | +func SetMode(mode string) error { |
| 40 | + return it.SetMode(mode) |
| 41 | +} |
0 commit comments