use chrono::{DateTime, Utc};
use opentelemetry::trace::TraceContextExt;
use opentelemetry::{Context, Key, KeyValue};
pub struct CurrentSpan;
impl CurrentSpan {
pub fn set_attribute(name: &Key, value: &str) {
Context::current()
.span()
.set_attribute(KeyValue::new(name.clone(), value.to_string()));
}
pub fn set_attribute_time(name: &Key) {
let current_utc: DateTime<Utc> = Utc::now();
let formatted_time: String = current_utc.format("%Y-%m-%dT%H:%M:%S.%3f").to_string();
CurrentSpan::set_attribute(name, &formatted_time)
}
}