pub struct TelemetryClient<P> { /* private fields */ }Expand description
A KIP-714 client telemetry runtime over one persistent broker connection.
The same connection is reused for subscription and push requests so Kafka’s telemetry throttling state remains attached to one broker connection. The runtime refreshes an invalid subscription, honors broker throttle windows, bounds payload allocation, and sends one terminating push when the shutdown channel is set.
Implementations§
Source§impl<P> TelemetryClient<P>where
P: TelemetryMetricsProvider,
impl<P> TelemetryClient<P>where
P: TelemetryMetricsProvider,
Sourcepub async fn connect(
client_config: ClientConfig,
provider: P,
config: TelemetryConfig,
) -> Result<Self>
pub async fn connect( client_config: ClientConfig, provider: P, config: TelemetryConfig, ) -> Result<Self>
Connects to Kafka and creates a telemetry runtime.
Sourcepub fn from_client(client: Client, provider: P, config: TelemetryConfig) -> Self
pub fn from_client(client: Client, provider: P, config: TelemetryConfig) -> Self
Wraps an already connected low-level client.
Sourcepub fn subscription(&self) -> Option<&TelemetrySubscription>
pub fn subscription(&self) -> Option<&TelemetrySubscription>
Returns the last broker subscription, if one has been acquired.
Sourcepub async fn refresh_subscription(&mut self) -> Result<&TelemetrySubscription>
pub async fn refresh_subscription(&mut self) -> Result<&TelemetrySubscription>
Fetches a new broker subscription and replaces local subscription state.
Sourcepub async fn push_once(&mut self) -> Result<Option<TelemetryPushSummary>>
pub async fn push_once(&mut self) -> Result<Option<TelemetryPushSummary>>
Collects and pushes one non-terminating telemetry payload.
An empty broker metric subscription returns Ok(None) and does not send
a payload. An outdated subscription or compression selection causes one
refresh and retry on the same connection.
Sourcepub async fn terminate(&mut self) -> Result<Option<TelemetryPushSummary>>
pub async fn terminate(&mut self) -> Result<Option<TelemetryPushSummary>>
Sends one terminating payload, if a subscription has been acquired.
Sourcepub async fn run_until_shutdown(self, shutdown: Receiver<bool>) -> Result<()>
pub async fn run_until_shutdown(self, shutdown: Receiver<bool>) -> Result<()>
Runs the telemetry loop until shutdown becomes true or is dropped.
The first push is immediate. Subsequent pushes use the broker interval with optional jitter in the range recommended by KIP-714. Shutdown sends a terminating push before returning.