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`

### Constructor Summary

Constructors
Constructor and Description
`TelemetryService()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `count()` Count one more successfully reported events
`static void` `disable()`
`static void` `enable()`
`String` `exportQueueToLogString(TelemetryEvent event)`
`String` `exportQueueToString(TelemetryEvent event)` Convert an event to a payload in string
`int` `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 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
`void` `report(TelemetryEvent event)` Report the event to the telemetry server in a new thread
`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

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

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

### Constructor Detail

#### TelemetryService

    public TelemetryService()

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

#### isEnabled

    public boolean isEnabled()

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

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

#### exportQueueToString

    public String exportQueueToString(TelemetryEvent event)

Convert an event to a payload in string

#### exportQueueToLogString

    public String exportQueueToLogString(TelemetryEvent event)

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