Add CMAKE option for default telemetry setting

Adds a CMAKE option to turn telemetry off by default by specifying
-DSEND_TELEMETRY_DEFAULT=NO. The default is YES or on.
This commit is contained in:
Matvey Arye 2019-06-05 16:59:35 -04:00 committed by Matvey Arye
parent 6dbcc85210
commit 48d9e2ce25
6 changed files with 26 additions and 5 deletions

View File

@ -280,6 +280,7 @@ endif ()
option(USE_OPENSSL "Enable use of OpenSSL if available" ON)
option(SEND_TELEMETRY_DEFAULT "The default value for whether to send telemetry" ON)
# Check if PostgreSQL has OpenSSL enabled by inspecting pg_config --configure.
# Right now, a Postgres header will redefine an OpenSSL function if Postgres is not installed --with-openssl,

View File

@ -6,6 +6,7 @@ DO language plpgsql $$
DECLARE
end_time TIMESTAMPTZ;
expiration_time_string TEXT;
telemetry_string TEXT;
BEGIN
end_time := _timescaledb_internal.license_expiration_time();
@ -16,7 +17,14 @@ BEGIN
expiration_time_string = '';
END IF;
RAISE WARNING E'%\n%',
IF current_setting('timescaledb.telemetry_level') = 'off'
THEN
telemetry_string = E'Note: Please enable telemetry to help us improve our product by running: ALTER DATABASE "' || current_database() || E'" SET timescaledb.telemetry_level = ''basic'';';
ELSE
telemetry_string = E'Note: TimescaleDB collects anonymous reports to better understand and assist our users.\nFor more information and how to disable, please see our docs https://docs.timescaledb.com/using-timescaledb/telemetry.';
END IF;
RAISE WARNING E'%\n%\n%',
E'\nWELCOME TO\n' ||
E' _____ _ _ ____________ \n' ||
E'|_ _(_) | | | _ \\ ___ \\ \n' ||
@ -30,8 +38,8 @@ BEGIN
||
E' 1. Getting started: https://docs.timescale.com/getting-started\n' ||
E' 2. API reference documentation: https://docs.timescale.com/api\n' ||
E' 3. How TimescaleDB is designed: https://docs.timescale.com/introduction/architecture\n\n' ||
E'Note: TimescaleDB collects anonymous reports to better understand and assist our users.\nFor more information and how to disable, please see our docs https://docs.timescaledb.com/using-timescaledb/telemetry.',
E' 3. How TimescaleDB is designed: https://docs.timescale.com/introduction/architecture\n',
telemetry_string,
expiration_time_string;
IF now() > end_time

View File

@ -87,6 +87,12 @@ else ()
add_library(${PROJECT_NAME} MODULE ${SOURCES} ${GITCOMMIT_H})
endif ()
if (SEND_TELEMETRY_DEFAULT)
set(TELEMETRY_DEFAULT TELEMETRY_BASIC)
else ()
set(TELEMETRY_DEFAULT TELEMETRY_OFF)
endif ()
set_target_properties(${PROJECT_NAME} PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}-${PROJECT_VERSION_MOD}
PREFIX "")

View File

@ -37,6 +37,10 @@
#cmakedefine TS_DEBUG
#endif
#ifndef TELEMETRY_DEFAULT
#cmakedefine TELEMETRY_DEFAULT @TELEMETRY_DEFAULT@
#endif
/* Avoid conflicts with USE_OPENSSL defined by PostgreSQL */
#cmakedefine TS_USE_OPENSSL

View File

@ -9,6 +9,7 @@
#include "guc.h"
#include "license_guc.h"
#include "config.h"
#include "hypertable_cache.h"
#include "telemetry/telemetry.h"
@ -43,7 +44,7 @@ bool ts_guc_enable_runtime_exclusion = true;
bool ts_guc_enable_constraint_exclusion = true;
int ts_guc_max_open_chunks_per_insert = 10;
int ts_guc_max_cached_chunks_per_hypertable = 10;
int ts_guc_telemetry_level = TELEMETRY_BASIC;
int ts_guc_telemetry_level = TELEMETRY_DEFAULT;
TSDLLEXPORT char *ts_guc_license_key = TS_DEFAULT_LICENSE;
char *ts_last_tune_time = NULL;
@ -190,7 +191,7 @@ _guc_init(void)
"Telemetry settings level",
"Level used to determine which telemetry to send",
&ts_guc_telemetry_level,
TELEMETRY_BASIC,
TELEMETRY_DEFAULT,
telemetry_level_options,
PGC_USERSET,
0,

View File

@ -4,3 +4,4 @@
* LICENSE-APACHE for a copy of the license.
*/
/* Overwrite main config.h so we could inject our own version #s here. */
#define TELEMETRY_DEFAULT TELEMETRY_OFF