Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaybeChild ¶
func MaybeChild(config Config)
MaybeChild executes the telemetry child logic if the calling program is the telemetry child process, and does nothing otherwise. It is meant to be called as the first thing in a program that uses telemetry.Start but cannot call telemetry.Start immediately when it starts.
func Mode ¶
func Mode() string
Mode returns the current telemetry mode.
The telemetry mode is a global value that controls both the local collection and uploading of telemetry data. Possible mode values are:
- "on": both collection and uploading is enabled
- "local": collection is enabled, but uploading is disabled
- "off": both collection and uploading are disabled
When mode is "on", or "local", telemetry data is written to the local file system and may be inspected with the gotelemetry command.
If an error occurs while reading the telemetry mode from the file system, Mode returns the default value "local".
Types ¶
type Config ¶
type Config struct { // ReportCrashes, if set, will enable crash reporting. // ReportCrashes uses the [debug.SetCrashOutput] mechanism, which is a // process-wide resource. // Do not make other calls to that function within your application. // ReportCrashes is a non-functional unless the program is built with go1.23+. ReportCrashes bool // Upload causes this program to periodically upload approved counters // from the local telemetry database to telemetry.go.dev. // // This option has no effect unless the user has given consent // to enable data collection, for example by running // cmd/gotelemetry or affirming the gopls dialog. // // (This feature is expected to be used only by gopls. // Longer term, the go command may become the sole program // responsible for uploading.) Upload bool // TelemetryDir, if set, will specify an alternate telemetry // directory to write data to. If not set, it uses the default // directory. // This field is intended to be used for isolating testing environments. TelemetryDir string // UploadStartTime, if set, overrides the time used as the upload start time, // which is the time used by the upload logic to determine whether counter // file data should be uploaded. Only counter files that have expired before // the start time are considered for upload. // // This field can be used to simulate a future upload that collects recently // modified counters. UploadStartTime time.Time // UploadURL, if set, overrides the URL used to receive uploaded reports. If // unset, this URL defaults to https://telemetry.go.dev/upload. UploadURL string }
Config controls the behavior of Start.
type CounterConfig ¶
type CounterConfig = telemetry.CounterConfig
type ProgramConfig ¶
type ProgramConfig = telemetry.ProgramConfig
type ProgramReport ¶
type ProgramReport = telemetry.ProgramReport
type StartResult ¶
type StartResult struct {
// contains filtered or unexported fields
}
A StartResult is a handle to the result of a call to Start. Call StartResult.Wait to wait for the completion of all work done on behalf of Start.
func Start ¶
func Start(config Config) *StartResult
Start initializes telemetry using the specified configuration.
Start opens the local telemetry database so that counter increment operations are durably recorded in the local file system.
If [Config.Upload] is set, and the user has opted in to telemetry uploading, this process may attempt to upload approved counters to telemetry.go.dev.
If [Config.ReportCrashes] is set, any fatal crash will be recorded by incrementing a counter named for the stack of the first running goroutine in the traceback.
If either of these flags is set, Start re-executes the current executable as a child process, in a special mode in which it acts as a telemetry sidecar for the parent process (the application). In that mode, the call to Start will never return, so Start must be called immediately within main, even before such things as inspecting the command line. The application should avoid expensive steps or external side effects in init functions, as they will be executed twice (parent and child).
Start returns a StartResult, which may be awaited via StartResult.Wait to wait for all work done by Start to complete.
func (*StartResult) Wait ¶
func (res *StartResult) Wait()
Wait waits for the completion of all work initiated by Start.
type UploadConfig ¶
type UploadConfig = telemetry.UploadConfig
An UploadConfig controls what data is uploaded.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
gotelemetry
Gotelemetry is a tool for managing Go telemetry data and settings.
|
Gotelemetry is a tool for managing Go telemetry data and settings. |
gotelemetry/internal/browser
Package browser provides utilities for interacting with users' browsers.
|
Package browser provides utilities for interacting with users' browsers. |
gotelemetry/internal/csv
csv dumps all the active counters.
|
csv dumps all the active counters. |
gotelemetry/internal/view
The view command is a server intended to be run on a user's machine to display the local counters and time series charts of counters.
|
The view command is a server intended to be run on a user's machine to display the local counters and time series charts of counters. |
config
module
|
|
Package counter implements a simple counter system for collecting totally public telemetry data.
|
Package counter implements a simple counter system for collecting totally public telemetry data. |
countertest
countertest provides testing utilities for counters.
|
countertest provides testing utilities for counters. |
godev
module
|
|
internal
|
|
chartconfig
The chartconfig package defines configuration that specifies both the data that is uploaded to telemetry.go.dev, and the resulting charts that are rendered.
|
The chartconfig package defines configuration that specifies both the data that is uploaded to telemetry.go.dev, and the resulting charts that are rendered. |
config
package config provides methods for loading and querying a telemetry upload config file.
|
package config provides methods for loading and querying a telemetry upload config file. |
configgen
Package configgen generates the upload config file stored in the config.json file of golang.org/x/telemetry/config based on the chartconfig stored in config.txt.
|
Package configgen generates the upload config file stored in the config.json file of golang.org/x/telemetry/config based on the chartconfig stored in config.txt. |
configstore
Package configstore abstracts interaction with the telemetry config server.
|
Package configstore abstracts interaction with the telemetry config server. |
configtest
Package configtest provides a helper for testing using a local proxy containing a fake upload config.
|
Package configtest provides a helper for testing using a local proxy containing a fake upload config. |
counter
Package internal/counter implements the internals of the public counter package.
|
Package internal/counter implements the internals of the public counter package. |
mmap
The mmap package provides an abstraction for memory mapping files on different platforms.
|
The mmap package provides an abstraction for memory mapping files on different platforms. |
proxy
Package proxy provides functions for writing module data to a directory in proxy format, so that it can be used as a module proxy by setting GOPROXY="file://<dir>".
|
Package proxy provides functions for writing module data to a directory in proxy format, so that it can be used as a module proxy by setting GOPROXY="file://<dir>". |
regtest
Package regtest provides helpers for end-to-end testing involving counter and upload packages.
|
Package regtest provides helpers for end-to-end testing involving counter and upload packages. |
telemetry
Package telemetry manages the telemetry mode file.
|
Package telemetry manages the telemetry mode file. |
testenv
Package testenv contains helper functions for skipping tests based on which tools are present in the environment.
|
Package testenv contains helper functions for skipping tests based on which tools are present in the environment. |
unionfs
Package unionfs allows multiple file systems to be read as a union.
|
Package unionfs allows multiple file systems to be read as a union. |