reduce buckets for incoming ap
Some checks failed
Lint / pnpm_install (push) Successful in 2m4s
Publish Docker image / Build (push) Successful in 5m4s
Test (production install and build) / production (22.11.0) (push) Successful in 1m5s
Lint / lint (backend) (push) Successful in 2m18s
Test (backend) / unit (22.11.0) (push) Successful in 8m58s
Lint / lint (frontend) (push) Successful in 2m26s
Lint / lint (frontend-embed) (push) Successful in 2m30s
Lint / lint (frontend-shared) (push) Successful in 2m26s
Lint / lint (misskey-bubble-game) (push) Successful in 2m41s
Test (backend) / e2e (22.11.0) (push) Successful in 12m10s
Lint / lint (misskey-js) (push) Successful in 2m36s
Lint / lint (misskey-reversi) (push) Successful in 2m43s
Lint / lint (sw) (push) Successful in 2m41s
Lint / typecheck (backend) (push) Has been cancelled
Lint / typecheck (misskey-js) (push) Has been cancelled
Lint / typecheck (sw) (push) Has been cancelled
Lint / pnpm_install (pull_request) Successful in 2m1s
Publish Docker image / Build (pull_request) Successful in 4m32s
Test (production install and build) / production (22.11.0) (pull_request) Successful in 1m6s
Test (backend) / unit (22.11.0) (pull_request) Successful in 8m55s
Test (backend) / e2e (22.11.0) (pull_request) Failing after 11m40s
Lint / lint (backend) (pull_request) Successful in 2m14s
Lint / lint (frontend) (pull_request) Successful in 2m12s
Lint / lint (frontend-embed) (pull_request) Successful in 2m19s
Lint / lint (frontend-shared) (pull_request) Successful in 2m27s
Lint / lint (misskey-bubble-game) (pull_request) Successful in 2m22s
Lint / lint (misskey-js) (pull_request) Successful in 2m22s
Lint / lint (misskey-reversi) (pull_request) Successful in 2m32s
Lint / lint (sw) (pull_request) Successful in 2m36s
Lint / typecheck (backend) (pull_request) Successful in 2m30s
Lint / typecheck (misskey-js) (pull_request) Successful in 1m40s
Lint / typecheck (sw) (pull_request) Successful in 1m42s

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
ゆめ 2024-11-17 21:53:54 -06:00
parent f9167b8b86
commit 3390f01128
No known key found for this signature in database

View file

@ -95,7 +95,6 @@ const sqlLogger = dbLogger.createSubLogger('sql', 'gray');
type QueryTagCache = {
join: string;
from: string;
hash: string;
};
function dedupConsecutive<T>(arr: T[]): T[] {
@ -107,40 +106,34 @@ function simplifyIdentifiers(sql: string) {
}
function extractQueryTags(query: string): QueryTagCache {
const joins = query.matchAll(/(LEFT|RIGHT|INNER|OUTER) JOIN ([a-zA-Z0-9_"`.\s]+) ON/ig);
const froms = query.matchAll(/FROM ([a-zA-Z0-9_"`.]+)/ig);
const joins = query.matchAll(/(LEFT|RIGHT|INNER|OUTER)[\s\S]+JOIN[\s\r\n]+([a-zA-Z0-9_"`.]+)/ig);
const froms = query.matchAll(/FROM[\s\r\n]+([a-zA-Z0-9_"`.]+)/ig);
const join = Array.from(joins).map(j => `${j[1]}:${simplifyIdentifiers(j[2])}`).join('|');
const from = dedupConsecutive(Array.from(froms).map(f => simplifyIdentifiers(f[1]))).join('|');
// this is not for security just to reduce metrics size just for confirmation in local environment
// all the code is public there is nothing secret in the query itself
const hash = createHash('md5');
hash.update(query);
return {
join,
from,
hash: hash.digest('hex'),
};
}
const mQueryCounter = metricCounter({
name: 'misskey_postgres_query_total',
help: 'Total queries to postgres',
labelNames: ['join', 'from', 'hash'],
labelNames: ['join', 'from'],
});
const mQueryErrorCounter = metricCounter({
name: 'misskey_postgres_query_error_total',
help: 'Total errors in queries to postgres',
labelNames: ['join', 'from', 'hash'],
labelNames: ['join', 'from'],
});
const mSlowQueryHisto = metricHistogram({
name: 'misskey_postgres_query_slow_duration_seconds',
help: 'Duration of slow queries to postgres',
labelNames: ['join', 'from', 'hash'],
labelNames: ['join', 'from'],
buckets: [0.1, 0.5, 1, 2, 5, 10, 30, 300],
});