Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions libdd-telemetry/src/worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use crate::{
use libdd_common::Endpoint;
use libdd_common::{hyper_migration, tag::Tag, worker::Worker};

use std::fmt::Debug;
use std::iter::Sum;
use std::ops::Add;
use std::{
Expand All @@ -26,6 +25,7 @@ use std::{
},
time,
};
use std::{fmt::Debug, time::Duration};

use crate::metrics::MetricBucketStats;
use futures::{
Expand Down Expand Up @@ -135,6 +135,7 @@ pub struct TelemetryWorker {
seq_id: AtomicU64,
runtime_id: String,
client: Box<dyn http_client::HttpClient + Sync + Send>,
metrics_flush_interval: Duration,
deadlines: scheduler::Scheduler<LifecycleAction>,
data: TelemetryWorkerData,
}
Expand All @@ -147,6 +148,7 @@ impl Debug for TelemetryWorker {
.field("cancellation_token", &self.cancellation_token)
.field("seq_id", &self.seq_id)
.field("runtime_id", &self.runtime_id)
.field("metrics_flush_interval", &self.metrics_flush_interval)
.field("deadlines", &self.deadlines)
.field("data", &self.data)
.finish()
Expand Down Expand Up @@ -595,7 +597,7 @@ impl TelemetryWorker {
},
common: context.common,
_type: context.metric_type,
interval: MetricBuckets::METRICS_FLUSH_INTERVAL.as_secs(),
interval: self.metrics_flush_interval.as_secs(),
});
}
data::Distributions { series }
Expand All @@ -619,7 +621,7 @@ impl TelemetryWorker {
points,
common: context.common,
_type: context.metric_type,
interval: MetricBuckets::METRICS_FLUSH_INTERVAL.as_secs(),
interval: self.metrics_flush_interval.as_secs(),
});
}

Expand Down Expand Up @@ -1087,6 +1089,9 @@ impl TelemetryWorkerBuilder {
let telemetry_heartbeat_interval = config.telemetry_heartbeat_interval;
let client = http_client::from_config(&config);

let metrics_flush_interval =
telemetry_heartbeat_interval.min(MetricBuckets::METRICS_FLUSH_INTERVAL);

#[allow(clippy::unwrap_used)]
let worker = TelemetryWorker {
flavor: self.flavor,
Expand All @@ -1108,11 +1113,9 @@ impl TelemetryWorkerBuilder {
.runtime_id
.unwrap_or_else(|| uuid::Uuid::new_v4().to_string()),
client,
metrics_flush_interval,
deadlines: scheduler::Scheduler::new(vec![
(
MetricBuckets::METRICS_FLUSH_INTERVAL,
LifecycleAction::FlushMetricAggr,
),
(metrics_flush_interval, LifecycleAction::FlushMetricAggr),
(telemetry_heartbeat_interval, LifecycleAction::FlushData),
(
time::Duration::from_secs(60 * 60 * 24),
Expand Down
Loading