pub trait AttributeMapper:
Send
+ Sync
+ 'static {
// Required method
fn map(&self, span_name: &str, name: Cow<'static, str>) -> Cow<'static, str>;
}
Expand description
Map span attributes name to ECS field name
§Trait implementations
This trait is implemented on HashMap<String, String>
and HashMap<&'static str, &'static str>
to allow a direct mapping from a map.
Example
use tracing_ecs::ECSLayerBuilder;
use maplit::hashmap;
ECSLayerBuilder::default()
.with_attribute_mapper(hashmap!(
"txid" => "transaction.id",
"request_ip" => "source.ip",
)).stdout().install().unwrap();
It is also implemented on HashMap<String, HashMap<String, String>>
and
HashMap<&'static str, HashMap<&'static str, &'static str>>
. In this case, the first map level
maps span names and the second attribute names.
Example
use tracing_ecs::ECSLayerBuilder;
use maplit::hashmap;
ECSLayerBuilder::default()
.with_attribute_mapper(hashmap!(
"request" => hashmap!(
"method" => "http.request.method",
"request_ip" => "source.ip",
),
"cron" => hashmap!(
"request_ip" => "cron.source.ip",
),
)).stdout().install().unwrap();