feat: add relevant ids for payment calls & make json logs (#908)

This commit is contained in:
Nishant Joshi
2023-04-21 02:51:47 +05:30
committed by GitHub
parent 1f151ba15a
commit 93b69e74b4
5 changed files with 34 additions and 10 deletions

View File

@ -40,3 +40,4 @@ default = ["actix_web"]
actix_web = ["tracing-actix-web"]
log_custom_entries_to_extra = []
log_extra_implicit_fields = []
log_active_span_json = []

View File

@ -13,7 +13,7 @@ use serde::ser::{SerializeMap, Serializer};
use serde_json::Value;
// use time::format_description::well_known::Rfc3339;
use time::format_description::well_known::Iso8601;
use tracing::{Event, Id, Metadata, Subscriber};
use tracing::{Event, Metadata, Subscriber};
use tracing_subscriber::{
fmt::MakeWriter,
layer::Context,
@ -282,6 +282,7 @@ where
}
/// Serialize entries of span.
#[cfg(feature = "log_active_span_json")]
fn span_serialize<S>(
&self,
span: &SpanRef<'_, S>,
@ -407,14 +408,16 @@ where
}
}
fn on_enter(&self, id: &Id, ctx: Context<'_, S>) {
#[cfg(feature = "log_active_span_json")]
fn on_enter(&self, id: &tracing::Id, ctx: Context<'_, S>) {
let span = ctx.span(id).expect("No span");
if let Ok(serialized) = self.span_serialize(&span, RecordType::EnterSpan) {
let _ = self.flush(serialized);
}
}
fn on_close(&self, id: Id, ctx: Context<'_, S>) {
#[cfg(feature = "log_active_span_json")]
fn on_close(&self, id: tracing::Id, ctx: Context<'_, S>) {
let span = ctx.span(&id).expect("No span");
if let Ok(serialized) = self.span_serialize(&span, RecordType::ExitSpan) {
let _ = self.flush(serialized);