Skip to content

Commit

Permalink
added more verbose logging (#5619)
Browse files Browse the repository at this point in the history
* added more verbose logging

* added empty query log test

* removed tests and returns error instead of just printing it

* fix rust linting

* returns error

---------

Co-authored-by: Rachel Chen <[email protected]>
  • Loading branch information
xurui-c and Rachel Chen authored Mar 5, 2024
1 parent db474d4 commit faed762
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rust_snuba/src/processors/querylog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use serde::{ser::Error, Deserialize, Serialize, Serializer};
use serde_json::Value;
use uuid::Uuid;

use crate::processors::utils;

use crate::types::{InsertBatch, KafkaMessageMetadata};

pub fn process_message(
Expand All @@ -17,6 +19,7 @@ pub fn process_message(
_config: &ProcessorConfig,
) -> anyhow::Result<InsertBatch> {
let payload_bytes = payload.payload().context("Expected payload")?;
let _: FromQuerylogMessage = utils::from_slice(payload_bytes)?;
let from: FromQuerylogMessage = serde_json::from_slice(payload_bytes)?;

let querylog_msg = QuerylogMessage {
Expand Down
7 changes: 7 additions & 0 deletions rust_snuba/src/processors/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ pub struct StringToIntDatetime(
#[schemars(with = "String")]
pub u32,
);

pub fn from_slice<'a, T: Deserialize<'a>>(
payload: &'a [u8],
) -> Result<T, serde_path_to_error::Error<serde_json::Error>> {
let jd = &mut serde_json::Deserializer::from_slice(payload);
serde_path_to_error::deserialize(jd)
}

0 comments on commit faed762

Please sign in to comment.