Class TelemetryService
- java.lang.Object
-
- net.snowflake.client.jdbc.telemetryOOB.TelemetryService
-
public class TelemetryService extends Object
Copyright (c) 2018-2019 Snowflake Computing Inc. All rights reserved.Out of Band Telemetry Service This is a thread safe singleton queue containing telemetry messages
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TelemetryService.TELEMETRY_SERVER_DEPLOYMENT
-
Constructor Summary
Constructors Constructor Description TelemetryService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
count()
Count one more successfully reported eventsstatic void
disable()
static void
disableHTAP()
static void
disableOOBTelemetry()
static void
enable()
static void
enableHTAP()
String
exportQueueToLogString(TelemetryEvent event)
String
exportQueueToString(TelemetryEvent event)
Convert an event to a payload in stringint
getClientFailureCount()
net.minidev.json.JSONObject
getContext()
String
getDriverConnectionString()
int
getEventCount()
static TelemetryService
getInstance()
String
getLastClientError()
int
getNumOfRetryToTriggerTelemetry()
String
getServerDeploymentName()
int
getServerFailureCount()
SnowflakeConnectString
getSnowflakeConnectionString()
boolean
isDeploymentEnabled()
whether the telemetry service is enabled for current deploymentboolean
isEnabled()
boolean
isHTAPEnabled()
void
logExecutionTimeTelemetryEvent(net.minidev.json.JSONObject telemetryData, String eventName)
log execution times from various processing slicesvoid
logHttpRequestTelemetryEvent(String eventName, org.apache.http.client.methods.HttpRequestBase request, int injectSocketTimeout, AtomicBoolean canceling, boolean withoutCookies, boolean includeRetryParameters, boolean includeRequestGuid, org.apache.http.client.methods.CloseableHttpResponse response, Exception savedEx, String breakRetryReason, long retryTimeout, int retryCount, String sqlState, int errorCode)
log error http response to telemetryvoid
logOCSPExceptionTelemetryEvent(String eventType, net.minidev.json.JSONObject telemetryData, CertificateException ex)
log OCSP exception to telemetryvoid
report(TelemetryEvent event)
Report the event to the telemetry server in a new threadvoid
reportChooseEvent(TelemetryEvent event, boolean isHTAP)
void
resetNumOfRetryToTriggerTelemetry()
void
setDeployment(TelemetryService.TELEMETRY_SERVER_DEPLOYMENT deployment)
void
setNumOfRetryToTriggerTelemetry(int num)
void
updateContext(SnowflakeConnectString conStr)
void
updateContextForIT(Map<String,String> params)
Note: Only used for IT
-
-
-
Method Detail
-
getInstance
public static TelemetryService getInstance()
- Returns:
- return thread local instance
-
resetNumOfRetryToTriggerTelemetry
public void resetNumOfRetryToTriggerTelemetry()
-
getNumOfRetryToTriggerTelemetry
public int getNumOfRetryToTriggerTelemetry()
-
setNumOfRetryToTriggerTelemetry
public void setNumOfRetryToTriggerTelemetry(int num)
-
enable
public static void enable()
-
disable
public static void disable()
-
enableHTAP
public static void enableHTAP()
-
disableHTAP
public static void disableHTAP()
-
disableOOBTelemetry
@SnowflakeJdbcInternalApi public static void disableOOBTelemetry()
-
isEnabled
public boolean isEnabled()
-
isHTAPEnabled
public boolean isHTAPEnabled()
-
getContext
public net.minidev.json.JSONObject getContext()
-
updateContextForIT
public void updateContextForIT(Map<String,String> params)
Note: Only used for IT- Parameters:
params
- parameter map
-
updateContext
public void updateContext(SnowflakeConnectString conStr)
-
isDeploymentEnabled
public boolean isDeploymentEnabled()
whether the telemetry service is enabled for current deployment- Returns:
- true if the telemetry service is enabled for current deployment
-
getDriverConnectionString
public String getDriverConnectionString()
-
getSnowflakeConnectionString
public SnowflakeConnectString getSnowflakeConnectionString()
-
setDeployment
public void setDeployment(TelemetryService.TELEMETRY_SERVER_DEPLOYMENT deployment)
-
getServerDeploymentName
public String getServerDeploymentName()
-
getEventCount
public int getEventCount()
- Returns:
- the number of events successfully reported by this service
-
getClientFailureCount
public int getClientFailureCount()
- Returns:
- the number of times an event was attempted to be reported but failed due to a client-side error
-
getServerFailureCount
public int getServerFailureCount()
- Returns:
- the number of times an event was attempted to be reported but failed due to a server-side error
-
getLastClientError
public String getLastClientError()
- Returns:
- the string containing the most recent failed response
-
count
public void count()
Count one more successfully reported events
-
report
public void report(TelemetryEvent event)
Report the event to the telemetry server in a new thread- Parameters:
event
- TelemetryEvent
-
reportChooseEvent
public void reportChooseEvent(TelemetryEvent event, boolean isHTAP)
-
exportQueueToString
public String exportQueueToString(TelemetryEvent event)
Convert an event to a payload in string- Parameters:
event
- TelemetryEvent- Returns:
- the string payload
-
exportQueueToLogString
public String exportQueueToLogString(TelemetryEvent event)
-
logOCSPExceptionTelemetryEvent
public void logOCSPExceptionTelemetryEvent(String eventType, net.minidev.json.JSONObject telemetryData, CertificateException ex)
log OCSP exception to telemetry- Parameters:
eventType
- event typetelemetryData
- JSON telemetry dataex
- CertificateException
-
logHttpRequestTelemetryEvent
public void logHttpRequestTelemetryEvent(String eventName, org.apache.http.client.methods.HttpRequestBase request, int injectSocketTimeout, AtomicBoolean canceling, boolean withoutCookies, boolean includeRetryParameters, boolean includeRequestGuid, org.apache.http.client.methods.CloseableHttpResponse response, Exception savedEx, String breakRetryReason, long retryTimeout, int retryCount, String sqlState, int errorCode)
log error http response to telemetry- Parameters:
eventName
- the event namerequest
- the HttpRequestBaseinjectSocketTimeout
- the socket timeoutcanceling
- cancellingwithoutCookies
- without cookiesincludeRetryParameters
- include retry parametersincludeRequestGuid
- include rest GUIDresponse
- the CloseableHttpResponsesavedEx
- the saved exceptionbreakRetryReason
- the break retry reasonretryTimeout
- the retry timeoutretryCount
- retry countsqlState
- the SQL stateerrorCode
- the error code
-
logExecutionTimeTelemetryEvent
public void logExecutionTimeTelemetryEvent(net.minidev.json.JSONObject telemetryData, String eventName)
log execution times from various processing slices- Parameters:
telemetryData
- JSON telemetry dataeventName
- the event name
-
-