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

Method deployment

coderd/telemetry/telemetry.go:308–374  ·  view source on GitHub ↗

deployment collects host information and reports it to the telemetry server.

()

Source from the content-addressed store, hash-verified

306
307// deployment collects host information and reports it to the telemetry server.
308func (r *remoteReporter) deployment() error {
309 sysInfoHost, err := sysinfo.Host()
310 if err != nil {
311 return xerrors.Errorf("get host info: %w", err)
312 }
313 mem, err := sysInfoHost.Memory()
314 if err != nil {
315 return xerrors.Errorf("get memory info: %w", err)
316 }
317 sysInfo := sysInfoHost.Info()
318
319 containerized := false
320 if sysInfo.Containerized != nil {
321 containerized = *sysInfo.Containerized
322 }
323
324 // Tracks where Coder was installed from!
325 installSource := os.Getenv("CODER_TELEMETRY_INSTALL_SOURCE")
326 if len(installSource) > 64 {
327 return xerrors.Errorf("install source must be <=64 chars: %s", installSource)
328 }
329
330 idpOrgSync, err := checkIDPOrgSync(r.ctx, r.options.Database, r.options.DeploymentConfig)
331 if err != nil {
332 r.options.Logger.Debug(r.ctx, "check IDP org sync", slog.Error(err))
333 }
334
335 data, err := json.Marshal(&Deployment{
336 ID: r.options.DeploymentID,
337 Architecture: sysInfo.Architecture,
338 BuiltinPostgres: r.options.BuiltinPostgres,
339 Containerized: containerized,
340 Config: r.options.DeploymentConfig,
341 Kubernetes: os.Getenv("KUBERNETES_SERVICE_HOST") != "",
342 InstallSource: installSource,
343 Tunnel: r.options.Tunnel,
344 OSType: sysInfo.OS.Type,
345 OSFamily: sysInfo.OS.Family,
346 OSPlatform: sysInfo.OS.Platform,
347 OSName: sysInfo.OS.Name,
348 OSVersion: sysInfo.OS.Version,
349 CPUCores: runtime.NumCPU(),
350 MemoryTotal: mem.Total,
351 MachineID: sysInfo.UniqueID,
352 StartedAt: r.startedAt,
353 ShutdownAt: r.shutdownAt,
354 IDPOrgSync: &idpOrgSync,
355 })
356 if err != nil {
357 return xerrors.Errorf("marshal deployment: %w", err)
358 }
359 req, err := http.NewRequestWithContext(r.ctx, "POST", r.deploymentURL.String(), bytes.NewReader(data))
360 if err != nil {
361 return xerrors.Errorf("create deployment request: %w", err)
362 }
363 req.Header.Set(VersionHeader, buildinfo.Version())
364 resp, err := r.client.Do(req)
365 if err != nil {

Callers 1

reportWithDeploymentMethod · 0.95

Calls 10

VersionFunction · 0.92
checkIDPOrgSyncFunction · 0.85
SetMethod · 0.65
DoMethod · 0.65
CloseMethod · 0.65
ErrorfMethod · 0.45
InfoMethod · 0.45
ErrorMethod · 0.45
MarshalMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected