Commit 0e1943fb authored by Russell Dickenson's avatar Russell Dickenson

Merge branch 'sh-usage-data-pg-system-id' into 'master'

Include PostgreSQL system identifier in usage ping

See merge request gitlab-org/gitlab!44972
parents 2c295f79 bb6730ec
---
title: Include PostgreSQL system identifier in usage ping
merge_request: 44972
author:
type: added
......@@ -750,7 +750,8 @@ The following is example content of the Usage Ping payload.
},
"database": {
"adapter": "postgresql",
"version": "9.6.15"
"version": "9.6.15",
"pg_system_id": 6842684531675334351
},
"avg_cycle_analytics": {
"issue": {
......@@ -910,6 +911,10 @@ The following is example content of the Usage Ping payload.
}
```
## Notable changes
In GitLab 13.5, `pg_system_id` was added to send the [PostgreSQL system identifier](https://www.2ndquadrant.com/en/blog/support-for-postgresqls-system-identifier-in-barman/).
## Exporting Usage Ping SQL queries and definitions
Two Rake tasks exist to export Usage Ping definitions.
......
......@@ -250,6 +250,12 @@ module Gitlab
false
end
def self.system_id
row = connection.execute('SELECT system_identifier FROM pg_control_system()').first
row['system_identifier']
end
def self.get_write_location(ar_connection)
row = ar_connection
.select_all("SELECT pg_current_wal_insert_lsn()::text AS location")
......
......@@ -303,7 +303,8 @@ module Gitlab
},
database: {
adapter: alt_usage_data { Gitlab::Database.adapter_name },
version: alt_usage_data { Gitlab::Database.version }
version: alt_usage_data { Gitlab::Database.version },
pg_system_id: alt_usage_data { Gitlab::Database.system_id }
},
mail: {
smtp_server: alt_usage_data { ActionMailer::Base.smtp_settings[:address] }
......
......@@ -39,6 +39,12 @@ RSpec.describe Gitlab::Database do
end
end
describe '.system_id' do
it 'returns the PostgreSQL system identifier' do
expect(described_class.system_id).to be_an_instance_of(Integer)
end
end
describe '.postgresql?' do
subject { described_class.postgresql? }
......
......@@ -723,6 +723,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
expect(subject[:git][:version]).to eq(Gitlab::Git.version)
expect(subject[:database][:adapter]).to eq(Gitlab::Database.adapter_name)
expect(subject[:database][:version]).to eq(Gitlab::Database.version)
expect(subject[:database][:pg_system_id]).to eq(Gitlab::Database.system_id)
expect(subject[:mail][:smtp_server]).to eq(ActionMailer::Base.smtp_settings[:address])
expect(subject[:gitaly][:version]).to be_present
expect(subject[:gitaly][:servers]).to be >= 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment