clickhouse_arrow/
telemetry.rs1use std::num::NonZeroU64;
15
16pub use opentelemetry_semantic_conventions::*;
17use tracing::Span;
18
19pub const ATT_CID: &str = "clickhouse.client.id";
21pub const ATT_CON: &str = "clickhouse.connection.id";
22pub const ATT_CREQ: &str = "clickhouse.client.request";
23pub const ATT_QID: &str = "clickhouse.query.id";
24pub const ATT_PCOUNT: &str = "clickhouse.packet.count";
25pub const ATT_PID: &str = "clickhouse.packet.id";
26pub const ATT_MSGTYPE: &str = "clickhouse.message.type";
27pub const ATT_FIELD_NAME: &str = "clickhouse.field.name";
28pub const ATT_FIELD_TYPE: &str = "clickhouse.field.type";
29
30#[derive(Clone, Copy, Default, Debug, PartialEq)]
34pub struct TraceContext(Option<NonZeroU64>);
35
36impl TraceContext {
37 pub(super) fn link(&self, span: &Span) -> &Self {
38 let _ = span.follows_from(self.get_id());
39 self
40 }
41
42 pub(super) fn get_id(self) -> Option<tracing::span::Id> {
43 self.0.map(tracing::span::Id::from_non_zero_u64)
44 }
45}
46
47impl From<NonZeroU64> for TraceContext {
48 fn from(id: NonZeroU64) -> Self { Self(Some(id)) }
49}
50
51impl From<Option<NonZeroU64>> for TraceContext {
52 fn from(id: Option<NonZeroU64>) -> Self { Self(id) }
53}