Class 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

    • 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()
      • enableHTAP

        public static void enableHTAP()
      • disableHTAP

        public static void disableHTAP()
      • 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
      • 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()
      • 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
      • logOCSPExceptionTelemetryEvent

        public void logOCSPExceptionTelemetryEvent​(String eventType,
                                                   net.minidev.json.JSONObject telemetryData,
                                                   CertificateException ex)
        log OCSP exception to telemetry
        Parameters:
        eventType - event type
        telemetryData - JSON telemetry data
        ex - 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 name
        request - the HttpRequestBase
        injectSocketTimeout - the socket timeout
        canceling - cancelling
        withoutCookies - without cookies
        includeRetryParameters - include retry parameters
        includeRequestGuid - include rest GUID
        response - the CloseableHttpResponse
        savedEx - the saved exception
        breakRetryReason - the break retry reason
        retryTimeout - the retry timeout
        retryCount - retry count
        sqlState - the SQL state
        errorCode - 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 data
        eventName - the event name