Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
35 changes: 35 additions & 0 deletions bottlecap/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bottlecap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ rmp-serde = { version = "1.3.0", default-features = false }
rustls = { version = "0.23.18", default-features = false, features = ["aws-lc-rs"] }
rand = { version = "0.8", default-features = false }
prost = { version = "0.11.6", default-features = false }
zstd = { version = "0.13.2", default-features = false }

[dev-dependencies]
figment = { version = "0.10", default-features = false, features = ["yaml", "env", "test"] }
Expand Down
12 changes: 10 additions & 2 deletions bottlecap/src/logs/flusher.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use crate::config;
use crate::http_client;
use crate::logs::aggregator::Aggregator;
use std::sync::{Arc, Mutex};
use std::{
io::Write,
sync::{Arc, Mutex},
};
use tokio::task::JoinSet;
use tracing::{debug, error};
use zstd::stream::write::Encoder;

pub struct Flusher {
api_key: String,
Expand Down Expand Up @@ -59,14 +63,18 @@ impl Flusher {

async fn send(client: reqwest::Client, api_key: String, fqdn: String, data: Vec<u8>) {
let url = format!("{fqdn}/api/v2/logs");
let mut encoder = Encoder::new(Vec::new(), 0).unwrap();
encoder.write_all(&data).unwrap();
let body = encoder.finish().unwrap();

if !data.is_empty() {
let resp: Result<reqwest::Response, reqwest::Error> = client
.post(&url)
.header("DD-API-KEY", api_key)
.header("DD-PROTOCOL", "agent-json")
.header("Content-Type", "application/json")
.body(data)
.header("Content-Encoding", "zstd")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add an option to enable/disable decompression?
It might be needed for audit or other user side application

.body(body)
.send()
.await;

Expand Down
Loading