MCPcopy Index your code
hub / github.com/coder/coder / New

Function New

coderd/telemetry/telemetry.go:71–100  ·  view source on GitHub ↗

New constructs a reporter for telemetry data. Duplicate data will be sent, it's on the server-side to index by UUID. Data is anonymized prior to being sent!

(options Options)

Source from the content-addressed store, hash-verified

69// Duplicate data will be sent, it's on the server-side to index by UUID.
70// Data is anonymized prior to being sent!
71func New(options Options) (Reporter, error) {
72 if options.Clock == nil {
73 options.Clock = quartz.NewReal()
74 }
75 if options.SnapshotFrequency == 0 {
76 options.SnapshotFrequency = DefaultSnapshotFrequency
77 }
78 snapshotURL, err := options.URL.Parse("/snapshot")
79 if err != nil {
80 return nil, xerrors.Errorf("parse snapshot url: %w", err)
81 }
82 deploymentURL, err := options.URL.Parse("/deployment")
83 if err != nil {
84 return nil, xerrors.Errorf("parse deployment url: %w", err)
85 }
86
87 ctx, cancelFunc := context.WithCancel(context.Background())
88 reporter := &remoteReporter{
89 ctx: ctx,
90 closed: make(chan struct{}),
91 closeFunc: cancelFunc,
92 options: options,
93 deploymentURL: deploymentURL,
94 snapshotURL: snapshotURL,
95 startedAt: dbtime.Time(options.Clock.Now()).UTC(),
96 client: &http.Client{},
97 }
98 go reporter.runSnapshotter()
99 return reporter, nil
100}
101
102// NewNoop creates a new telemetry reporter that entirely discards all requests.
103func NewNoop() Reporter {

Callers 2

collectSnapshotFunction · 0.92
ServerMethod · 0.92

Calls 4

runSnapshotterMethod · 0.95
TimeFunction · 0.92
ParseMethod · 0.65
ErrorfMethod · 0.45

Tested by 1

collectSnapshotFunction · 0.74