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

Commit90f82da

Browse files
committed
fix: write server config to telemetry (#13590)
* fix: add external auth configs to telemetry* Refactor telemetry to send the entire config* gen* Fix linting(cherry picked from commit3a1fa04)
1 parent201cb1c commit90f82da

File tree

10 files changed

+54
-142
lines changed

10 files changed

+54
-142
lines changed

‎cli/server.go

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -796,31 +796,18 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
796796
cliui.Infof(inv.Stdout,"\n==> Logs will stream in below (press ctrl+c to gracefully exit):")
797797

798798
ifvals.Telemetry.Enable {
799-
gitAuth:=make([]telemetry.GitAuth,0)
800-
// TODO:
801-
vargitAuthConfigs []codersdk.ExternalAuthConfig
802-
for_,cfg:=rangegitAuthConfigs {
803-
gitAuth=append(gitAuth, telemetry.GitAuth{
804-
Type:cfg.Type,
805-
})
799+
vals,err:=vals.WithoutSecrets()
800+
iferr!=nil {
801+
returnxerrors.Errorf("remove secrets from deployment values: %w",err)
806802
}
807-
808803
options.Telemetry,err=telemetry.New(telemetry.Options{
809-
BuiltinPostgres:builtinPostgres,
810-
DeploymentID:deploymentID,
811-
Database:options.Database,
812-
Logger:logger.Named("telemetry"),
813-
URL:vals.Telemetry.URL.Value(),
814-
Wildcard:vals.WildcardAccessURL.String()!="",
815-
DERPServerRelayURL:vals.DERP.Server.RelayURL.String(),
816-
GitAuth:gitAuth,
817-
GitHubOAuth:vals.OAuth2.Github.ClientID!="",
818-
OIDCAuth:vals.OIDC.ClientID!="",
819-
OIDCIssuerURL:vals.OIDC.IssuerURL.String(),
820-
Prometheus:vals.Prometheus.Enable.Value(),
821-
STUN:len(vals.DERP.Server.STUNAddresses)!=0,
822-
Tunnel:tunnel!=nil,
823-
Experiments:vals.Experiments.Value(),
804+
BuiltinPostgres:builtinPostgres,
805+
DeploymentID:deploymentID,
806+
Database:options.Database,
807+
Logger:logger.Named("telemetry"),
808+
URL:vals.Telemetry.URL.Value(),
809+
Tunnel:tunnel!=nil,
810+
DeploymentConfig:vals,
824811
ParseLicenseJWT:func(lic*telemetry.License)error {
825812
// This will be nil when running in AGPL-only mode.
826813
ifoptions.ParseLicenseClaims==nil {

‎coderd/apidoc/docs.go

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/telemetry/telemetry.go

Lines changed: 43 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,13 @@ type Options struct {
4141
// URL is an endpoint to direct telemetry towards!
4242
URL*url.URL
4343

44-
BuiltinPostgresbool
45-
DeploymentIDstring
46-
GitHubOAuthbool
47-
OIDCAuthbool
48-
OIDCIssuerURLstring
49-
Wildcardbool
50-
DERPServerRelayURLstring
51-
GitAuth []GitAuth
52-
Prometheusbool
53-
STUNbool
54-
SnapshotFrequency time.Duration
55-
Tunnelbool
56-
ParseLicenseJWTfunc(lic*License)error
57-
Experiments []string
44+
DeploymentIDstring
45+
DeploymentConfig*codersdk.DeploymentValues
46+
BuiltinPostgresbool
47+
Tunnelbool
48+
49+
SnapshotFrequency time.Duration
50+
ParseLicenseJWTfunc(lic*License)error
5851
}
5952

6053
// New constructs a reporter for telemetry data.
@@ -247,31 +240,24 @@ func (r *remoteReporter) deployment() error {
247240
}
248241

249242
data,err:=json.Marshal(&Deployment{
250-
ID:r.options.DeploymentID,
251-
Architecture:sysInfo.Architecture,
252-
BuiltinPostgres:r.options.BuiltinPostgres,
253-
Containerized:containerized,
254-
Wildcard:r.options.Wildcard,
255-
DERPServerRelayURL:r.options.DERPServerRelayURL,
256-
GitAuth:r.options.GitAuth,
257-
Kubernetes:os.Getenv("KUBERNETES_SERVICE_HOST")!="",
258-
GitHubOAuth:r.options.GitHubOAuth,
259-
OIDCAuth:r.options.OIDCAuth,
260-
OIDCIssuerURL:r.options.OIDCIssuerURL,
261-
Prometheus:r.options.Prometheus,
262-
InstallSource:installSource,
263-
STUN:r.options.STUN,
264-
Tunnel:r.options.Tunnel,
265-
OSType:sysInfo.OS.Type,
266-
OSFamily:sysInfo.OS.Family,
267-
OSPlatform:sysInfo.OS.Platform,
268-
OSName:sysInfo.OS.Name,
269-
OSVersion:sysInfo.OS.Version,
270-
CPUCores:runtime.NumCPU(),
271-
MemoryTotal:mem.Total,
272-
MachineID:sysInfo.UniqueID,
273-
StartedAt:r.startedAt,
274-
ShutdownAt:r.shutdownAt,
243+
ID:r.options.DeploymentID,
244+
Architecture:sysInfo.Architecture,
245+
BuiltinPostgres:r.options.BuiltinPostgres,
246+
Containerized:containerized,
247+
Config:r.options.DeploymentConfig,
248+
Kubernetes:os.Getenv("KUBERNETES_SERVICE_HOST")!="",
249+
InstallSource:installSource,
250+
Tunnel:r.options.Tunnel,
251+
OSType:sysInfo.OS.Type,
252+
OSFamily:sysInfo.OS.Family,
253+
OSPlatform:sysInfo.OS.Platform,
254+
OSName:sysInfo.OS.Name,
255+
OSVersion:sysInfo.OS.Version,
256+
CPUCores:runtime.NumCPU(),
257+
MemoryTotal:mem.Total,
258+
MachineID:sysInfo.UniqueID,
259+
StartedAt:r.startedAt,
260+
ShutdownAt:r.shutdownAt,
275261
})
276262
iferr!=nil {
277263
returnxerrors.Errorf("marshal deployment: %w",err)
@@ -486,10 +472,6 @@ func (r *remoteReporter) createSnapshot() (*Snapshot, error) {
486472
}
487473
returnnil
488474
})
489-
eg.Go(func()error {
490-
snapshot.Experiments=ConvertExperiments(r.options.Experiments)
491-
returnnil
492-
})
493475

494476
err:=eg.Wait()
495477
iferr!=nil {
@@ -750,16 +732,6 @@ func ConvertExternalProvisioner(id uuid.UUID, tags map[string]string, provisione
750732
}
751733
}
752734

753-
funcConvertExperiments(experiments []string) []Experiment {
754-
varout []Experiment
755-
756-
for_,exp:=rangeexperiments {
757-
out=append(out,Experiment{Name:exp})
758-
}
759-
760-
returnout
761-
}
762-
763735
// Snapshot represents a point-in-time anonymized database dump.
764736
// Data is aggregated by latest on the server-side, so partial data
765737
// can be sent without issue.
@@ -782,40 +754,28 @@ type Snapshot struct {
782754
WorkspaceResourceMetadata []WorkspaceResourceMetadata`json:"workspace_resource_metadata"`
783755
WorkspaceResources []WorkspaceResource`json:"workspace_resources"`
784756
Workspaces []Workspace`json:"workspaces"`
785-
Experiments []Experiment`json:"experiments"`
786757
}
787758

788759
// Deployment contains information about the host running Coder.
789760
typeDeploymentstruct {
790-
IDstring`json:"id"`
791-
Architecturestring`json:"architecture"`
792-
BuiltinPostgresbool`json:"builtin_postgres"`
793-
Containerizedbool`json:"containerized"`
794-
Kubernetesbool`json:"kubernetes"`
795-
Tunnelbool`json:"tunnel"`
796-
Wildcardbool`json:"wildcard"`
797-
DERPServerRelayURLstring`json:"derp_server_relay_url"`
798-
GitAuth []GitAuth`json:"git_auth"`
799-
GitHubOAuthbool`json:"github_oauth"`
800-
OIDCAuthbool`json:"oidc_auth"`
801-
OIDCIssuerURLstring`json:"oidc_issuer_url"`
802-
Prometheusbool`json:"prometheus"`
803-
InstallSourcestring`json:"install_source"`
804-
STUNbool`json:"stun"`
805-
OSTypestring`json:"os_type"`
806-
OSFamilystring`json:"os_family"`
807-
OSPlatformstring`json:"os_platform"`
808-
OSNamestring`json:"os_name"`
809-
OSVersionstring`json:"os_version"`
810-
CPUCoresint`json:"cpu_cores"`
811-
MemoryTotaluint64`json:"memory_total"`
812-
MachineIDstring`json:"machine_id"`
813-
StartedAt time.Time`json:"started_at"`
814-
ShutdownAt*time.Time`json:"shutdown_at"`
815-
}
816-
817-
typeGitAuthstruct {
818-
Typestring`json:"type"`
761+
IDstring`json:"id"`
762+
Architecturestring`json:"architecture"`
763+
BuiltinPostgresbool`json:"builtin_postgres"`
764+
Containerizedbool`json:"containerized"`
765+
Kubernetesbool`json:"kubernetes"`
766+
Config*codersdk.DeploymentValues`json:"config"`
767+
Tunnelbool`json:"tunnel"`
768+
InstallSourcestring`json:"install_source"`
769+
OSTypestring`json:"os_type"`
770+
OSFamilystring`json:"os_family"`
771+
OSPlatformstring`json:"os_platform"`
772+
OSNamestring`json:"os_name"`
773+
OSVersionstring`json:"os_version"`
774+
CPUCoresint`json:"cpu_cores"`
775+
MemoryTotaluint64`json:"memory_total"`
776+
MachineIDstring`json:"machine_id"`
777+
StartedAt time.Time`json:"started_at"`
778+
ShutdownAt*time.Time`json:"shutdown_at"`
819779
}
820780

821781
typeAPIKeystruct {
@@ -990,10 +950,6 @@ type ExternalProvisioner struct {
990950
ShutdownAt*time.Time`json:"shutdown_at"`
991951
}
992952

993-
typeExperimentstruct {
994-
Namestring`json:"name"`
995-
}
996-
997953
typenoopReporterstruct{}
998954

999955
func (*noopReporter)Report(_*Snapshot) {}

‎coderd/telemetry/telemetry_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,6 @@ func TestTelemetry(t *testing.T) {
114114
require.Len(t,snapshot.Users,1)
115115
require.Equal(t,snapshot.Users[0].EmailHashed,"bb44bf07cf9a2db0554bba63a03d822c927deae77df101874496df5a6a3e896d@coder.com")
116116
})
117-
t.Run("Experiments",func(t*testing.T) {
118-
t.Parallel()
119-
120-
constexpName="my-experiment"
121-
exps:= []string{expName}
122-
_,snapshot:=collectSnapshot(t,dbmem.New(),func(opts telemetry.Options) telemetry.Options {
123-
opts.Experiments=exps
124-
returnopts
125-
})
126-
require.Equal(t, []telemetry.Experiment{{Name:expName}},snapshot.Experiments)
127-
})
128117
}
129118

130119
// nolint:paralleltest

‎codersdk/deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ type ExternalAuthConfig struct {
392392
AppInstallationsURLstring`json:"app_installations_url" yaml:"app_installations_url"`
393393
NoRefreshbool`json:"no_refresh" yaml:"no_refresh"`
394394
Scopes []string`json:"scopes" yaml:"scopes"`
395-
ExtraTokenKeys []string`json:"extra_token_keys" yaml:"extra_token_keys"`
395+
ExtraTokenKeys []string`json:"-" yaml:"extra_token_keys"`
396396
DeviceFlowbool`json:"device_flow" yaml:"device_flow"`
397397
DeviceCodeURLstring`json:"device_code_url" yaml:"device_code_url"`
398398
// Regex allows API requesters to match an auth config by

‎docs/api/general.md

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎docs/api/schemas.md

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎site/src/api/typesGenerated.ts

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎site/src/pages/DeploySettingsPage/ExternalAuthSettingsPage/ExternalAuthSettingsPageView.stories.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const meta: Meta<typeof ExternalAuthSettingsPageView> = {
1919
app_installations_url:"",
2020
no_refresh:false,
2121
scopes:[],
22-
extra_token_keys:[],
2322
device_flow:true,
2423
device_code_url:"",
2524
display_icon:"",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp