log: Make the ES flush interval configurable
@@ -5,6 +5,14 @@ use crate::log::elastic::*;
use crate::log::split::*;
use slog::*;
+lazy_static::lazy_static! {
+ static ref ES_FLUSH_INTERVAL: Duration =
+ Duration::from_secs(std::env::var("GRAPH_ELASTIC_SEARCH_FLUSH_INTERVAL_SECS")
+ .unwrap_or("5".into())
+ .parse::<u64>()
+ .expect("invalid GRAPH_ELASTIC_SEARCH_FLUSH_INTERVAL_SECS"));
+}
+
/// Configuration for component-specific logging to Elasticsearch.
pub struct ElasticComponentLoggerConfig {
pub index: String,
@@ -64,7 +72,7 @@ impl LoggerFactory {
document_type: String::from("log"),
custom_id_key: String::from("componentId"),
custom_id_value: component.to_string(),
- flush_interval: Duration::from_secs(5),
+ flush_interval: *ES_FLUSH_INTERVAL,
},
term_logger.clone(),
),
@@ -93,7 +101,7 @@ impl LoggerFactory {
document_type: String::from("log"),
custom_id_key: String::from("subgraphId"),
custom_id_value: loc.hash.to_string(),
- flush_interval: Duration::from_secs(5),
+ flush_interval: *ES_FLUSH_INTERVAL,
},
term_logger.clone(),
),
