- Notifications
You must be signed in to change notification settings - Fork1.1k
feat(coderd/telemetry): add telemetry for database Tasks#20279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
5eefbd7 to7b7d778Compare7b7d778 to0f0801fCompareee92a76 toe901f8dCompared15c472 to55e34c6Comparee901f8d to7b6e819Compare55e34c6 to777681aCompare7b6e819 to4c1b0b2Compared87670a to9cc8e53Compare4e74abd toebe0908Compareebe0908 to213da47Compare| funcTask(t testing.TB,db database.Store,orig database.TaskTable) database.Task { | ||
| t.Helper() | ||
| parameters:=orig.TemplateParameters | ||
| ifparameters==nil { | ||
| parameters=json.RawMessage([]byte("{}")) | ||
| } | ||
| task,err:=db.InsertTask(genCtx, database.InsertTaskParams{ | ||
| OrganizationID:orig.OrganizationID, | ||
| OwnerID:orig.OwnerID, | ||
| Name:takeFirst(orig.Name,taskname.GenerateFallback()), | ||
| WorkspaceID:orig.WorkspaceID, | ||
| TemplateVersionID:orig.TemplateVersionID, | ||
| TemplateParameters:parameters, | ||
| Prompt:orig.Prompt, | ||
| CreatedAt:takeFirst(orig.CreatedAt,dbtime.Now()), | ||
| }) | ||
| require.NoError(t,err,"failed to insert task") | ||
| returntask | ||
| // Return the Task from the view instead of the TaskTable | ||
| fetched,err:=db.GetTaskByID(genCtx,task.ID) | ||
| require.NoError(t,err,"failed to fetch task") | ||
| require.Equal(t,task.ID,fetched.ID) | ||
| returnfetched |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
drive-by: modified this to return the view type instead
coderd/telemetry/telemetry.go Outdated
| TemplateParametersHash:fmt.Sprintf("%x",sha256.New().Sum(task.TemplateParameters)), | ||
| PromptHash:fmt.Sprintf("%x",sha256.New().Sum([]byte(task.Prompt))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I "defaulted" tosha256 here, but I'm open to other suggestions.
DanielleMaywood left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM but will defer to Hugo for approval
mafredri left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Except for the sha256, looks good 👍🏻
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
Uh oh!
There was an error while loading.Please reload this page.
dc6e50d intomainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Relates tocoder/internal#981
Stack: