Skip to content

Commit

Permalink
fix fields not preserved
Browse files Browse the repository at this point in the history
  • Loading branch information
bragov4ik committed Aug 15, 2024
1 parent aa6a4a5 commit c14935b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libs/blockscout-service-launcher/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blockscout-service-launcher"
version = "0.13.0"
version = "0.13.1"
description = "Allows to launch blazingly fast blockscout rust services"
license = "MIT"
repository = "https://github.com/blockscout/blockscout-rs"
Expand Down
15 changes: 13 additions & 2 deletions libs/blockscout-service-launcher/src/tracing/request_id_layer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{fmt::Debug, str::FromStr};
use tracing::{field::Field, span::Attributes, Id, Subscriber};
use tracing_subscriber::{
fmt::{format::JsonFields, FormattedFields},
fmt::{format::JsonFields, FormatFields, FormattedFields},
layer::Context,
registry::LookupSpan,
Layer,
Expand Down Expand Up @@ -29,7 +29,18 @@ impl<S: Subscriber + for<'lookup> LookupSpan<'lookup>> Layer<S> for RequestIdSto
.get_mut::<FormattedFields<JsonFields>>()
.is_none()
{
extensions.insert(FormattedFields::<JsonFields>::new("{}".to_string()));
let mut fields = FormattedFields::<JsonFields>::new(String::new());
if JsonFields::new()
.format_fields(fields.as_writer(), attrs)
.is_ok()
{
extensions.insert(fields);
} else {
eprintln!(
"[tracing-subscriber] Unable to format the following event, ignoring: {:?}",
attrs
);
}
}
let data = extensions.get_mut::<FormattedFields<JsonFields>>().unwrap();
if let Some(request_id) = request_id {
Expand Down

0 comments on commit c14935b

Please sign in to comment.