| `gitlab_banzai_cached_render_real_duration_seconds` | Histogram | 9.4 | Duration of rendering Markdown into HTML when cached output exists | `controller`, `action` |
| `gitlab_banzai_cacheless_render_real_duration_seconds` | Histogram | 9.4 | Duration of rendering Markdown into HTML when cached output does not exist | `controller`, `action` |
| `http_request_duration_seconds` | Histogram | 9.4 | HTTP response time from rack middleware | `method` |
| `gitlab_transaction_db_count_total` | Counter | 13.1 | Counter for total number of SQL calls | `controller`, `action` |
| `gitlab_transaction_db_<role>_count_total` | Counter | 13.10 | Counter for total number of SQL calls, grouped by database roles (primary/replica) | `controller`, `action` |
| `gitlab_transaction_db_write_count_total` | Counter | 13.1 | Counter for total number of write SQL calls | `controller`, `action` |
| `gitlab_transaction_db_cached_count_total` | Counter | 13.1 | Counter for total number of cached SQL calls | `controller`, `action` |
| `gitlab_transaction_db_<role>_cached_count_total` | Counter | 13.1 | Counter for total number of cached SQL calls, grouped by database roles (primary/replica) | `controller`, `action` |
| `http_elasticsearch_requests_duration_seconds`**(PREMIUM)** | Histogram | 13.1 | Elasticsearch requests duration during web transactions | `controller`, `action` |
| `http_elasticsearch_requests_total`**(PREMIUM)** | Counter | 13.1 | Elasticsearch requests count during web transactions | `controller`, `action` |
| `pipelines_created_total` | Counter | 9.4 | Counter of pipelines created | |
'SQL'|'SELECT * FROM users WHERE id = 10'|true|false|false
'SQL'|'WITH active_milestones AS (SELECT COUNT(*), state FROM milestones GROUP BY state) SELECT * FROM active_milestones'|true|false|false
'SQL'|'SELECT * FROM users WHERE id = 10 FOR UPDATE'|true|true|false
'SQL'|'WITH archived_rows AS (SELECT * FROM users WHERE archived = true) INSERT INTO products_log SELECT * FROM archived_rows'|true|true|false
'SQL'|'DELETE FROM users where id = 10'|true|true|false
'SQL'|'INSERT INTO project_ci_cd_settings (project_id) SELECT id FROM projects'|true|true|false
'SQL'|'UPDATE users SET admin = true WHERE id = 10'|true|true|false
'CACHE'|'SELECT * FROM users WHERE id = 10'|true|false|true
'SCHEMA'|"SELECT attr.attname FROM pg_attribute attr INNER JOIN pg_constraint cons ON attr.attrelid = cons.conrelid AND attr.attnum = any(cons.conkey) WHERE cons.contype = 'p' AND cons.conrelid = '\"projects\"'::regclass"|false|false|false
'SQL'|'SELECT * FROM users WHERE id = 10'|true|false|false
'SQL'|'WITH active_milestones AS (SELECT COUNT(*), state FROM milestones GROUP BY state) SELECT * FROM active_milestones'|true|false|false
'SQL'|'SELECT * FROM users WHERE id = 10 FOR UPDATE'|true|true|false
'SQL'|'WITH archived_rows AS (SELECT * FROM users WHERE archived = true) INSERT INTO products_log SELECT * FROM archived_rows'|true|true|false
'SQL'|'DELETE FROM users where id = 10'|true|true|false
'SQL'|'INSERT INTO project_ci_cd_settings (project_id) SELECT id FROM projects'|true|true|false
'SQL'|'UPDATE users SET admin = true WHERE id = 10'|true|true|false
'CACHE'|'SELECT * FROM users WHERE id = 10'|true|false|true
'SCHEMA'|"SELECT attr.attname FROM pg_attribute attr INNER JOIN pg_constraint cons ON attr.attrelid = cons.conrelid AND attr.attnum = any(cons.conkey) WHERE cons.contype = 'p' AND cons.conrelid = '\"projects\"'::regclass"|false|false|false
let(:payload){{sql: sql('WITH active_milestones AS (SELECT COUNT(*), state FROM milestones GROUP BY state) SELECT * FROM active_milestones',comments: comments)}}
it_behaves_like'track query in metrics'
it_behaves_like'track query in RequestStore'
end
end
shared_examples'write queries'do
let(:expected_counters)do
{
db_count: 1,
db_write_count: 1,
db_cached_count: 0
}
it_behaves_like'record ActiveRecord metrics'
it_behaves_like'store ActiveRecord info in RequestStore'
end
context'with select for update sql event'do
let(:payload){{sql: sql('SELECT * FROM users WHERE id = 10 FOR UPDATE',comments: comments)}}
it_behaves_like'track query in metrics'
it_behaves_like'track query in RequestStore'
end
context'with common table expression'do
context'with insert'do
let(:payload){{sql: sql('WITH archived_rows AS (SELECT * FROM users WHERE archived = true) INSERT INTO products_log SELECT * FROM archived_rows',comments: comments)}}
it_behaves_like'track query in metrics'
it_behaves_like'track query in RequestStore'
end
end
context'with delete sql event'do
let(:payload){{sql: sql('DELETE FROM users where id = 10',comments: comments)}}