Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ellie committed Nov 21, 2023
1 parent 3a41c02 commit 16af34f
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions capture/src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use time::OffsetDateTime;
use tracing::instrument;

use crate::billing_limits::QuotaResource;
use crate::event::{ProcessingContext, Compression};
use crate::event::{Compression, ProcessingContext};
use crate::prometheus::report_dropped_events;
use crate::token::validate_token;
use crate::{
Expand All @@ -26,7 +26,18 @@ use crate::{
utils::uuid_v7,
};

#[instrument(skip_all, fields(token, batch_size, user_agent, content_encoding, content_type, version, compression))]
#[instrument(
skip_all,
fields(
token,
batch_size,
user_agent,
content_encoding,
content_type,
version,
compression
)
)]
pub async fn event(
state: State<router::State>,
InsecureClientIp(ip): InsecureClientIp,
Expand All @@ -37,8 +48,12 @@ pub async fn event(
// content-type
// user-agent

let user_agent = headers.get("user_agent").map_or("unknown", |v|v.to_str().unwrap_or("unknown"));
let content_encoding = headers.get("content_encoding").map_or("unknown", |v|v.to_str().unwrap_or("unknown"));
let user_agent = headers
.get("user_agent")
.map_or("unknown", |v| v.to_str().unwrap_or("unknown"));
let content_encoding = headers
.get("content_encoding")
.map_or("unknown", |v| v.to_str().unwrap_or("unknown"));

tracing::Span::current().record("user_agent", user_agent);
tracing::Span::current().record("content_encoding", content_encoding);
Expand All @@ -59,21 +74,20 @@ pub async fn event(
ct => {
tracing::Span::current().record("content_type", ct);

RawEvent::from_bytes(&meta, body)
},
RawEvent::from_bytes(&meta, body)
}
}?;

let comp = match meta.compression {
None => String::from("unknown"),
Some(Compression::Gzip)=> String::from("gzip"),
Some(Compression::Unsupported)=> String::from("unsupported"),
Some(Compression::Gzip) => String::from("gzip"),
Some(Compression::Unsupported) => String::from("unsupported"),
};

tracing::Span::current().record("batch_size", events.len());
tracing::Span::current().record("version", meta.lib_version.clone());
tracing::Span::current().record("compression", comp.as_str());


if events.is_empty() {
return Err(CaptureError::EmptyBatch);
}
Expand Down

0 comments on commit 16af34f

Please sign in to comment.