Skip to content

Commit

Permalink
feat(dd): flush if size is above threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
robertohuertasm committed Sep 20, 2023
1 parent 87d8ec4 commit 1fe5787
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[workspace]
members = [
"log-tracing-layer",
"dd-tracing-layer",
]

resolver = "2"
members = ["log-tracing-layer", "dd-tracing-layer"]
10 changes: 5 additions & 5 deletions dd-tracing-layer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dd-tracing-layer"
version = "0.1.3"
version = "0.1.4"
authors = ["Roberto Huertas <[email protected]>"]
description = "Send your logs to Datadog"
edition = "2021"
Expand All @@ -16,15 +16,15 @@ maintenance = { status = "actively-developed" }

[dependencies]
log-tracing-layer = { path = "../log-tracing-layer", version = "0.1.3" }
tracing-subscriber = "0.3"
tracing-subscriber = "0.3"
tracing = "0.1"
reqwest = { version = "0.11.14", features = ["blocking", "json"] }
reqwest = { version = "0.11", features = ["blocking", "json"] }
tokio = { version = "1", features = ["sync", "rt-multi-thread", "time"] }
serde_json = "1"
chrono = "0.4"
async-trait = "0.1"
async-recursion = "1.0"

[dev-dependencies]
tracing-subscriber = { version = "0.3.16", features = ["json", "registry"] }
httpmock = "0.6.7"
tracing-subscriber = { version = "0.3", features = ["json", "registry"] }
httpmock = "0.6.8"
6 changes: 5 additions & 1 deletion dd-tracing-layer/src/datadog_ingestor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{collections::VecDeque, sync::Arc};
use tokio::sync::RwLock;

const DD_SOURCE: &str = "dd-tracing-layer";
const DD_TAGS: &str = "version:0.1.3";
const DD_TAGS: &str = "source-version:0.1.4";
const MAX_BATCH_SIZE: usize = 1000;
const MAX_BATCH_DURATION_SECS: i64 = 5;
const MAX_RETRIES: u8 = 3;
Expand Down Expand Up @@ -173,6 +173,10 @@ impl DatadogLogIngestor {
}
if !is_flush {
// send the logs only if the last one is more than 5 seconds old
// or if the queue has more than MAX_BATCH_SIZE logs
if queue.len() < MAX_BATCH_SIZE {
return;
}
let last_log = queue.back().unwrap();
let now = Utc::now();
let diff = now - last_log.received_at;
Expand Down
5 changes: 2 additions & 3 deletions log-tracing-layer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "log-tracing-layer"
version = "0.1.3"
version = "0.1.4"
authors = ["Roberto Huertas <[email protected]>"]
description = "Build your own custom tracing layer."
edition = "2021"
Expand All @@ -15,11 +15,10 @@ maintenance = { status = "actively-developed" }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tracing-subscriber = "0.3"
tracing-subscriber = "0.3"
tracing = "0.1"
tokio = { version = "1", features = ["sync", "rt-multi-thread", "time"] }
serde_json = "1"
chrono = "0.4"
async-trait = "0.1"
log = "0.4"

0 comments on commit 1fe5787

Please sign in to comment.