Skip to content

Commit

Permalink
PS-9165: Product Usage Tracking - phase 1
Browse files Browse the repository at this point in the history
kamil-holubicki committed May 31, 2024
1 parent 820068d commit abaa584
Showing 15 changed files with 233 additions and 52 deletions.
23 changes: 9 additions & 14 deletions components/percona_telemetry/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
# Copyright (c) 2017, 2021, Oracle and/or its affiliates.
# Copyright (c) 2024 Percona LLC and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 of
# the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version 2.0, for more details.
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA


DISABLE_MISSING_PROFILE_WARNING()

16 changes: 16 additions & 0 deletions components/percona_telemetry/common.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* Copyright (c) 2024 Percona LLC and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#ifndef PERCONA_TELEMETRY_COMMON_H
#define PERCONA_TELEMETRY_COMMON_H

16 changes: 16 additions & 0 deletions components/percona_telemetry/component.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* Copyright (c) 2024 Percona LLC and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#include <mysql/components/component_implementation.h>
#include <mysql/components/my_service.h>
#include <mysql/components/services/component_sys_var_service.h>
16 changes: 16 additions & 0 deletions components/percona_telemetry/config.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* Copyright (c) 2024 Percona LLC and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#include <cassert>

#include "common.h"
16 changes: 16 additions & 0 deletions components/percona_telemetry/config.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* Copyright (c) 2024 Percona LLC and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#ifndef PERCONA_TELEMETRY_CONFIG_H
#define PERCONA_TELEMETRY_CONFIG_H

54 changes: 16 additions & 38 deletions components/percona_telemetry/data_provider.cc
Original file line number Diff line number Diff line change
@@ -1,47 +1,25 @@
/* Copyright (c) 2024 Percona LLC and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#include <mysqld_error.h>
#include <sstream>

#include "data_provider.h"
#include "logger.h"

/* The list of metrics collected by Percona Telemetry Component:
Must have:
1. replication information (is it enabled, Galera vs. Group Replication)
If it is PXC, it is Galera
If there is replication (see below) -> async replication
If there is replication and semisync_master or semisync_slave plugin is
installed -> semi-sync replication For GR detection fool around GR plugin and
performance_schema.replication_group_members table (see Orchestrator)
2. product version with “…-pro” suffix for Pro Builds - SELECT VERSION();
Should have:
1. plugin information (list of active plugins) -
select plugin_name, plugin_status from information_schema.plugins;
select component_urn from mysql.component;
Nice to have:
1. MySQL uptime - SHOW GLOBAL STATUS LIKE 'Uptime';
2. number of databases - SELECT COUNT(*) FROM information_schema.SCHEMATA WHERE
SCHEMA_NAME NOT IN('mysql', 'information_schema', 'performance_schema', 'sys');
3. size of databases - SELECT IFNULL(ROUND(SUM(data_length + index_length), 1),
"0") size_MB FROM information_schema.tables WHERE table_schema NOT IN('mysql',
'information_schema', 'performance_schema', 'sys');
4. encryption methods applied (?)
encrypted tables count: SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE
CREATE_OPTIONS LIKE '%ENCRYPTION%'; encrypted databases count: SELECT COUNT(*)
FROM INFORMATION_SCHEMA.SCHEMATA WHERE DEFAULT_ENCRYPTION='YES'; encrypted
tablespaces count: SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
WHERE (flag & 8192) != 0;
5. number of replication nodes, master/slave
source:
show replicas;
replica:
show replica status; -> Replica_IO_Running, Replica_SQL_Running
6. storage engine used (MyRocks, InnoDB) - SELECT DISTINCT ENGINE FROM
information_schema.tables WHERE table_schema NOT IN('mysql',
'information_schema', 'performance_schema', 'sys'); 7.
*/

namespace {
inline const char *b2s(bool val) { return val ? "1" : "0"; }

16 changes: 16 additions & 0 deletions components/percona_telemetry/data_provider.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* Copyright (c) 2024 Percona LLC and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#ifndef PERCONA_TELEMETRY_DATA_PROVIDER_H
#define PERCONA_TELEMETRY_DATA_PROVIDER_H

16 changes: 16 additions & 0 deletions components/percona_telemetry/logger.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* Copyright (c) 2024 Percona LLC and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#include <stdarg.h>

#include <mysqld_error.h>
16 changes: 16 additions & 0 deletions components/percona_telemetry/logger.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* Copyright (c) 2024 Percona LLC and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#ifndef PERCONA_TELEMETRY_LOGGER_H
#define PERCONA_TELEMETRY_LOGGER_H

16 changes: 16 additions & 0 deletions components/percona_telemetry/percona_telemetry_component.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* Copyright (c) 2024 Percona LLC and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#include "percona_telemetry_component.h"
#include "config.h"
#include "data_provider.h"
16 changes: 16 additions & 0 deletions components/percona_telemetry/percona_telemetry_component.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* Copyright (c) 2024 Percona LLC and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#ifndef PERCONA_TELEMETRY_COMPONENT_H
#define PERCONA_TELEMETRY_COMPONENT_H

16 changes: 16 additions & 0 deletions components/percona_telemetry/storage.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* Copyright (c) 2024 Percona LLC and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#include <filesystem>
#include <fstream>
#include <string_view>
16 changes: 16 additions & 0 deletions components/percona_telemetry/storage.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* Copyright (c) 2024 Percona LLC and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#ifndef PERCONA_TELEMETRY_STORAGE_H
#define PERCONA_TELEMETRY_STORAGE_H

16 changes: 16 additions & 0 deletions components/percona_telemetry/worker.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* Copyright (c) 2024 Percona LLC and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#include <mutex>

#include "logger.h"
16 changes: 16 additions & 0 deletions components/percona_telemetry/worker.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/* Copyright (c) 2024 Percona LLC and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#ifndef PERCONA_TELEMETRY_WORKER_H
#define PERCONA_TELEMETRY_WORKER_H

0 comments on commit abaa584

Please sign in to comment.