mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
chore: Expose additional agent options to telemetry (#5070)
This also adds a few properties for deployments!
This commit is contained in:
@ -509,18 +509,28 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
|
|||||||
return xerrors.Errorf("parse telemetry url: %w", err)
|
return xerrors.Errorf("parse telemetry url: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gitAuth := make([]telemetry.GitAuth, 0)
|
||||||
|
for _, cfg := range gitAuthConfigs {
|
||||||
|
gitAuth = append(gitAuth, telemetry.GitAuth{
|
||||||
|
Type: string(cfg.Type),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
options.Telemetry, err = telemetry.New(telemetry.Options{
|
options.Telemetry, err = telemetry.New(telemetry.Options{
|
||||||
BuiltinPostgres: builtinPostgres,
|
BuiltinPostgres: builtinPostgres,
|
||||||
DeploymentID: deploymentID,
|
DeploymentID: deploymentID,
|
||||||
Database: options.Database,
|
Database: options.Database,
|
||||||
Logger: logger.Named("telemetry"),
|
Logger: logger.Named("telemetry"),
|
||||||
URL: telemetryURL,
|
URL: telemetryURL,
|
||||||
GitHubOAuth: cfg.OAuth2.Github.ClientID.Value != "",
|
Wildcard: cfg.WildcardAccessURL.Value != "",
|
||||||
OIDCAuth: cfg.OIDC.ClientID.Value != "",
|
DERPServerRelayURL: cfg.DERP.Server.RelayURL.Value,
|
||||||
OIDCIssuerURL: cfg.OIDC.IssuerURL.Value,
|
GitAuth: gitAuth,
|
||||||
Prometheus: cfg.Prometheus.Enable.Value,
|
GitHubOAuth: cfg.OAuth2.Github.ClientID.Value != "",
|
||||||
STUN: len(cfg.DERP.Server.STUNAddresses.Value) != 0,
|
OIDCAuth: cfg.OIDC.ClientID.Value != "",
|
||||||
Tunnel: tunnel != nil,
|
OIDCIssuerURL: cfg.OIDC.IssuerURL.Value,
|
||||||
|
Prometheus: cfg.Prometheus.Enable.Value,
|
||||||
|
STUN: len(cfg.DERP.Server.STUNAddresses.Value) != 0,
|
||||||
|
Tunnel: tunnel != nil,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("create telemetry reporter: %w", err)
|
return xerrors.Errorf("create telemetry reporter: %w", err)
|
||||||
|
@ -39,15 +39,18 @@ type Options struct {
|
|||||||
// URL is an endpoint to direct telemetry towards!
|
// URL is an endpoint to direct telemetry towards!
|
||||||
URL *url.URL
|
URL *url.URL
|
||||||
|
|
||||||
BuiltinPostgres bool
|
BuiltinPostgres bool
|
||||||
DeploymentID string
|
DeploymentID string
|
||||||
GitHubOAuth bool
|
GitHubOAuth bool
|
||||||
OIDCAuth bool
|
OIDCAuth bool
|
||||||
OIDCIssuerURL string
|
OIDCIssuerURL string
|
||||||
Prometheus bool
|
Wildcard bool
|
||||||
STUN bool
|
DERPServerRelayURL string
|
||||||
SnapshotFrequency time.Duration
|
GitAuth []GitAuth
|
||||||
Tunnel bool
|
Prometheus bool
|
||||||
|
STUN bool
|
||||||
|
SnapshotFrequency time.Duration
|
||||||
|
Tunnel bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// New constructs a reporter for telemetry data.
|
// New constructs a reporter for telemetry data.
|
||||||
@ -228,27 +231,30 @@ func (r *remoteReporter) deployment() error {
|
|||||||
containerized = *sysInfo.Containerized
|
containerized = *sysInfo.Containerized
|
||||||
}
|
}
|
||||||
data, err := json.Marshal(&Deployment{
|
data, err := json.Marshal(&Deployment{
|
||||||
ID: r.options.DeploymentID,
|
ID: r.options.DeploymentID,
|
||||||
Architecture: sysInfo.Architecture,
|
Architecture: sysInfo.Architecture,
|
||||||
BuiltinPostgres: r.options.BuiltinPostgres,
|
BuiltinPostgres: r.options.BuiltinPostgres,
|
||||||
Containerized: containerized,
|
Containerized: containerized,
|
||||||
Kubernetes: os.Getenv("KUBERNETES_SERVICE_HOST") != "",
|
Wildcard: r.options.Wildcard,
|
||||||
GitHubOAuth: r.options.GitHubOAuth,
|
DERPServerRelayURL: r.options.DERPServerRelayURL,
|
||||||
OIDCAuth: r.options.OIDCAuth,
|
GitAuth: r.options.GitAuth,
|
||||||
OIDCIssuerURL: r.options.OIDCIssuerURL,
|
Kubernetes: os.Getenv("KUBERNETES_SERVICE_HOST") != "",
|
||||||
Prometheus: r.options.Prometheus,
|
GitHubOAuth: r.options.GitHubOAuth,
|
||||||
STUN: r.options.STUN,
|
OIDCAuth: r.options.OIDCAuth,
|
||||||
Tunnel: r.options.Tunnel,
|
OIDCIssuerURL: r.options.OIDCIssuerURL,
|
||||||
OSType: sysInfo.OS.Type,
|
Prometheus: r.options.Prometheus,
|
||||||
OSFamily: sysInfo.OS.Family,
|
STUN: r.options.STUN,
|
||||||
OSPlatform: sysInfo.OS.Platform,
|
Tunnel: r.options.Tunnel,
|
||||||
OSName: sysInfo.OS.Name,
|
OSType: sysInfo.OS.Type,
|
||||||
OSVersion: sysInfo.OS.Version,
|
OSFamily: sysInfo.OS.Family,
|
||||||
CPUCores: runtime.NumCPU(),
|
OSPlatform: sysInfo.OS.Platform,
|
||||||
MemoryTotal: mem.Total,
|
OSName: sysInfo.OS.Name,
|
||||||
MachineID: sysInfo.UniqueID,
|
OSVersion: sysInfo.OS.Version,
|
||||||
StartedAt: r.startedAt,
|
CPUCores: runtime.NumCPU(),
|
||||||
ShutdownAt: r.shutdownAt,
|
MemoryTotal: mem.Total,
|
||||||
|
MachineID: sysInfo.UniqueID,
|
||||||
|
StartedAt: r.startedAt,
|
||||||
|
ShutdownAt: r.shutdownAt,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("marshal deployment: %w", err)
|
return xerrors.Errorf("marshal deployment: %w", err)
|
||||||
@ -512,17 +518,28 @@ func ConvertProvisionerJob(job database.ProvisionerJob) ProvisionerJob {
|
|||||||
|
|
||||||
// ConvertWorkspaceAgent anonymizes a workspace agent.
|
// ConvertWorkspaceAgent anonymizes a workspace agent.
|
||||||
func ConvertWorkspaceAgent(agent database.WorkspaceAgent) WorkspaceAgent {
|
func ConvertWorkspaceAgent(agent database.WorkspaceAgent) WorkspaceAgent {
|
||||||
return WorkspaceAgent{
|
snapAgent := WorkspaceAgent{
|
||||||
ID: agent.ID,
|
ID: agent.ID,
|
||||||
CreatedAt: agent.CreatedAt,
|
CreatedAt: agent.CreatedAt,
|
||||||
ResourceID: agent.ResourceID,
|
ResourceID: agent.ResourceID,
|
||||||
InstanceAuth: agent.AuthInstanceID.Valid,
|
InstanceAuth: agent.AuthInstanceID.Valid,
|
||||||
Architecture: agent.Architecture,
|
Architecture: agent.Architecture,
|
||||||
OperatingSystem: agent.OperatingSystem,
|
OperatingSystem: agent.OperatingSystem,
|
||||||
EnvironmentVariables: agent.EnvironmentVariables.Valid,
|
EnvironmentVariables: agent.EnvironmentVariables.Valid,
|
||||||
StartupScript: agent.StartupScript.Valid,
|
StartupScript: agent.StartupScript.Valid,
|
||||||
Directory: agent.Directory != "",
|
Directory: agent.Directory != "",
|
||||||
|
ConnectionTimeoutSeconds: agent.ConnectionTimeoutSeconds,
|
||||||
}
|
}
|
||||||
|
if agent.FirstConnectedAt.Valid {
|
||||||
|
snapAgent.FirstConnectedAt = &agent.FirstConnectedAt.Time
|
||||||
|
}
|
||||||
|
if agent.LastConnectedAt.Valid {
|
||||||
|
snapAgent.LastConnectedAt = &agent.LastConnectedAt.Time
|
||||||
|
}
|
||||||
|
if agent.DisconnectedAt.Valid {
|
||||||
|
snapAgent.DisconnectedAt = &agent.DisconnectedAt.Time
|
||||||
|
}
|
||||||
|
return snapAgent
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConvertWorkspaceApp anonymizes a workspace app.
|
// ConvertWorkspaceApp anonymizes a workspace app.
|
||||||
@ -625,27 +642,34 @@ type Snapshot struct {
|
|||||||
|
|
||||||
// Deployment contains information about the host running Coder.
|
// Deployment contains information about the host running Coder.
|
||||||
type Deployment struct {
|
type Deployment struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Architecture string `json:"architecture"`
|
Architecture string `json:"architecture"`
|
||||||
BuiltinPostgres bool `json:"builtin_postgres"`
|
BuiltinPostgres bool `json:"builtin_postgres"`
|
||||||
Containerized bool `json:"containerized"`
|
Containerized bool `json:"containerized"`
|
||||||
Kubernetes bool `json:"kubernetes"`
|
Kubernetes bool `json:"kubernetes"`
|
||||||
Tunnel bool `json:"tunnel"`
|
Tunnel bool `json:"tunnel"`
|
||||||
GitHubOAuth bool `json:"github_oauth"`
|
Wildcard bool `json:"wildcard"`
|
||||||
OIDCAuth bool `json:"oidc_auth"`
|
DERPServerRelayURL string `json:"derp_server_relay_url"`
|
||||||
OIDCIssuerURL string `json:"oidc_issuer_url"`
|
GitAuth []GitAuth `json:"git_auth"`
|
||||||
Prometheus bool `json:"prometheus"`
|
GitHubOAuth bool `json:"github_oauth"`
|
||||||
STUN bool `json:"stun"`
|
OIDCAuth bool `json:"oidc_auth"`
|
||||||
OSType string `json:"os_type"`
|
OIDCIssuerURL string `json:"oidc_issuer_url"`
|
||||||
OSFamily string `json:"os_family"`
|
Prometheus bool `json:"prometheus"`
|
||||||
OSPlatform string `json:"os_platform"`
|
STUN bool `json:"stun"`
|
||||||
OSName string `json:"os_name"`
|
OSType string `json:"os_type"`
|
||||||
OSVersion string `json:"os_version"`
|
OSFamily string `json:"os_family"`
|
||||||
CPUCores int `json:"cpu_cores"`
|
OSPlatform string `json:"os_platform"`
|
||||||
MemoryTotal uint64 `json:"memory_total"`
|
OSName string `json:"os_name"`
|
||||||
MachineID string `json:"machine_id"`
|
OSVersion string `json:"os_version"`
|
||||||
StartedAt time.Time `json:"started_at"`
|
CPUCores int `json:"cpu_cores"`
|
||||||
ShutdownAt *time.Time `json:"shutdown_at"`
|
MemoryTotal uint64 `json:"memory_total"`
|
||||||
|
MachineID string `json:"machine_id"`
|
||||||
|
StartedAt time.Time `json:"started_at"`
|
||||||
|
ShutdownAt *time.Time `json:"shutdown_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GitAuth struct {
|
||||||
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type APIKey struct {
|
type APIKey struct {
|
||||||
@ -682,15 +706,19 @@ type WorkspaceResourceMetadata struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type WorkspaceAgent struct {
|
type WorkspaceAgent struct {
|
||||||
ID uuid.UUID `json:"id"`
|
ID uuid.UUID `json:"id"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
ResourceID uuid.UUID `json:"resource_id"`
|
ResourceID uuid.UUID `json:"resource_id"`
|
||||||
InstanceAuth bool `json:"instance_auth"`
|
InstanceAuth bool `json:"instance_auth"`
|
||||||
Architecture string `json:"architecture"`
|
Architecture string `json:"architecture"`
|
||||||
OperatingSystem string `json:"operating_system"`
|
OperatingSystem string `json:"operating_system"`
|
||||||
EnvironmentVariables bool `json:"environment_variables"`
|
EnvironmentVariables bool `json:"environment_variables"`
|
||||||
StartupScript bool `json:"startup_script"`
|
StartupScript bool `json:"startup_script"`
|
||||||
Directory bool `json:"directory"`
|
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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WorkspaceApp struct {
|
type WorkspaceApp struct {
|
||||||
|
Reference in New Issue
Block a user