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]]
name = "rmp-ipc"
version = "0.7.1"
version = "0.7.2"
dependencies = [
"criterion",
"lazy_static",

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

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

@ -54,7 +54,7 @@ impl EventHandler {
}
/// 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<()> {
if let Some(cb) = self.callbacks.get(event.name()) {
cb.as_ref()(ctx, event).await?;

@ -20,7 +20,12 @@ async fn handle_connection(
ctx: Context,
) {
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
if let Some(ref_id) = event.reference_id() {
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>(
&self,
namespace: Option<&str>,
@ -116,6 +116,7 @@ impl EmitMetadata {
}
/// 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> {
let reply = ctx.await_reply(self.message_id).await?;
Ok(reply)

Loading…
Cancel
Save