Merge pull request #15 from Trivernis/develop

Remove tracing of events to avoid spam and low performance
pull/24/head
Julius Riegel 3 years ago committed by GitHub
commit 354b389a38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

2
Cargo.lock generated

@ -500,7 +500,7 @@ dependencies = [
[[package]] [[package]]
name = "rmp-ipc" name = "rmp-ipc"
version = "0.7.1" version = "0.7.2"
dependencies = [ dependencies = [
"criterion", "criterion",
"lazy_static", "lazy_static",

@ -1,6 +1,6 @@
[package] [package]
name = "rmp-ipc" name = "rmp-ipc"
version = "0.7.1" version = "0.7.2"
authors = ["trivernis <trivernis@protonmail.com>"] authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018" edition = "2018"
readme = "README.md" readme = "README.md"

@ -24,7 +24,7 @@ struct EventHeader {
impl Event { impl Event {
/// Creates a new event with a namespace /// Creates a new event with a namespace
#[tracing::instrument(level = "trace")] #[tracing::instrument(level = "trace", skip(data))]
pub fn with_namespace( pub fn with_namespace(
namespace: String, namespace: String,
name: String, name: String,
@ -41,7 +41,7 @@ impl Event {
} }
/// Creates a new event /// Creates a new event
#[tracing::instrument(level = "trace")] #[tracing::instrument(level = "trace", skip(data))]
pub fn new(name: String, data: Vec<u8>, ref_id: Option<u64>) -> Self { pub fn new(name: String, data: Vec<u8>, ref_id: Option<u64>) -> Self {
let header = EventHeader { let header = EventHeader {
id: generate_event_id(), id: generate_event_id(),
@ -107,7 +107,7 @@ impl Event {
} }
/// Encodes the event into bytes /// Encodes the event into bytes
#[tracing::instrument(level = "trace")] #[tracing::instrument(level = "trace", skip(self))]
pub fn into_bytes(mut self) -> Result<Vec<u8>> { pub fn into_bytes(mut self) -> Result<Vec<u8>> {
let mut header_bytes = rmp_serde::to_vec(&self.header)?; let mut header_bytes = rmp_serde::to_vec(&self.header)?;
let header_length = header_bytes.len() as u16; let header_length = header_bytes.len() as u16;

@ -54,7 +54,7 @@ impl EventHandler {
} }
/// Handles a received event /// Handles a received event
#[tracing::instrument(level = "debug", skip(self, ctx))] #[tracing::instrument(level = "debug", skip(self, ctx, event))]
pub async fn handle_event(&self, ctx: &Context, event: Event) -> Result<()> { pub async fn handle_event(&self, ctx: &Context, event: Event) -> Result<()> {
if let Some(cb) = self.callbacks.get(event.name()) { if let Some(cb) = self.callbacks.get(event.name()) {
cb.as_ref()(ctx, event).await?; cb.as_ref()(ctx, event).await?;

@ -20,7 +20,12 @@ async fn handle_connection(
ctx: Context, ctx: Context,
) { ) {
while let Ok(event) = Event::from_async_read(&mut read_half).await { while let Ok(event) = Event::from_async_read(&mut read_half).await {
tracing::trace!("event = {:?}", event); tracing::trace!(
"event.name = {:?}, event.namespace = {:?}, event.reference_id = {:?}",
event.name(),
event.namespace(),
event.reference_id()
);
// check if the event is a reply // check if the event is a reply
if let Some(ref_id) = event.reference_id() { if let Some(ref_id) = event.reference_id() {
tracing::trace!("Event has reference id. Passing to reply listener"); tracing::trace!("Event has reference id. Passing to reply listener");

@ -23,7 +23,7 @@ impl StreamEmitter {
} }
} }
#[tracing::instrument(level = "trace", skip(self))] #[tracing::instrument(level = "trace", skip(self, data))]
pub async fn _emit<T: EventSendPayload + Debug>( pub async fn _emit<T: EventSendPayload + Debug>(
&self, &self,
namespace: Option<&str>, namespace: Option<&str>,
@ -116,6 +116,7 @@ impl EmitMetadata {
} }
/// Waits for a reply to the given message. /// Waits for a reply to the given message.
#[tracing::instrument(skip(self, ctx), fields(self.message_id))]
pub async fn await_reply(&self, ctx: &Context) -> Result<Event> { pub async fn await_reply(&self, ctx: &Context) -> Result<Event> {
let reply = ctx.await_reply(self.message_id).await?; let reply = ctx.await_reply(self.message_id).await?;
Ok(reply) Ok(reply)

Loading…
Cancel
Save