Skip to content

AttributePropagatingSpanProcessor doesn't accept non-Readable spans #743

Description

@zhongkechen

Hi,

I'm encountering an error when creating an Otel span with ADOT

elif parent_span and _is_server_kind(parent_span):
propagation_data = self._propagation_data_extractor(parent_span)

When the parent_span isn't a ReadableSpan (e.g. a NonRecordingSpan), _is_server_kind would throw an attribute exception because the other types of span may not have the kind attribute.

My use case:

I'm using NonRecordingSpan to create a parent span placeholder, which will be filled later

        context = SpanContext(
            trace_id=self._id_generator.generate_trace_id(),
            span_id=operation_id_to_span_id(parent_id),
            is_remote=False,
        )
        placeholder_span = NonRecordingSpan(context)

        parent_context = trace.set_span_in_context(
                placeholder_span, self._extracted_context
            )

        span = self._tracer.start_span(
            name=name,
            attributes=attributes,
            start_time=_to_otel_timestamp(start_time),
            context=parent_context,
        )

My workaround is to add the expected attributes to the NonRecordingSpan I created above:

        placeholder_span.kind = SpanKind.INTERNAL
        placeholder_span.attributes = {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions