telemetry

package
v0.7.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2022 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VersionHeader is sent in every telemetry request to
	// report the semantic version of Coder.
	VersionHeader = "X-Coder-Version"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	ID        string             `json:"id"`
	UserID    uuid.UUID          `json:"user_id"`
	CreatedAt time.Time          `json:"created_at"`
	LastUsed  time.Time          `json:"last_used"`
	LoginType database.LoginType `json:"login_type"`
	IPAddress net.IP             `json:"ip_address"`
}

func ConvertAPIKey

func ConvertAPIKey(apiKey database.APIKey) APIKey

ConvertAPIKey anonymizes an API key.

type Deployment

type Deployment struct {
	ID              string     `json:"id"`
	Architecture    string     `json:"architecture"`
	BuiltinPostgres bool       `json:"builtin_postgres"`
	Containerized   bool       `json:"containerized"`
	Tunnel          bool       `json:"tunnel"`
	GitHubOAuth     bool       `json:"github_oauth"`
	Prometheus      bool       `json:"prometheus"`
	STUN            bool       `json:"stun"`
	OSType          string     `json:"os_type"`
	OSFamily        string     `json:"os_family"`
	OSPlatform      string     `json:"os_platform"`
	OSName          string     `json:"os_name"`
	OSVersion       string     `json:"os_version"`
	CPUCores        int        `json:"cpu_cores"`
	MemoryTotal     uint64     `json:"memory_total"`
	MachineID       string     `json:"machine_id"`
	StartedAt       time.Time  `json:"started_at"`
	ShutdownAt      *time.Time `json:"shutdown_at"`
}

Deployment contains information about the host running Coder.

type Options

type Options struct {
	Database database.Store
	Logger   slog.Logger
	// URL is an endpoint to direct telemetry towards!
	URL *url.URL

	BuiltinPostgres   bool
	DeploymentID      string
	GitHubOAuth       bool
	Prometheus        bool
	STUN              bool
	SnapshotFrequency time.Duration
	Tunnel            bool
}

type ParameterSchema

type ParameterSchema struct {
	ID                  uuid.UUID `json:"id"`
	JobID               uuid.UUID `json:"job_id"`
	Name                string    `json:"name"`
	ValidationCondition string    `json:"validation_condition"`
}

type ProvisionerJob

type ProvisionerJob struct {
	ID             uuid.UUID                   `json:"id"`
	OrganizationID uuid.UUID                   `json:"organization_id"`
	InitiatorID    uuid.UUID                   `json:"initiator_id"`
	CreatedAt      time.Time                   `json:"created_at"`
	UpdatedAt      time.Time                   `json:"updated_at"`
	StartedAt      *time.Time                  `json:"started_at,omitempty"`
	CanceledAt     *time.Time                  `json:"canceled_at,omitempty"`
	CompletedAt    *time.Time                  `json:"completed_at,omitempty"`
	Error          string                      `json:"error"`
	Type           database.ProvisionerJobType `json:"type"`
}

func ConvertProvisionerJob

func ConvertProvisionerJob(job database.ProvisionerJob) ProvisionerJob

ConvertProvisionerJob anonymizes a provisioner job.

type Reporter

type Reporter interface {
	// Report sends a snapshot to the telemetry server.
	// The contents of the snapshot can be a partial representation of the
	// database. For example, if a new user is added, a snapshot can
	// contain just that user entry.
	Report(snapshot *Snapshot)
	Close()
}

Reporter sends data to the telemetry server.

func New

func New(options Options) (Reporter, error)

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!

func NewNoop

func NewNoop() Reporter

NewNoop creates a new telemetry reporter that entirely discards all requests.

type Snapshot

type Snapshot struct {
	DeploymentID string `json:"deployment_id"`

	APIKeys            []APIKey            `json:"api_keys"`
	ParameterSchemas   []ParameterSchema   `json:"parameter_schemas"`
	ProvisionerJobs    []ProvisionerJob    `json:"provisioner_jobs"`
	Templates          []Template          `json:"templates"`
	TemplateVersions   []TemplateVersion   `json:"template_versions"`
	Users              []User              `json:"users"`
	Workspaces         []Workspace         `json:"workspaces"`
	WorkspaceApps      []WorkspaceApp      `json:"workspace_apps"`
	WorkspaceAgents    []WorkspaceAgent    `json:"workspace_agents"`
	WorkspaceBuilds    []WorkspaceBuild    `json:"workspace_build"`
	WorkspaceResources []WorkspaceResource `json:"workspace_resources"`
}

