Class TelemetryClient
- java.lang.Object
-
- net.snowflake.client.jdbc.telemetry.TelemetryClient
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLogToBatch(com.fasterxml.jackson.databind.node.ObjectNode message, long timeStamp)
Add log to batch to be submitted to telemetry.void
addLogToBatch(TelemetryData log)
Add log to batch to be submitted to telemetry.int
bufferSize()
For test use onlyvoid
close()
Close telemetry connector and send any unsubmitted logsstatic Telemetry
createSessionlessTelemetry(org.apache.http.impl.client.CloseableHttpClient httpClient, String serverUrl, String authType)
Initialize the sessionless telemetry connectorstatic Telemetry
createSessionlessTelemetry(org.apache.http.impl.client.CloseableHttpClient httpClient, String serverUrl, String authType, int flushSize)
Initialize the sessionless telemetry connectorstatic Telemetry
createTelemetry(Connection conn)
Initialize the telemetry connectorstatic Telemetry
createTelemetry(Connection conn, int flushSize)
Initialize the telemetry connectorstatic Telemetry
createTelemetry(SFSession session)
Initialize the telemetry connectorstatic Telemetry
createTelemetry(SFSession session, int flushSize)
Initialize the telemetry connectorvoid
disableTelemetry()
Disable any use of the client to add/send metricsboolean
isClosed()
Return whether the client has been closedboolean
isTelemetryEnabled()
Return whether the client can be used to add/send metricsLinkedList<TelemetryData>
logBuffer()
For test use onlyvoid
postProcess(String queryId, String sqlState, int vendorCode, Throwable ex)
A hook for post-processing after sending telemetry data.void
refreshToken(String token)
Refresh the JWT/OAuth tokenFuture<Boolean>
sendBatchAsync()
Send all cached logs to serverboolean
sendLog(com.fasterxml.jackson.databind.node.ObjectNode message, long timeStamp)
Send a log to the server, along with any existing logs waiting to be sentboolean
sendLog(TelemetryData log)
Send a log to the server, along with any existing logs waiting to be sent
-
-
-
Method Detail
-
isTelemetryEnabled
public boolean isTelemetryEnabled()
Return whether the client can be used to add/send metrics- Returns:
- whether client is enabled
-
disableTelemetry
public void disableTelemetry()
Disable any use of the client to add/send metrics
-
createTelemetry
public static Telemetry createTelemetry(Connection conn, int flushSize)
Initialize the telemetry connector- Parameters:
conn
- connection with the session to use for the connectorflushSize
- maximum size of telemetry batch before flush- Returns:
- a telemetry connector
-
createTelemetry
public static Telemetry createTelemetry(Connection conn)
Initialize the telemetry connector- Parameters:
conn
- connection with the session to use for the connector- Returns:
- a telemetry connector
-
createTelemetry
public static Telemetry createTelemetry(SFSession session)
Initialize the telemetry connector- Parameters:
session
- session to use for telemetry dumps- Returns:
- a telemetry connector
-
createTelemetry
public static Telemetry createTelemetry(SFSession session, int flushSize)
Initialize the telemetry connector- Parameters:
session
- session to use for telemetry dumpsflushSize
- maximum size of telemetry batch before flush- Returns:
- a telemetry connector
-
createSessionlessTelemetry
public static Telemetry createSessionlessTelemetry(org.apache.http.impl.client.CloseableHttpClient httpClient, String serverUrl, String authType)
Initialize the sessionless telemetry connector- Parameters:
httpClient
- client object used to communicate with other machineserverUrl
- server url- Returns:
- a telemetry connector
-
createSessionlessTelemetry
public static Telemetry createSessionlessTelemetry(org.apache.http.impl.client.CloseableHttpClient httpClient, String serverUrl, String authType, int flushSize)
Initialize the sessionless telemetry connector- Parameters:
httpClient
- client object used to communicate with other machineserverUrl
- server urlauthType
- authorization type for sessionless telemetryflushSize
- maximum size of telemetry batch before flush- Returns:
- a telemetry connector
-
addLogToBatch
public void addLogToBatch(TelemetryData log)
Add log to batch to be submitted to telemetry. Send batch if forceFlushSize reached- Specified by:
addLogToBatch
in interfaceTelemetry
- Parameters:
log
- entry to add
-
addLogToBatch
public void addLogToBatch(com.fasterxml.jackson.databind.node.ObjectNode message, long timeStamp)
Add log to batch to be submitted to telemetry. Send batch if forceFlushSize reached- Parameters:
message
- json node of logtimeStamp
- timestamp to use for log
-
close
public void close()
Close telemetry connector and send any unsubmitted logs
-
isClosed
public boolean isClosed()
Return whether the client has been closed- Returns:
- whether client is closed
-
sendBatchAsync
public Future<Boolean> sendBatchAsync()
Description copied from interface:Telemetry
Send all cached logs to server- Specified by:
sendBatchAsync
in interfaceTelemetry
- Returns:
- future indicating whether the logs were sent successfully
-
postProcess
public void postProcess(String queryId, String sqlState, int vendorCode, Throwable ex)
Description copied from interface:Telemetry
A hook for post-processing after sending telemetry data. Can be used, for example, for additional error handling.- Specified by:
postProcess
in interfaceTelemetry
- Parameters:
queryId
- The query idsqlState
- The SQL state as defined in net.snowflake.common.core.SqlStatevendorCode
- The vendor code for localized messagesex
- The throwable that caused this.
-
sendLog
public boolean sendLog(TelemetryData log) throws IOException
Send a log to the server, along with any existing logs waiting to be sent- Parameters:
log
- entry to send- Returns:
- whether the logs were sent successfully
- Throws:
IOException
- if closed or uploading batch fails
-
sendLog
public boolean sendLog(com.fasterxml.jackson.databind.node.ObjectNode message, long timeStamp) throws IOException
Send a log to the server, along with any existing logs waiting to be sent- Parameters:
message
- json node of logtimeStamp
- timestamp to use for log- Returns:
- whether the logs were sent successfully
- Throws:
IOException
- if closed or uploading batch fails
-
bufferSize
public int bufferSize()
For test use only- Returns:
- the number of cached logs
-
logBuffer
public LinkedList<TelemetryData> logBuffer()
For test use only- Returns:
- a copy of the logs currently in the buffer
-
refreshToken
public void refreshToken(String token)
Refresh the JWT/OAuth token- Parameters:
token
- latest JWT/OAuth token
-
-