Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for disabled telemetry earlier #1982

Merged
merged 1 commit into from Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/bgw/job.c
Expand Up @@ -519,6 +519,9 @@ ts_bgw_job_execute(BgwJob *job)
case JOB_TYPE_VERSION_CHECK:
{
bool next_start_set;
if (!ts_telemetry_on())
/* If telemetry is off, the job trivially succeeds. */
return true;
/*
* In the first 12 hours, we want telemetry to ping every
* hour. After that initial period, we default to the
Expand Down
3 changes: 0 additions & 3 deletions src/telemetry/telemetry.c
Expand Up @@ -508,9 +508,6 @@ ts_telemetry_main(const char *host, const char *path, const char *service)
bool started = false;
const char *volatile json = NULL;

if (!ts_telemetry_on())
return true;

if (!IsTransactionOrTransactionBlock())
{
started = true;
Expand Down
22 changes: 9 additions & 13 deletions test/expected/privacy.out
Expand Up @@ -5,24 +5,20 @@
CREATE OR REPLACE FUNCTION _timescaledb_internal.test_privacy() RETURNS BOOLEAN
AS :MODULE_PATHNAME, 'ts_test_privacy' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER
-- Should be off be default in tests
SHOW timescaledb.telemetry_level;
timescaledb.telemetry_level
-----------------------------
off
(1 row)

SET timescaledb.telemetry_level=off;
SHOW timescaledb.telemetry_level;
timescaledb.telemetry_level
-----------------------------
off
SELECT 'Executed' AS test_privacy FROM _timescaledb_internal.test_privacy();
WARNING: scheme "" not supported for telemetry
test_privacy
--------------
Executed
(1 row)

SELECT _timescaledb_internal.test_privacy();
RESET timescaledb.telemetry_level;
SELECT 'Executed' AS test_privacy FROM _timescaledb_internal.test_privacy();
WARNING: scheme "" not supported for telemetry
test_privacy
--------------
t
Executed
(1 row)

-- To make sure nothing was sent, we check the UUID table to make sure no exported UUID row was created
Expand Down
9 changes: 5 additions & 4 deletions test/sql/privacy.sql
Expand Up @@ -7,10 +7,11 @@ CREATE OR REPLACE FUNCTION _timescaledb_internal.test_privacy() RETURNS BOOLEAN
AS :MODULE_PATHNAME, 'ts_test_privacy' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER

-- Should be off be default in tests
SHOW timescaledb.telemetry_level;
SET timescaledb.telemetry_level=off;
SHOW timescaledb.telemetry_level;
SELECT _timescaledb_internal.test_privacy();
SELECT 'Executed' AS test_privacy FROM _timescaledb_internal.test_privacy();

RESET timescaledb.telemetry_level;
SELECT 'Executed' AS test_privacy FROM _timescaledb_internal.test_privacy();

-- To make sure nothing was sent, we check the UUID table to make sure no exported UUID row was created
SELECT key from _timescaledb_catalog.metadata;