mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-27 10:20:38 +00:00
feat: make empty parent_span_id null for v1 (#5690)
This commit is contained in:
@@ -32,22 +32,22 @@ pub struct TraceSpan {
|
||||
pub service_name: Option<String>,
|
||||
pub trace_id: String,
|
||||
pub span_id: String,
|
||||
pub parent_span_id: String,
|
||||
pub parent_span_id: Option<String>,
|
||||
|
||||
// the following are fields
|
||||
pub resource_attributes: Attributes, // TODO(yuanbohan): Map in the future
|
||||
pub resource_attributes: Attributes,
|
||||
pub scope_name: String,
|
||||
pub scope_version: String,
|
||||
pub scope_attributes: Attributes, // TODO(yuanbohan): Map in the future
|
||||
pub scope_attributes: Attributes,
|
||||
pub trace_state: String,
|
||||
pub span_name: String,
|
||||
pub span_kind: String,
|
||||
pub span_status_code: String,
|
||||
pub span_status_message: String,
|
||||
pub span_attributes: Attributes, // TODO(yuanbohan): Map in the future
|
||||
pub span_events: SpanEvents, // TODO(yuanbohan): List in the future
|
||||
pub span_links: SpanLinks, // TODO(yuanbohan): List in the future
|
||||
pub start_in_nanosecond: u64, // this is also the Timestamp Index
|
||||
pub span_attributes: Attributes,
|
||||
pub span_events: SpanEvents, // TODO(yuanbohan): List in the future
|
||||
pub span_links: SpanLinks, // TODO(yuanbohan): List in the future
|
||||
pub start_in_nanosecond: u64, // this is also the Timestamp Index
|
||||
pub end_in_nanosecond: u64,
|
||||
}
|
||||
|
||||
@@ -203,7 +203,11 @@ pub fn parse_span(
|
||||
service_name,
|
||||
trace_id: bytes_to_hex_string(&span.trace_id),
|
||||
span_id: bytes_to_hex_string(&span.span_id),
|
||||
parent_span_id: bytes_to_hex_string(&span.parent_span_id),
|
||||
parent_span_id: if span.parent_span_id.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(bytes_to_hex_string(&span.parent_span_id))
|
||||
},
|
||||
|
||||
resource_attributes: Attributes::from(resource_attrs),
|
||||
trace_state: span.trace_state,
|
||||
|
||||
@@ -91,7 +91,10 @@ pub fn write_span_to_row(writer: &mut TableData, span: TraceSpan) -> Result<()>
|
||||
let iter = vec![
|
||||
(TRACE_ID_COLUMN, span.trace_id),
|
||||
(SPAN_ID_COLUMN, span.span_id),
|
||||
(PARENT_SPAN_ID_COLUMN, span.parent_span_id),
|
||||
(
|
||||
PARENT_SPAN_ID_COLUMN,
|
||||
span.parent_span_id.unwrap_or_default(),
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(col, val)| (col.to_string(), val));
|
||||
|
||||
@@ -103,8 +103,18 @@ pub fn write_span_to_row(writer: &mut TableData, span: TraceSpan) -> Result<()>
|
||||
row_writer::write_tags(writer, tags.into_iter(), &mut row)?;
|
||||
|
||||
// write fields
|
||||
if let Some(parent_span_id) = span.parent_span_id {
|
||||
row_writer::write_fields(
|
||||
writer,
|
||||
std::iter::once(make_string_column_data(
|
||||
PARENT_SPAN_ID_COLUMN,
|
||||
parent_span_id,
|
||||
)),
|
||||
&mut row,
|
||||
)?;
|
||||
}
|
||||
|
||||
let fields = vec![
|
||||
make_string_column_data(PARENT_SPAN_ID_COLUMN, span.parent_span_id),
|
||||
make_string_column_data(SPAN_KIND_COLUMN, span.span_kind),
|
||||
make_string_column_data(SPAN_NAME_COLUMN, span.span_name),
|
||||
make_string_column_data("span_status_code", span.span_status_code),
|
||||
|
||||
Reference in New Issue
Block a user