Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfefacc5

Browse files
authored
chore: Expose additional agent options to telemetry (#5070)
This also adds a few properties for deployments!
1 parent9692cc2 commitfefacc5

File tree

2 files changed

+119
-81
lines changed

2 files changed

+119
-81
lines changed

‎cli/server.go

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -509,18 +509,28 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
509509
returnxerrors.Errorf("parse telemetry url: %w",err)
510510
}
511511

512+
gitAuth:=make([]telemetry.GitAuth,0)
513+
for_,cfg:=rangegitAuthConfigs {
514+
gitAuth=append(gitAuth, telemetry.GitAuth{
515+
Type:string(cfg.Type),
516+
})
517+
}
518+
512519
options.Telemetry,err=telemetry.New(telemetry.Options{
513-
BuiltinPostgres:builtinPostgres,
514-
DeploymentID:deploymentID,
515-
Database:options.Database,
516-
Logger:logger.Named("telemetry"),
517-
URL:telemetryURL,
518-
GitHubOAuth:cfg.OAuth2.Github.ClientID.Value!="",
519-
OIDCAuth:cfg.OIDC.ClientID.Value!="",
520-
OIDCIssuerURL:cfg.OIDC.IssuerURL.Value,
521-
Prometheus:cfg.Prometheus.Enable.Value,
522-
STUN:len(cfg.DERP.Server.STUNAddresses.Value)!=0,
523-
Tunnel:tunnel!=nil,
520+
BuiltinPostgres:builtinPostgres,
521+
DeploymentID:deploymentID,
522+
Database:options.Database,
523+
Logger:logger.Named("telemetry"),
524+
URL:telemetryURL,
525+
Wildcard:cfg.WildcardAccessURL.Value!="",
526+
DERPServerRelayURL:cfg.DERP.Server.RelayURL.Value,
527+
GitAuth:gitAuth,
528+
GitHubOAuth:cfg.OAuth2.Github.ClientID.Value!="",
529+
OIDCAuth:cfg.OIDC.ClientID.Value!="",
530+
OIDCIssuerURL:cfg.OIDC.IssuerURL.Value,
531+
Prometheus:cfg.Prometheus.Enable.Value,
532+
STUN:len(cfg.DERP.Server.STUNAddresses.Value)!=0,
533+
Tunnel:tunnel!=nil,
524534
})
525535
iferr!=nil {
526536
returnxerrors.Errorf("create telemetry reporter: %w",err)

‎coderd/telemetry/telemetry.go

Lines changed: 98 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,18 @@ type Options struct {
3939
// URL is an endpoint to direct telemetry towards!
4040
URL*url.URL
4141

42-
BuiltinPostgresbool
43-
DeploymentIDstring
44-
GitHubOAuthbool
45-
OIDCAuthbool
46-
OIDCIssuerURLstring
47-
Prometheusbool
48-
STUNbool
49-
SnapshotFrequency time.Duration
50-
Tunnelbool
42+
BuiltinPostgresbool
43+
DeploymentIDstring
44+
GitHubOAuthbool
45+
OIDCAuthbool
46+
OIDCIssuerURLstring
47+
Wildcardbool
48+
DERPServerRelayURLstring
49+
GitAuth []GitAuth
50+
Prometheusbool
51+
STUNbool
52+
SnapshotFrequency time.Duration
53+
Tunnelbool
5154
}
5255

5356
// New constructs a reporter for telemetry data.
@@ -228,27 +231,30 @@ func (r *remoteReporter) deployment() error {
228231
containerized=*sysInfo.Containerized
229232
}
230233
data,err:=json.Marshal(&Deployment{
231-
ID:r.options.DeploymentID,
232-
Architecture:sysInfo.Architecture,
233-
BuiltinPostgres:r.options.BuiltinPostgres,
234-
Containerized:containerized,
235-
Kubernetes:os.Getenv("KUBERNETES_SERVICE_HOST")!="",
236-
GitHubOAuth:r.options.GitHubOAuth,
237-
OIDCAuth:r.options.OIDCAuth,
238-
OIDCIssuerURL:r.options.OIDCIssuerURL,
239-
Prometheus:r.options.Prometheus,
240-
STUN:r.options.STUN,
241-
Tunnel:r.options.Tunnel,
242-
OSType:sysInfo.OS.Type,
243-
OSFamily:sysInfo.OS.Family,
244-
OSPlatform:sysInfo.OS.Platform,
245-
OSName:sysInfo.OS.Name,
246-
OSVersion:sysInfo.OS.Version,
247-
CPUCores:runtime.NumCPU(),
248-
MemoryTotal:mem.Total,
249-
MachineID:sysInfo.UniqueID,
250-
StartedAt:r.startedAt,
251-
ShutdownAt:r.shutdownAt,
234+
ID:r.options.DeploymentID,
235+
Architecture:sysInfo.Architecture,
236+
BuiltinPostgres:r.options.BuiltinPostgres,
237+
Containerized:containerized,
238+
Wildcard:r.options.Wildcard,
239+
DERPServerRelayURL:r.options.DERPServerRelayURL,
240+
GitAuth:r.options.GitAuth,
241+
Kubernetes:os.Getenv("KUBERNETES_SERVICE_HOST")!="",
242+
GitHubOAuth:r.options.GitHubOAuth,
243+
OIDCAuth:r.options.OIDCAuth,
244+
OIDCIssuerURL:r.options.OIDCIssuerURL,
245+
Prometheus:r.options.Prometheus,
246+
STUN:r.options.STUN,
247+
Tunnel:r.options.Tunnel,
248+
OSType:sysInfo.OS.Type,
249+
OSFamily:sysInfo.OS.Family,
250+
OSPlatform:sysInfo.OS.Platform,
251+
OSName:sysInfo.OS.Name,
252+
OSVersion:sysInfo.OS.Version,
253+
CPUCores:runtime.NumCPU(),
254+
MemoryTotal:mem.Total,
255+
MachineID:sysInfo.UniqueID,
256+
StartedAt:r.startedAt,
257+
ShutdownAt:r.shutdownAt,
252258
})
253259
iferr!=nil {
254260
returnxerrors.Errorf("marshal deployment: %w",err)
@@ -512,17 +518,28 @@ func ConvertProvisionerJob(job database.ProvisionerJob) ProvisionerJob {
512518

513519
// ConvertWorkspaceAgent anonymizes a workspace agent.
514520
funcConvertWorkspaceAgent(agent database.WorkspaceAgent)WorkspaceAgent {
515-
returnWorkspaceAgent{
516-
ID:agent.ID,
517-
CreatedAt:agent.CreatedAt,
518-
ResourceID:agent.ResourceID,
519-
InstanceAuth:agent.AuthInstanceID.Valid,
520-
Architecture:agent.Architecture,
521-
OperatingSystem:agent.OperatingSystem,
522-
EnvironmentVariables:agent.EnvironmentVariables.Valid,
523-
StartupScript:agent.StartupScript.Valid,
524-
Directory:agent.Directory!="",
521+
snapAgent:=WorkspaceAgent{
522+
ID:agent.ID,
523+
CreatedAt:agent.CreatedAt,
524+
ResourceID:agent.ResourceID,
525+
InstanceAuth:agent.AuthInstanceID.Valid,
526+
Architecture:agent.Architecture,
527+
OperatingSystem:agent.OperatingSystem,
528+
EnvironmentVariables:agent.EnvironmentVariables.Valid,
529+
StartupScript:agent.StartupScript.Valid,
530+
Directory:agent.Directory!="",
531+
ConnectionTimeoutSeconds:agent.ConnectionTimeoutSeconds,
525532
}
533+
ifagent.FirstConnectedAt.Valid {
534+
snapAgent.FirstConnectedAt=&agent.FirstConnectedAt.Time
535+
}
536+
ifagent.LastConnectedAt.Valid {
537+
snapAgent.LastConnectedAt=&agent.LastConnectedAt.Time
538+
}
539+
ifagent.DisconnectedAt.Valid {
540+
snapAgent.DisconnectedAt=&agent.DisconnectedAt.Time
541+
}
542+
returnsnapAgent
526543
}
527544

528545
// ConvertWorkspaceApp anonymizes a workspace app.
@@ -625,27 +642,34 @@ type Snapshot struct {
625642

626643
// Deployment contains information about the host running Coder.
627644
typeDeploymentstruct {
628-
IDstring`json:"id"`
629-
Architecturestring`json:"architecture"`
630-
BuiltinPostgresbool`json:"builtin_postgres"`
631-
Containerizedbool`json:"containerized"`
632-
Kubernetesbool`json:"kubernetes"`
633-
Tunnelbool`json:"tunnel"`
634-
GitHubOAuthbool`json:"github_oauth"`
635-
OIDCAuthbool`json:"oidc_auth"`
636-
OIDCIssuerURLstring`json:"oidc_issuer_url"`
637-
Prometheusbool`json:"prometheus"`
638-
STUNbool`json:"stun"`
639-
OSTypestring`json:"os_type"`
640-
OSFamilystring`json:"os_family"`
641-
OSPlatformstring`json:"os_platform"`
642-
OSNamestring`json:"os_name"`
643-
OSVersionstring`json:"os_version"`
644-
CPUCoresint`json:"cpu_cores"`
645-
MemoryTotaluint64`json:"memory_total"`
646-
MachineIDstring`json:"machine_id"`
647-
StartedAt time.Time`json:"started_at"`
648-
ShutdownAt*time.Time`json:"shutdown_at"`
645+
IDstring`json:"id"`
646+
Architecturestring`json:"architecture"`
647+
BuiltinPostgresbool`json:"builtin_postgres"`
648+
Containerizedbool`json:"containerized"`
649+
Kubernetesbool`json:"kubernetes"`
650+
Tunnelbool`json:"tunnel"`
651+
Wildcardbool`json:"wildcard"`
652+
DERPServerRelayURLstring`json:"derp_server_relay_url"`
653+
GitAuth []GitAuth`json:"git_auth"`
654+
GitHubOAuthbool`json:"github_oauth"`
655+
OIDCAuthbool`json:"oidc_auth"`
656+
OIDCIssuerURLstring`json:"oidc_issuer_url"`
657+
Prometheusbool`json:"prometheus"`
658+
STUNbool`json:"stun"`
659+
OSTypestring`json:"os_type"`
660+
OSFamilystring`json:"os_family"`
661+
OSPlatformstring`json:"os_platform"`
662+
OSNamestring`json:"os_name"`
663+
OSVersionstring`json:"os_version"`
664+
CPUCoresint`json:"cpu_cores"`
665+
MemoryTotaluint64`json:"memory_total"`
666+
MachineIDstring`json:"machine_id"`
667+
StartedAt time.Time`json:"started_at"`
668+
ShutdownAt*time.Time`json:"shutdown_at"`
669+
}
670+
671+
typeGitAuthstruct {
672+
Typestring`json:"type"`
649673
}
650674

651675
typeAPIKeystruct {
@@ -682,15 +706,19 @@ type WorkspaceResourceMetadata struct {
682706
}
683707

684708
typeWorkspaceAgentstruct {
685-
ID uuid.UUID`json:"id"`
686-
CreatedAt time.Time`json:"created_at"`
687-
ResourceID uuid.UUID`json:"resource_id"`
688-
InstanceAuthbool`json:"instance_auth"`
689-
Architecturestring`json:"architecture"`
690-
OperatingSystemstring`json:"operating_system"`
691-
EnvironmentVariablesbool`json:"environment_variables"`
692-
StartupScriptbool`json:"startup_script"`
693-
Directorybool`json:"directory"`
709+
ID uuid.UUID`json:"id"`
710+
CreatedAt time.Time`json:"created_at"`
711+
ResourceID uuid.UUID`json:"resource_id"`
712+
InstanceAuthbool`json:"instance_auth"`
713+
Architecturestring`json:"architecture"`
714+
OperatingSystemstring`json:"operating_system"`
715+
EnvironmentVariablesbool`json:"environment_variables"`
716+
StartupScriptbool`json:"startup_script"`
717+
Directorybool`json:"directory"`
718+
FirstConnectedAt*time.Time`json:"first_connected_at"`
719+
LastConnectedAt*time.Time`json:"last_connected_at"`
720+
DisconnectedAt*time.Time`json:"disconnected_at"`
721+
ConnectionTimeoutSecondsint32`json:"connection_timeout_seconds"`
694722
}
695723

696724
typeWorkspaceAppstruct {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp