@@ -113,44 +113,54 @@ static void exportLatencyLog(
113113 long latencyMilliseconds ,
114114 SqlExecutionEvent executionEvent ,
115115 StatementId statementId ) {
116- TelemetryEvent telemetryEvent =
117- new TelemetryEvent ()
118- .setLatency (latencyMilliseconds )
119- .setSqlOperation (executionEvent )
120- .setDriverConnectionParameters (getDriverConnectionParameter (connectionContext ));
121- if (statementId != null ) {
122- telemetryEvent .setSqlStatementId (statementId .toString ());
116+ // Though we already handle null connectionContext in the downstream implementation,
117+ // we are adding this check for extra sanity
118+ if (connectionContext != null ) {
119+ TelemetryEvent telemetryEvent =
120+ new TelemetryEvent ()
121+ .setLatency (latencyMilliseconds )
122+ .setSqlOperation (executionEvent )
123+ .setDriverConnectionParameters (getDriverConnectionParameter (connectionContext ));
124+ if (statementId != null ) {
125+ telemetryEvent .setSqlStatementId (statementId .toString ());
126+ }
127+ TelemetryFrontendLog telemetryFrontendLog =
128+ new TelemetryFrontendLog ()
129+ .setFrontendLogEventId (getEventUUID ())
130+ .setContext (getLogContext ())
131+ .setEntry (new FrontendLogEntry ().setSqlDriverLog (telemetryEvent ));
132+ TelemetryClientFactory .getInstance ()
133+ .getTelemetryClient (
134+ connectionContext , DatabricksThreadContextHolder .getDatabricksConfig ())
135+ .exportEvent (telemetryFrontendLog );
123136 }
124- TelemetryFrontendLog telemetryFrontendLog =
125- new TelemetryFrontendLog ()
126- .setFrontendLogEventId (getEventUUID ())
127- .setContext (getLogContext ())
128- .setEntry (new FrontendLogEntry ().setSqlDriverLog (telemetryEvent ));
129- TelemetryClientFactory .getInstance ()
130- .getTelemetryClient (connectionContext , DatabricksThreadContextHolder .getDatabricksConfig ())
131- .exportEvent (telemetryFrontendLog );
132137 }
133138
134139 public static void exportLatencyLog (
135140 IDatabricksConnectionContext connectionContext ,
136141 long latencyMilliseconds ,
137142 DriverVolumeOperation volumeOperationEvent ) {
138- TelemetryFrontendLog telemetryFrontendLog =
139- new TelemetryFrontendLog ()
140- .setFrontendLogEventId (getEventUUID ())
141- .setContext (getLogContext ())
142- .setEntry (
143- new FrontendLogEntry ()
144- .setSqlDriverLog (
145- new TelemetryEvent ()
146- .setLatency (latencyMilliseconds )
147- .setVolumeOperation (volumeOperationEvent )
148- .setDriverConnectionParameters (
149- getDriverConnectionParameter (connectionContext ))));
143+ // Though we already handle null connectionContext in the downstream implementation,
144+ // we are adding this check for extra sanity
145+ if (connectionContext != null ) {
146+ TelemetryFrontendLog telemetryFrontendLog =
147+ new TelemetryFrontendLog ()
148+ .setFrontendLogEventId (getEventUUID ())
149+ .setContext (getLogContext ())
150+ .setEntry (
151+ new FrontendLogEntry ()
152+ .setSqlDriverLog (
153+ new TelemetryEvent ()
154+ .setLatency (latencyMilliseconds )
155+ .setVolumeOperation (volumeOperationEvent )
156+ .setDriverConnectionParameters (
157+ getDriverConnectionParameter (connectionContext ))));
150158
151- TelemetryClientFactory .getInstance ()
152- .getTelemetryClient (connectionContext , DatabricksThreadContextHolder .getDatabricksConfig ())
153- .exportEvent (telemetryFrontendLog );
159+ TelemetryClientFactory .getInstance ()
160+ .getTelemetryClient (
161+ connectionContext , DatabricksThreadContextHolder .getDatabricksConfig ())
162+ .exportEvent (telemetryFrontendLog );
163+ }
154164 }
155165
156166 private static DriverConnectionParameters getDriverConnectionParameter (
0 commit comments