telemetry

package
v0.26.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: AGPL-3.0 Imports: 21 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 CLIInvocation added in v0.23.6

type CLIInvocation struct {
	Command string      `json:"command"`
	Options []CLIOption `json:"options"`
	// InvokedAt is provided for deduplication purposes.
	InvokedAt time.Time `json:"invoked_at"`
}

type CLIOption added in v0.23.6

type CLIOption struct {
	Name        string `json:"name"`
	ValueSource string `json:"value_source"`
}

type Deployment

type Deployment struct {
	ID                 string     `json:"id"`
	Architecture       string     `json:"architecture"`
	BuiltinPostgres    bool       `json:"builtin_postgres"`
	Containerized      bool       `json:"containerized"`
	Kubernetes         bool       `json:"kubernetes"`
	Tunnel             bool       `json:"tunnel"`
	Wildcard           bool       `json:"wildcard"`
	DERPServerRelayURL string     `json:"derp_server_relay_url"`
	GitAuth            []GitAuth  `json:"git_auth"`
	GitHubOAuth        bool       `json:"github_oauth"`
	OIDCAuth           bool       `json:"oidc_auth"`
	OIDCIssuerURL      string     `json:"oidc_issuer_url"`
	Prometheus         bool       `json:"prometheus"`
	InstallSource      string     `json:"install_source"`
	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 GitAuth added in v0.12.7

type GitAuth struct {
	Type string `json:"type"`
}

type License added in v0.12.8

type License struct {
	UploadedAt time.Time `json:"uploaded_at"`
	UUID       uuid.UUID `json:"uuid"`
}

func ConvertLicense added in v0.12.8

func ConvertLicense(license database.License) License

ConvertLicense anonymizes a license.

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
	OIDCAuth           bool
	OIDCIssuerURL      string
	Wildcard           bool
	DERPServerRelayURL string
	GitAuth            []GitAuth
	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"`
	ProvisionerJobs           []ProvisionerJob            `json:"provisioner_jobs"`
	Licenses                  []License                   `json:"licenses"`
	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"`
	WorkspaceAgentStats       []WorkspaceAgentStat        `json:"workspace_agent_stats"`
	WorkspaceBuilds           []WorkspaceBuild            `json:"workspace_build"`
	WorkspaceResources        []WorkspaceResource         `json:"workspace_resources"`
	WorkspaceResourceMetadata []WorkspaceResourceMetadata `json:"workspace_resource_metadata"`
	CLIInvocations            []CLIInvocation             `json:"cli_invocations"`
}

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"`
	FirstConnectedAt         *time.Time `json:"first_connected_at"`
	LastConnectedAt          *time.Time `json:"last_connected_at"`
	DisconnectedAt           *time.Time `json:"disconnected_at"`
	ConnectionTimeoutSeconds int32      `json:"connection_timeout_seconds"`
	ShutdownScript           bool       `json:"shutdown_script"`
	Subsystem                string     `json:"subsystem"`
}

func ConvertWorkspaceAgent

func ConvertWorkspaceAgent(agent database.WorkspaceAgent) WorkspaceAgent

ConvertWorkspaceAgent anonymizes a workspace agent.

type WorkspaceAgentStat added in v0.20.0

type WorkspaceAgentStat struct {
	UserID                      uuid.UUID `json:"user_id"`
	TemplateID                  uuid.UUID `json:"template_id"`
	WorkspaceID                 uuid.UUID `json:"workspace_id"`
	AggregatedFrom              time.Time `json:"aggregated_from"`
	AgentID                     uuid.UUID `json:"agent_id"`
	RxBytes                     int64     `json:"rx_bytes"`
	TxBytes                     int64     `json:"tx_bytes"`
	ConnectionLatency50         float64   `json:"connection_latency_50"`
	ConnectionLatency95         float64   `json:"connection_latency_95"`
	SessionCountVSCode          int64     `json:"session_count_vscode"`
	SessionCountJetBrains       int64     `json:"session_count_jetbrains"`
	SessionCountReconnectingPTY int64     `json:"session_count_reconnecting_pty"`
	SessionCountSSH             int64     `json:"session_count_ssh"`
}

func ConvertWorkspaceAgentStat added in v0.20.0

func ConvertWorkspaceAgentStat(stat database.GetWorkspaceAgentStatsRow) WorkspaceAgentStat

ConvertWorkspaceAgentStat anonymizes a workspace agent stat.

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"`
	Subdomain bool      `json:"subdomain"`
}

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"`
	InstanceType string                       `json:"instance_type"`
}

func ConvertWorkspaceResource

func ConvertWorkspaceResource(resource database.WorkspaceResource) WorkspaceResource

ConvertWorkspaceResource anonymizes a workspace resource.

type WorkspaceResourceMetadata added in v0.8.6

type WorkspaceResourceMetadata struct {
	ResourceID uuid.UUID `json:"resource_id"`
	Key        string    `json:"key"`
	Sensitive  bool      `json:"sensitive"`
}

func ConvertWorkspaceResourceMetadata added in v0.8.6

func ConvertWorkspaceResourceMetadata(metadata database.WorkspaceResourceMetadatum) WorkspaceResourceMetadata

ConvertWorkspaceResourceMetadata anonymizes workspace metadata.

Jump to

Keyboard shortcuts

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