def test_non_soda_span_filtering(): spans_input = [ ReadableSpan(name="test_1"), ReadableSpan(name="soda_test_span"), ReadableSpan(name="test_2"), ] spans_output = get_soda_spans(spans_input) assert len(spans_output) == 1 assert spans_output[0].name == "soda_test_span"
def _translate_span(self, span: ReadableSpan) -> model_pb2.Span: ctx = span.get_span_context() # pb2 span expects in byte format trace_id = _trace_id_to_bytes(ctx.trace_id) span_id = _span_id_to_bytes(ctx.span_id) start_time = _proto_timestamp_from_epoch_nanos(span.start_time) end_time = _proto_timestamp_from_epoch_nanos(span.end_time) duration = _duration_from_two_time_stamps(start_time, end_time) tags = self._extract_tags(span) refs = self._extract_refs(span) logs = self._extract_logs(span) flags = int(ctx.trace_flags) process = model_pb2.Process( service_name=self.svc_name, tags=_extract_resource_tags(span, self._max_tag_value_length), ) jaeger_span = model_pb2.Span( trace_id=trace_id, span_id=span_id, operation_name=span.name, references=refs, flags=flags, start_time=start_time, duration=duration, tags=tags, logs=logs, process=process, ) return jaeger_span
def _translate_span(self, span: ReadableSpan) -> TCollector.Span: ctx = span.get_span_context() trace_id = ctx.trace_id span_id = ctx.span_id start_time_us = _nsec_to_usec_round(span.start_time) duration_us = _nsec_to_usec_round(span.end_time - span.start_time) parent_id = span.parent.span_id if span.parent else 0 tags = self._extract_tags(span) refs = self._extract_refs(span) logs = self._extract_logs(span) flags = int(ctx.trace_flags) jaeger_span = TCollector.Span( traceIdHigh=_get_trace_id_high(trace_id), traceIdLow=_get_trace_id_low(trace_id), spanId=_convert_int_to_i64(span_id), operationName=span.name, startTime=start_time_us, duration=duration_us, tags=tags, logs=logs, references=refs, flags=flags, parentSpanId=_convert_int_to_i64(parent_id), ) return jaeger_span
def _extract_refs( self, span: ReadableSpan ) -> Optional[Sequence[model_pb2.SpanRef]]: refs = [] if span.parent: ctx = span.get_span_context() parent_id = span.parent.span_id parent_ref = model_pb2.SpanRef( ref_type=model_pb2.SpanRefType.CHILD_OF, trace_id=_trace_id_to_bytes(ctx.trace_id), span_id=_span_id_to_bytes(parent_id), ) refs.append(parent_ref) for link in span.links: trace_id = link.context.trace_id span_id = link.context.span_id refs.append( model_pb2.SpanRef( ref_type=model_pb2.SpanRefType.FOLLOWS_FROM, trace_id=_trace_id_to_bytes(trace_id), span_id=_span_id_to_bytes(span_id), ) ) return refs