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

Commitadba421

Browse files
authored
refactor(coderd/telemetry): move CLI telemetry to cli/telemetry (#9517)
This change removes an indirect import of `coderd/database` from theslim binary.No size change (yet).Ref:#9380
1 parentb240799 commitadba421

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed

‎cli/root.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636
"github.com/coder/coder/v2/cli/cliui"
3737
"github.com/coder/coder/v2/cli/config"
3838
"github.com/coder/coder/v2/cli/gitauth"
39-
"github.com/coder/coder/v2/coderd/telemetry"
39+
"github.com/coder/coder/v2/cli/telemetry"
4040
"github.com/coder/coder/v2/codersdk"
4141
"github.com/coder/coder/v2/codersdk/agentsdk"
4242
)
@@ -467,17 +467,17 @@ func addTelemetryHeader(client *codersdk.Client, inv *clibase.Invocation) {
467467
client.HTTPClient.Transport=transport
468468
}
469469

470-
vartopts []telemetry.CLIOption
470+
vartopts []telemetry.Option
471471
for_,opt:=rangeinv.Command.FullOptions() {
472472
ifopt.ValueSource==clibase.ValueSourceNone||opt.ValueSource==clibase.ValueSourceDefault {
473473
continue
474474
}
475-
topts=append(topts, telemetry.CLIOption{
475+
topts=append(topts, telemetry.Option{
476476
Name:opt.Name,
477477
ValueSource:string(opt.ValueSource),
478478
})
479479
}
480-
ti:= telemetry.CLIInvocation{
480+
ti:= telemetry.Invocation{
481481
Command:inv.Command.FullName(),
482482
Options:topts,
483483
InvokedAt:time.Now(),

‎cli/telemetry/telemetry.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package telemetry
2+
3+
import"time"
4+
5+
typeOptionstruct {
6+
Namestring`json:"name"`
7+
ValueSourcestring`json:"value_source"`
8+
}
9+
10+
typeInvocationstruct {
11+
Commandstring`json:"command"`
12+
Options []Option`json:"options"`
13+
// InvokedAt is provided for deduplication purposes.
14+
InvokedAt time.Time`json:"invoked_at"`
15+
}

‎coderd/httpmw/clitelemetry.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"tailscale.com/tstime/rate"
1212

1313
"cdr.dev/slog"
14+
clitelemetry"github.com/coder/coder/v2/cli/telemetry"
1415
"github.com/coder/coder/v2/coderd/telemetry"
1516
"github.com/coder/coder/v2/codersdk"
1617
)
@@ -30,7 +31,7 @@ func ReportCLITelemetry(log slog.Logger, rep telemetry.Reporter) func(http.Handl
3031
//
3132
// This approach just helps us reduce storage and ingest fees, and doesn't
3233
// change the correctness.
33-
queue=make(map[string]telemetry.CLIInvocation)
34+
queue=make(map[string]clitelemetry.Invocation)
3435
)
3536

3637
log=log.Named("cli-telemetry")
@@ -55,7 +56,7 @@ func ReportCLITelemetry(log slog.Logger, rep telemetry.Reporter) func(http.Handl
5556
return
5657
}
5758

58-
varinvtelemetry.CLIInvocation
59+
varinvclitelemetry.Invocation
5960
err=json.Unmarshal(byt,&inv)
6061
iferr!=nil {
6162
log.Error(

‎coderd/telemetry/telemetry.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"cdr.dev/slog"
2525
"github.com/coder/coder/v2/buildinfo"
26+
clitelemetry"github.com/coder/coder/v2/cli/telemetry"
2627
"github.com/coder/coder/v2/coderd/database"
2728
"github.com/coder/coder/v2/coderd/database/dbtime"
2829
)
@@ -714,7 +715,7 @@ type Snapshot struct {
714715
WorkspaceResources []WorkspaceResource`json:"workspace_resources"`
715716
WorkspaceResourceMetadata []WorkspaceResourceMetadata`json:"workspace_resource_metadata"`
716717
WorkspaceProxies []WorkspaceProxy`json:"workspace_proxies"`
717-
CLIInvocations []CLIInvocation`json:"cli_invocations"`
718+
CLIInvocations []clitelemetry.Invocation`json:"cli_invocations"`
718719
}
719720

720721
// Deployment contains information about the host running Coder.
@@ -890,18 +891,6 @@ type License struct {
890891
UUID uuid.UUID`json:"uuid"`
891892
}
892893

893-
typeCLIOptionstruct {
894-
Namestring`json:"name"`
895-
ValueSourcestring`json:"value_source"`
896-
}
897-
898-
typeCLIInvocationstruct {
899-
Commandstring`json:"command"`
900-
Options []CLIOption`json:"options"`
901-
// InvokedAt is provided for deduplication purposes.
902-
InvokedAt time.Time`json:"invoked_at"`
903-
}
904-
905894
typeWorkspaceProxystruct {
906895
ID uuid.UUID`json:"id"`
907896
Namestring`json:"name"`

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp