use std::num::NonZeroU64;
pub use opentelemetry_semantic_conventions::*;
use tracing::Span;
pub const ATT_CID: &str = "clickhouse.client.id";
pub const ATT_CON: &str = "clickhouse.connection.id";
pub const ATT_CREQ: &str = "clickhouse.client.request";
pub const ATT_QID: &str = "clickhouse.query.id";
pub const ATT_PCOUNT: &str = "clickhouse.packet.count";
pub const ATT_PID: &str = "clickhouse.packet.id";
pub const ATT_MSGTYPE: &str = "clickhouse.message.type";
pub const ATT_FIELD_NAME: &str = "clickhouse.field.name";
pub const ATT_FIELD_TYPE: &str = "clickhouse.field.type";
#[derive(Clone, Copy, Default, Debug, PartialEq)]
pub struct TraceContext(Option<NonZeroU64>);
impl TraceContext {
pub(super) fn link(&self, span: &Span) -> &Self {
let _ = span.follows_from(self.get_id());
self
}
pub(super) fn get_id(self) -> Option<tracing::span::Id> {
self.0.map(tracing::span::Id::from_non_zero_u64)
}
}
impl From<NonZeroU64> for TraceContext {
fn from(id: NonZeroU64) -> Self { Self(Some(id)) }
}
impl From<Option<NonZeroU64>> for TraceContext {
fn from(id: Option<NonZeroU64>) -> Self { Self(id) }
}