@@ -121,13 +121,14 @@ def get_log_data(self, span: Span, attributes: dict[str, str]) -> LogData:
121
121
instrumentation_scope = span .instrumentation_scope if hasattr (span ,
122
122
"instrumentation_scope" ) else None
123
123
span_context = span .get_span_context ()
124
+ parent = span .parent
124
125
125
126
enc_spans = encode_spans ([span ]).resource_spans
126
127
traces_data = trace_pb2 .TracesData ()
127
128
traces_data .resource_spans .extend (enc_spans )
128
129
serialized_traces_data = json_format .MessageToJson (traces_data )
129
130
130
- # FIXME/HACK replace serialized traceId and spanId values as string comparison
131
+ # FIXME/HACK replace serialized traceId, spanId, and parentSpanId (if present) values as string comparison
131
132
# possible issue is when there are multiple spans in the same trace.
132
133
# currently that should not be the case.
133
134
# trace_id and span_id are stored as int.
@@ -139,7 +140,10 @@ def get_log_data(self, span: Span, attributes: dict[str, str]) -> LogData:
139
140
for span in scope_span .get ("spans" , []):
140
141
span ["traceId" ] = hex (span_context .trace_id )[2 :]
141
142
span ["spanId" ] = hex (span_context .span_id )[2 :]
142
- serialized_traces_data = json .dumps (traces_dict , separators = (',' , ':' ))
143
+ if parent :
144
+ span ["parentSpanId" ] = hex (parent .span_id )[2 :]
145
+
146
+ serialized_traces_data = json .dumps (traces_dict , separators = ("," , ":" ))
143
147
144
148
log_record = LogRecord (
145
149
timestamp = time .time_ns (),
0 commit comments