refactor(coderd/telemetry): move CLI telemetry to cli/telemetry (#9517)

This change removes an indirect import of `coderd/database` from the
slim binary.

No size change (yet).

Ref: #9380
This commit is contained in:
Mathias Fredriksson
2023-09-04 21:42:45 +03:00
committed by GitHub
parent b240799f47
commit adba421524
4 changed files with 24 additions and 19 deletions

View File

@ -11,6 +11,7 @@ import (
"tailscale.com/tstime/rate"
"cdr.dev/slog"
clitelemetry "github.com/coder/coder/v2/cli/telemetry"
"github.com/coder/coder/v2/coderd/telemetry"
"github.com/coder/coder/v2/codersdk"
)
@ -30,7 +31,7 @@ func ReportCLITelemetry(log slog.Logger, rep telemetry.Reporter) func(http.Handl
//
// This approach just helps us reduce storage and ingest fees, and doesn't
// change the correctness.
queue = make(map[string]telemetry.CLIInvocation)
queue = make(map[string]clitelemetry.Invocation)
)
log = log.Named("cli-telemetry")
@ -55,7 +56,7 @@ func ReportCLITelemetry(log slog.Logger, rep telemetry.Reporter) func(http.Handl
return
}
var inv telemetry.CLIInvocation
var inv clitelemetry.Invocation
err = json.Unmarshal(byt, &inv)
if err != nil {
log.Error(

View File

@ -23,6 +23,7 @@ import (
"cdr.dev/slog"
"github.com/coder/coder/v2/buildinfo"
clitelemetry "github.com/coder/coder/v2/cli/telemetry"
"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/database/dbtime"
)
@ -714,7 +715,7 @@ type Snapshot struct {
WorkspaceResources []WorkspaceResource `json:"workspace_resources"`
WorkspaceResourceMetadata []WorkspaceResourceMetadata `json:"workspace_resource_metadata"`
WorkspaceProxies []WorkspaceProxy `json:"workspace_proxies"`
CLIInvocations []CLIInvocation `json:"cli_invocations"`
CLIInvocations []clitelemetry.Invocation `json:"cli_invocations"`
}
// Deployment contains information about the host running Coder.
@ -890,18 +891,6 @@ type License struct {
UUID uuid.UUID `json:"uuid"`
}
type CLIOption struct {
Name string `json:"name"`
ValueSource string `json:"value_source"`
}
type CLIInvocation struct {
Command string `json:"command"`
Options []CLIOption `json:"options"`
// InvokedAt is provided for deduplication purposes.
InvokedAt time.Time `json:"invoked_at"`
}
type WorkspaceProxy struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`