net.snowflake.client.jdbc.telemetryOOB

## 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
`static class` `TelemetryService.TELEMETRY_SERVER_DEPLOYMENT`

### Field Summary

Fields
`static boolean` `FLUSH_OCSP_REVOKED_EVENT`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `add(TelemetryEvent event)`
`void` `disable()`
`void` `disableRunFlushBeforeException()`
`void` `enable()`
`void` `enableRunFlushBeforeException()`
`String` `exportQueueToString()` convert a list of json objects to a string
`void` `flush()` force to flush events in the queue
`net.minidev.json.JSONObject` `getContext()`
`String` `getDriverConnectionString()`
`static TelemetryService` `getInstance()`
`int` `getNumOfRetryToTriggerTelemetry()`
`String` `getServerDeploymentName()`
`SnowflakeConnectString` `getSnowflakeConnectionString()`
`boolean` `isDeploymentEnabled()` whether the telemetry service is enabled for current deployment
`boolean` `isEnabled()`

`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

`void` `logOCSPExceptionTelemetryEvent(String eventType, net.minidev.json.JSONObject telemetryData, CertificateException ex)` log OCSP exception to telemetry
`TelemetryEvent` `peek()`
`void` `resetBatchSize()`
`void` `resetNumOfRetryToTriggerTelemetry()`
`boolean` `runFlushBeforeException()`
`void` `setBatchSize(int size)`
`void` `setDeployment(TelemetryService.TELEMETRY_SERVER_DEPLOYMENT deployment)`
`void` `setNumOfRetryToTriggerTelemetry(int num)`
`int` `size()`
`void` `updateContext(SnowflakeConnectString conStr)`
`void` `updateContextForIT(Map<String,String> params)` Note: Only used for IT

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### FLUSH_OCSP_REVOKED_EVENT

    public static boolean FLUSH_OCSP_REVOKED_EVENT

### 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 void enable()

#### disable

    public void disable()

#### isEnabled

    public boolean isEnabled()

#### runFlushBeforeException

    public boolean runFlushBeforeException()

#### enableRunFlushBeforeException

    public void enableRunFlushBeforeException()

#### disableRunFlushBeforeException

    public void disableRunFlushBeforeException()

#### getContext

    public net.minidev.json.JSONObject getContext()

#### updateContextForIT

    public void updateContextForIT(Map<String,String> params)

Note: Only used for IT

#### updateContext

    public void updateContext(SnowflakeConnectString conStr)

#### isDeploymentEnabled

    public boolean isDeploymentEnabled()

whether the telemetry service is enabled for current deployment

#### peek

    public TelemetryEvent peek()

#### setBatchSize

    public void setBatchSize(int size)

#### resetBatchSize

    public void resetBatchSize()

#### getDriverConnectionString

    public String getDriverConnectionString()

#### getSnowflakeConnectionString

    public SnowflakeConnectString getSnowflakeConnectionString()

#### setDeployment

    public void setDeployment(TelemetryService.TELEMETRY_SERVER_DEPLOYMENT deployment)

#### getServerDeploymentName

    public String getServerDeploymentName()

#### add

    public void add(TelemetryEvent event)

#### flush

    public void flush()

force to flush events in the queue

#### exportQueueToString

    public String exportQueueToString()

convert a list of json objects to a string

Returns:
  the result json string

#### size

    public int size()

#### logOCSPExceptionTelemetryEvent

    public void logOCSPExceptionTelemetryEvent(String eventType,
                                               net.minidev.json.JSONObject telemetryData,
                                               CertificateException ex)

log OCSP exception to telemetry

#### 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