Snapshot represents a point-in-time anonymized database dump. Data is aggregated by latest on the server-side, so partial data can be sent without issue.

type Template

type Template struct {
	ID              uuid.UUID `json:"id"`
	CreatedBy       uuid.UUID `json:"created_by"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	OrganizationID  uuid.UUID `json:"organization_id"`
	Deleted         bool      `json:"deleted"`
	ActiveVersionID uuid.UUID `json:"active_version_id"`
	Name            string    `json:"name"`
	Description     bool      `json:"description"`
}

func ConvertTemplate

func ConvertTemplate(dbTemplate database.Template) Template

ConvertTemplate anonymizes a template.

type TemplateVersion

type TemplateVersion struct {
	ID             uuid.UUID  `json:"id"`
	CreatedAt      time.Time  `json:"created_at"`
	TemplateID     *uuid.UUID `json:"template_id,omitempty"`
	OrganizationID uuid.UUID  `json:"organization_id"`
	JobID          uuid.UUID  `json:"job_id"`
}

func ConvertTemplateVersion

func ConvertTemplateVersion(version database.TemplateVersion) TemplateVersion

ConvertTemplateVersion anonymizes a template version.

type User

type User struct {
	ID        uuid.UUID `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	// Email is only filled in for the first/admin user!
	Email       *string             `json:"email"`
	EmailHashed string              `json:"email_hashed"`
	RBACRoles   []string            `json:"rbac_roles"`
	Status      database.UserStatus `json:"status"`
}

func ConvertUser

func ConvertUser(dbUser database.User) User

ConvertUser anonymizes a user.

type Workspace

type Workspace struct {
	ID                uuid.UUID `json:"id"`
	OrganizationID    uuid.UUID `json:"organization_id"`
	OwnerID           uuid.UUID `json:"owner_id"`
	TemplateID        uuid.UUID `json:"template_id"`
	CreatedAt         time.Time `json:"created_at"`
	Deleted           bool      `json:"deleted"`
	Name              string    `json:"name"`
	AutostartSchedule string    `json:"autostart_schedule"`
}

func ConvertWorkspace

func ConvertWorkspace(workspace database.Workspace) Workspace

ConvertWorkspace anonymizes a workspace.

type WorkspaceAgent

type WorkspaceAgent struct {
	ID                   uuid.UUID `json:"id"`
	CreatedAt            time.Time `json:"created_at"`
	ResourceID           uuid.UUID `json:"resource_id"`
	InstanceAuth         bool      `json:"instance_auth"`
	Architecture         string    `json:"architecture"`
	OperatingSystem      string    `json:"operating_system"`
	EnvironmentVariables bool      `json:"environment_variables"`
	StartupScript        bool      `json:"startup_script"`
	Directory            bool      `json:"directory"`
}

func ConvertWorkspaceAgent

func ConvertWorkspaceAgent(agent database.WorkspaceAgent) WorkspaceAgent

ConvertWorkspaceAgent anonymizes a workspace agent.

type WorkspaceApp

type WorkspaceApp struct {
	ID           uuid.UUID `json:"id"`
	CreatedAt    time.Time `json:"created_at"`
	AgentID      uuid.UUID `json:"agent_id"`
	Icon         string    `json:"icon"`
	RelativePath bool      `json:"relative_path"`
}

func ConvertWorkspaceApp

func ConvertWorkspaceApp(app database.WorkspaceApp) WorkspaceApp

ConvertWorkspaceApp anonymizes a workspace app.

type WorkspaceBuild

type WorkspaceBuild struct {
	ID                uuid.UUID `json:"id"`
	CreatedAt         time.Time `json:"created_at"`
	WorkspaceID       uuid.UUID `json:"workspace_id"`
	TemplateVersionID uuid.UUID `json:"template_version_id"`
	JobID             uuid.UUID `json:"job_id"`
	BuildNumber       uint32    `json:"build_number"`
}

func ConvertWorkspaceBuild

func ConvertWorkspaceBuild(build database.WorkspaceBuild) WorkspaceBuild

ConvertWorkspaceBuild anonymizes a workspace build.

type WorkspaceResource

type WorkspaceResource struct {
	ID         uuid.UUID                    `json:"id"`
	JobID      uuid.UUID                    `json:"job_id"`
	Transition database.WorkspaceTransition `json:"transition"`
	Type       string                       `json:"type"`
}

func ConvertWorkspaceResource

func ConvertWorkspaceResource(resource database.WorkspaceResource) WorkspaceResource

ConvertWorkspaceResource anonymizes a workspace resource.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL