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

Commit7b7d778

Browse files
committed
feat(coderd/telemetry): add telemetry for database Tasks
1 parentee92a76 commit7b7d778

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

‎coderd/telemetry/telemetry.go‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"strings"
2020
"sync"
2121
"time"
22+
"unicode/utf8"
2223

2324
"github.com/elastic/go-sysinfo"
2425
"github.com/google/uuid"
@@ -730,6 +731,10 @@ func (r *remoteReporter) createSnapshot() (*Snapshot, error) {
730731
}
731732
returnnil
732733
})
734+
eg.Go(func()error {
735+
// TODO: we need a way to list tasks.
736+
returnnil
737+
})
733738

734739
err:=eg.Wait()
735740
iferr!=nil {
@@ -914,6 +919,22 @@ func ConvertWorkspaceResourceMetadata(metadata database.WorkspaceResourceMetadat
914919
}
915920
}
916921

922+
// ConvertTask anonymizes a Task.
923+
funcConvertTask(task database.Task)Task {
924+
returnTask{
925+
ID:task.ID,
926+
OrganizationID:task.OrganizationID,
927+
OwnerID:task.OwnerID,
928+
Name:task.Name,
929+
WorkspaceID:task.WorkspaceID,
930+
TemplateVersionID:task.TemplateVersionID,
931+
PromptHash:fmt.Sprintf("%x",sha256.New().Sum([]byte(task.Prompt))),
932+
PromptLength:utf8.RuneCountInString(task.Prompt),
933+
CreatedAt:task.CreatedAt,
934+
Status:string(task.Status),
935+
}
936+
}
937+
917938
funcshouldSendRawModuleSource(sourcestring)bool {
918939
returnstrings.Contains(source,"registry.coder.com")
919940
}
@@ -1205,6 +1226,7 @@ type Snapshot struct {
12051226
Workspaces []Workspace`json:"workspaces"`
12061227
NetworkEvents []NetworkEvent`json:"network_events"`
12071228
Organizations []Organization`json:"organizations"`
1229+
Tasks []Task`json:"tasks"`
12081230
TelemetryItems []TelemetryItem`json:"telemetry_items"`
12091231
UserTailnetConnections []UserTailnetConnection`json:"user_tailnet_connections"`
12101232
PrebuiltWorkspaces []PrebuiltWorkspace`json:"prebuilt_workspaces"`
@@ -1753,6 +1775,19 @@ type Organization struct {
17531775
CreatedAt time.Time`json:"created_at"`
17541776
}
17551777

1778+
typeTaskstruct {
1779+
ID uuid.UUID`json:"id"`
1780+
OrganizationID uuid.UUID`json:"organization_id"`
1781+
OwnerID uuid.UUID`json:"owner_id"`
1782+
Namestring`json:"name"`
1783+
WorkspaceID uuid.NullUUID`json:"workspace_id"`
1784+
TemplateVersionID uuid.UUID`json:"template_version_id"`
1785+
PromptHashstring`json:"hashed_prompt"`
1786+
PromptLengthint`json:"prompt_length"`
1787+
CreatedAt time.Time`json:"created_at"`
1788+
Statusstring`json:"status"`
1789+
}
1790+
17561791
typetelemetryItemKeystring
17571792

17581793
// The comment below gets rid of the warning that the name "TelemetryItemKey" has

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp