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

SNOW-844477: Allow connection property CLIENT_OUT_OF_BAND_TELEMETRY_ENABLED to disable OOB telemetry #1464

Merged
merged 1 commit into from
Jul 14, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/net/snowflake/client/core/SFSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,15 @@ public synchronized void open() throws SFException, SnowflakeSQLException {
.setOCSPMode(getOCSPMode())
.setHttpClientSettingsKey(httpClientSettingsKey);

// Enable or disable OOB telemetry based on connection parameter. Default is disabled.
// The value may still change later when session parameters from the server are read.
if (getBooleanValue(
sfc-gh-mknister marked this conversation as resolved.
Show resolved Hide resolved
connectionPropertiesMap.get(SFSessionProperty.CLIENT_OUT_OF_BAND_TELEMETRY_ENABLED))) {
TelemetryService.enable();
} else {
TelemetryService.disable();
}

// propagate OCSP mode to SFTrustManager. Note OCSP setting is global on JVM.
HttpUtil.initHttpClient(httpClientSettingsKey, null);
SFLoginOutput loginOutput =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
import static org.junit.Assert.*;

import java.sql.Connection;
import java.sql.SQLException;
Expand Down Expand Up @@ -308,6 +308,58 @@ public void testHTAPTelemetry() throws SQLException {
}
}

/**
* Requires part 2 of SNOW-844477. Make sure CLIENT_OUT_OF_BAND_TELEMETRY_ENABLED is true at
* account level. Tests connection property CLIENT_OUT_OF_BAND_TELEMETRY_ENABLED=true
*/
@Ignore
@Test
public void testOOBTelemetryEnabled() throws SQLException {
Properties properties = new Properties();
properties.put("CLIENT_OUT_OF_BAND_TELEMETRY_ENABLED", "true");
try (Connection con = getConnection(properties)) {
Statement statement = con.createStatement();
statement.execute("select 1");
// Make sure OOB telemetry is enabled
assertTrue(TelemetryService.getInstance().isEnabled());
}
}

/**
* Requires part 2 of SNOW-844477. Make sure CLIENT_OUT_OF_BAND_TELEMETRY_ENABLED is false at
* account level. Tests connection property CLIENT_OUT_OF_BAND_TELEMETRY_ENABLED=false
*/
@Ignore
@Test
public void testOOBTelemetryDisabled() throws SQLException {
Properties properties = new Properties();
properties.put("CLIENT_OUT_OF_BAND_TELEMETRY_ENABLED", "false");
try (Connection con = getConnection(properties)) {
Statement statement = con.createStatement();
statement.execute("select 1");
// Make sure OOB telemetry is disabled
assertFalse(TelemetryService.getInstance().isEnabled());
}
}

/**
* Requires part 2 of SNOW-844477. Make sure CLIENT_OUT_OF_BAND_TELEMETRY_ENABLED is true at
* account level. Tests connection property CLIENT_OUT_OF_BAND_TELEMETRY_ENABLED=false but
* CLIENT_OUT_OF_BAND_TELEMETRY_ENABLED is enabled on account level
*/
@Ignore
@Test
public void testOOBTelemetryEnabledOnServerDisabledOnClient() throws SQLException {
Properties properties = new Properties();
properties.put("CLIENT_OUT_OF_BAND_TELEMETRY_ENABLED", "false");
try (Connection con = getConnection(properties)) {
Statement statement = con.createStatement();
statement.execute("select 1");
// Make sure OOB telemetry is enabled
assertTrue(TelemetryService.getInstance().isEnabled());
}
}

/**
* Test case for checking telemetry message for SnowflakeSQLExceptions. In-band telemetry should
* be used.
Expand Down