- Notifications
You must be signed in to change notification settings - Fork928
feat: expose template insights as Prometheus metrics#10325
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
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!
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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 👍
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
templateNames := map[uuid.UUID]string{} | ||
if len(templateIDs) > 0 { | ||
templates, err := mc.database.GetTemplatesWithFilter(ctx, database.GetTemplatesWithFilterParams{ | ||
IDs: templateIDs, | ||
}) | ||
if err != nil { | ||
mc.logger.Error(ctx, "unable to fetch template details from database", slog.Error(err)) | ||
return | ||
} | ||
templateNames = onlyTemplateNames(templates) | ||
} |
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.
non-blocking, potential improvement: cache template ID -> template name to avoid DB fetches
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.
Thanks for your suggestion. Honestly, I wouldn't cache it yet unless we face performance issues. We would have to define the cache expiry and call db when templates are gone. Loop iterations are scheduled every 5 minutes by default, so I hope it won't impact performance. For sure, insights calls are heavier.
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.
Agreed, just something to think about later!
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Related:#9983
part 1/3 - I decided to split this PR into 3 parts to simplify code reviews. Unfortunately, we need to implement 3 extra DB queries with matching
dbfake
implementation.This PR exposes "active users" metric from Coder template insights.