Class TelemetryCollectorManager
- java.lang.Object
-
- com.databricks.jdbc.telemetry.latency.TelemetryCollectorManager
-
public class TelemetryCollectorManager extends Object
Manages TelemetryCollector instances per connection. Each connection gets its own TelemetryCollector instance to ensure telemetry data is properly isolated.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears all collectors.TelemetryCollectorgetCollectorSafely(Supplier<IDatabricksConnectionContext> connectionContextSupplier)Safely gets a TelemetryCollector from connection context, catching and ignoring any errors.static TelemetryCollectorManagergetInstance()TelemetryCollectorgetOrCreateCollector(IDatabricksConnectionContext context)Gets or creates a TelemetryCollector for the given connection context.TelemetryCollectorremoveCollector(IDatabricksConnectionContext context)Removes and returns the TelemetryCollector for the given connection context.TelemetryCollectorremoveCollector(String connectionUuid)Removes and returns the TelemetryCollector for the given connection.
-
-
-
Method Detail
-
getInstance
public static TelemetryCollectorManager getInstance()
-
getOrCreateCollector
public TelemetryCollector getOrCreateCollector(IDatabricksConnectionContext context)
Gets or creates a TelemetryCollector for the given connection context. Null checks are retained due to ThreadLocal usage patterns that may result in null context.- Parameters:
context- the connection context- Returns:
- the TelemetryCollector instance for this connection
-
removeCollector
public TelemetryCollector removeCollector(String connectionUuid)
Removes and returns the TelemetryCollector for the given connection. Should be called when a connection is closed.- Parameters:
connectionUuid- the connection UUID- Returns:
- the removed TelemetryCollector, or null if not found
-
removeCollector
public TelemetryCollector removeCollector(IDatabricksConnectionContext context)
Removes and returns the TelemetryCollector for the given connection context.- Parameters:
context- the connection context- Returns:
- the removed TelemetryCollector, or null if not found
-
getCollectorSafely
public TelemetryCollector getCollectorSafely(Supplier<IDatabricksConnectionContext> connectionContextSupplier)
Safely gets a TelemetryCollector from connection context, catching and ignoring any errors. This is useful for code that doesn't want telemetry failures to affect main logic.- Parameters:
connectionContextSupplier- a function that provides the connection context- Returns:
- the TelemetryCollector, or null if an error occurred
-
clear
public void clear()
Clears all collectors. For testing purposes only.
-
-