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,12 +509,22 @@ 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,
|
||||||
|
Wildcard: cfg.WildcardAccessURL.Value != "",
|
||||||
|
DERPServerRelayURL: cfg.DERP.Server.RelayURL.Value,
|
||||||
|
GitAuth: gitAuth,
|
||||||
GitHubOAuth: cfg.OAuth2.Github.ClientID.Value != "",
|
GitHubOAuth: cfg.OAuth2.Github.ClientID.Value != "",
|
||||||
OIDCAuth: cfg.OIDC.ClientID.Value != "",
|
OIDCAuth: cfg.OIDC.ClientID.Value != "",
|
||||||
OIDCIssuerURL: cfg.OIDC.IssuerURL.Value,
|
OIDCIssuerURL: cfg.OIDC.IssuerURL.Value,
|
||||||
|
@ -44,6 +44,9 @@ type Options struct {
|
|||||||
GitHubOAuth bool
|
GitHubOAuth bool
|
||||||
OIDCAuth bool
|
OIDCAuth bool
|
||||||
OIDCIssuerURL string
|
OIDCIssuerURL string
|
||||||
|
Wildcard bool
|
||||||
|
DERPServerRelayURL string
|
||||||
|
GitAuth []GitAuth
|
||||||
Prometheus bool
|
Prometheus bool
|
||||||
STUN bool
|
STUN bool
|
||||||
SnapshotFrequency time.Duration
|
SnapshotFrequency time.Duration
|
||||||
@ -232,6 +235,9 @@ func (r *remoteReporter) deployment() error {
|
|||||||
Architecture: sysInfo.Architecture,
|
Architecture: sysInfo.Architecture,
|
||||||
BuiltinPostgres: r.options.BuiltinPostgres,
|
BuiltinPostgres: r.options.BuiltinPostgres,
|
||||||
Containerized: containerized,
|
Containerized: containerized,
|
||||||
|
Wildcard: r.options.Wildcard,
|
||||||
|
DERPServerRelayURL: r.options.DERPServerRelayURL,
|
||||||
|
GitAuth: r.options.GitAuth,
|
||||||
Kubernetes: os.Getenv("KUBERNETES_SERVICE_HOST") != "",
|
Kubernetes: os.Getenv("KUBERNETES_SERVICE_HOST") != "",
|
||||||
GitHubOAuth: r.options.GitHubOAuth,
|
GitHubOAuth: r.options.GitHubOAuth,
|
||||||
OIDCAuth: r.options.OIDCAuth,
|
OIDCAuth: r.options.OIDCAuth,
|
||||||
@ -512,7 +518,7 @@ 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,
|
||||||
@ -522,7 +528,18 @@ func ConvertWorkspaceAgent(agent database.WorkspaceAgent) WorkspaceAgent {
|
|||||||
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.
|
||||||
@ -631,6 +648,9 @@ type Deployment struct {
|
|||||||
Containerized bool `json:"containerized"`
|
Containerized bool `json:"containerized"`
|
||||||
Kubernetes bool `json:"kubernetes"`
|
Kubernetes bool `json:"kubernetes"`
|
||||||
Tunnel bool `json:"tunnel"`
|
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"`
|
GitHubOAuth bool `json:"github_oauth"`
|
||||||
OIDCAuth bool `json:"oidc_auth"`
|
OIDCAuth bool `json:"oidc_auth"`
|
||||||
OIDCIssuerURL string `json:"oidc_issuer_url"`
|
OIDCIssuerURL string `json:"oidc_issuer_url"`
|
||||||
@ -648,6 +668,10 @@ type Deployment struct {
|
|||||||
ShutdownAt *time.Time `json:"shutdown_at"`
|
ShutdownAt *time.Time `json:"shutdown_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GitAuth struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
type APIKey struct {
|
type APIKey struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
UserID uuid.UUID `json:"user_id"`
|
UserID uuid.UUID `json:"user_id"`
|
||||||
@ -691,6 +715,10 @@ type WorkspaceAgent struct {
|
|||||||
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