public boolean sendBatch ( ) throws IOException { if ( isClosed ) { throw new IOException ( "Telemetry connector is closed" ) ; } if ( ! isTelemetryEnabled ( ) ) { return false ; } LinkedList < TelemetryData > tmpList ; synchronized ( locker ) { tmpList = this . logBatch ; this . logBatch = new LinkedList <> ( ) ; } if ( session . isClosed ( ) ) { throw new UnexpectedException ( "Session is closed when sending log" ) ; } if ( ! tmpList . isEmpty ( ) ) { //session shared with JDBC String sessionToken = this . session . getSessionToken ( ) ; HttpPost post = new HttpPost ( this . telemetryUrl ) ; post . setEntity ( new StringEntity ( logsToString ( tmpList ) ) ) ; post . setHeader ( "Content-type" , "application/json" ) ; post . setHeader ( "Authorization" , "Snowflake Token=\"" + sessionToken + "\"" ) ; String response = null ; try { response = HttpUtil . executeRequest ( post , 1000 , 0 , null ) ; } catch ( SnowflakeSQLException e ) { disableTelemetry ( ) ; // when got error like 404 or bad request, disable telemetry in this telemetry instance logger . error ( "Telemetry request failed, " + "response: {}, exception: {}" , response , e . getMessage ( ) ) ; return false ; } } return true ; }
Send all cached logs to server