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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/stats service #2211
Feat/stats service #2211
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
5f8d822
to
f933d35
Compare
14625b9
to
64dec7e
Compare
64dec7e
to
6cff2db
Compare
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 have a question about the signatures but I think this this looks great!
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.
Nice. Some minor details and clarifications, otherwise looks super clean!
</TableHead> | ||
<TableBody> | ||
{rows.map(row => ( | ||
<TableRow > |
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.
This should have a key, technically since you can't mutate the state and the order is guaranteed it doesn't matter. But it would be good to promote best practices.
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 👍🏼
Maybe prettier could warn about this?
frontend/src/hooks/api/getters/useInstanceStats/useInstanceStats.ts
Outdated
Show resolved
Hide resolved
|
||
export const InstanceAdmin = () => { | ||
return ( | ||
<div> |
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.
Should InstanceStats be available for everyone in the system? Currently we don't gate the stats for Admins only.
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.
That was the intention, all users with access should be able to access it for now, as there is not secrets here. All stats will be implicitly available for read only users anyway (number of projects, feature toggles etc).
if(stats?.versionEnterprise) { | ||
versionTitle = 'Unleash Enterprise version'; | ||
version = stats.versionEnterprise; | ||
} else { | ||
versionTitle = 'Unleash OSS version'; | ||
version = stats?.versionOSS; | ||
} | ||
|
||
|
||
|
||
const rows = [ | ||
{title: 'Instance Id', value: stats?.instanceId}, | ||
{title: versionTitle, value: version}, | ||
{title: 'Users', value: stats?.users}, | ||
{title: 'Feature toggles', value: stats?.featureToggles}, | ||
{title: 'Projects', value: stats?.projects}, | ||
{title: 'Environments', value: stats?.environments}, | ||
{title: 'Roles', value: stats?.roles}, | ||
{title: 'Groups', value: stats?.groups}, | ||
{title: 'Context fields', value: stats?.contextFields}, | ||
{title: 'Strategies', value: stats?.strategies}, | ||
]; |
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.
Hmm. Prettier seems to not be working correctly here.
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 have not gotten my IDE to work correctly with prettier after the merge. This is how it looks after auto-format of this file.
src/lib/db/role-store.ts
Outdated
.count('*') | ||
.where('type', 'custom') | ||
.orWhere('type', 'project') | ||
.then((res) => Number(res[0].count)); |
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'm curious about this. I guess since it's count it always returns a row? But not every knex method does this, as far as I know. Sometimes this causes problems because people try to copy what they have seen elsewhere, and expect it to work the same. Not sure if we should do something about it, but I'm raising the point.
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.
In knex a count()
will return a result of type: Record<string, number | string>
. So we know it will be a single row with a "key" named "count" and the value to be a number
or a stringed number (42
vs "42"
).
method: 'get', | ||
path: '/statistics', | ||
handler: this.getStatistics, | ||
permission: NONE, |
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 assume this is intentional.
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.
yes
I have addressed all feedback @FredrikOseberg |
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!
Introduces an instance stats service exposing usage metrics of the Unleash installation.
About the changes
This feature introduces instance stats to Unleash.
This makes it easier for admins to get an overview of the Unleash installation and also offer a download CSV file function, to make it shareable (e.g. with support)
All metrics are also exposed as Prometheus metrics for convenience.