-
Notifications
You must be signed in to change notification settings - Fork 119
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
feature/psa-metrics #969
feature/psa-metrics #969
Changes from 3 commits
5f5967e
9ccc73a
ff9425e
0b5a205
7bea36c
0d1e497
7b7ee64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,26 @@ export async function getUploadMetrics (client) { | |
} | ||
} | ||
|
||
const uploadTypeMapping = { | ||
uploads_car_total: 'Car', | ||
uploads_blob_total: 'Blob', | ||
uploads_multipart_total: 'Multipart', | ||
uploads_upload_total: 'Upload' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The DB client shouldn't be concerned with the keys we're using in the metrics. An actual upload "type" should be passed to |
||
} | ||
|
||
export async function getUploadTypeMetrics (client, key) { | ||
const uploadType = uploadTypeMapping[key] | ||
const { data, error } = await client.rpc('uploads_by_type', { query_type: uploadType }) | ||
|
||
if (error) { | ||
throw new DBError(error) | ||
} | ||
|
||
return { | ||
total: data | ||
} | ||
} | ||
|
||
export async function getContentMetrics (client) { | ||
const { data, error } = await client.rpc('content_dag_size_total') | ||
if (error) { | ||
|
@@ -68,10 +88,10 @@ export async function getPinMetrics (client) { | |
} | ||
|
||
const pinStatusMapping = { | ||
pins_status_queued_total: 'PinQueued', | ||
pins_status_pinqueued_total: 'PinQueued', | ||
pins_status_pinning_total: 'Pinning', | ||
pins_status_pinned_total: 'Pinned', | ||
pins_status_failed_total: 'PinError' | ||
pins_status_pinerror_total: 'PinError' | ||
} | ||
|
||
export async function getPinStatusMetrics (client, key) { | ||
|
@@ -86,3 +106,18 @@ export async function getPinStatusMetrics (client, key) { | |
total: data | ||
} | ||
} | ||
|
||
export async function getPinRequestsMetrics (client, key) { | ||
const { count, error } = await client | ||
.from('psa_pin_request') | ||
.select('*', { head: true, count: 'exact' }) | ||
.range(0, 1) | ||
|
||
if (error) { | ||
throw new DBError(error) | ||
} | ||
|
||
return { | ||
total: count | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -325,6 +325,19 @@ BEGIN | |
END | ||
$$; | ||
|
||
CREATE OR REPLACE FUNCTION uploads_by_type(query_type TEXT) RETURNS TEXT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering why do we need a procedure here? Shouldn't we just use client count API? I wonder if was done like this because of the Supabase client issue loading the all table even when just "counting"? Probably one for @vasco-santos There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For We use the client for other metrics counts, so if we can use it here, I think we should There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alexandrastoica did you find a reason to not have it using supabase client? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will change to client! :) |
||
LANGUAGE plpgsql | ||
AS | ||
$$ | ||
BEGIN | ||
return( | ||
select count(*) | ||
from upload | ||
where type = (query_type)::upload_type | ||
)::TEXT; | ||
END | ||
$$; | ||
|
||
CREATE OR REPLACE FUNCTION find_deals_by_content_cids(cids text[]) | ||
RETURNS TABLE | ||
( | ||
|
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 would like to change this. But we need to take into account older values. Should we rename things here to Prometheus best practises and do a sum in Grafana query with the older name?
cc @hugomrdias @alanshaw
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!