Skip to content

🐛 Bug Report: exporter is ignored when processor is also defined in Traceloop.init() #3046

Open
@ronensc

Description

@ronensc

Which component is this bug for?

Traceloop SDK

📜 Description

When both a custom SpanProcessor and SpanExporter are passed to Traceloop.init(), the exporter is silently ignored. This leads to unexpected behavior: the processor is invoked, but the exporter is never called.

👟 Reproduction steps

  1. Create a fresh virtual environment.
  2. Install the SDK
pip install traceloop-sdk==0.40.14
  1. Run the following code:
from typing import Sequence
from opentelemetry.sdk.trace import ReadableSpan
from opentelemetry.sdk.trace.export import SpanExporter, SpanProcessor, SpanExportResult
from opentelemetry.trace import Span
from traceloop.sdk import Traceloop
from traceloop.sdk.decorators import workflow


class MySpanProcessor(SpanProcessor):
    def __init__(self):
        self.call_count = 0

    def on_start(self, span: Span, parent_context):
        self.call_count += 1
        print("MySpanProcessor")


class MySpanExporter(SpanExporter):
    def __init__(self):
        self.call_count = 0

    def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
        self.call_count += 1
        print("MySpanExporter")
        return SpanExportResult.SUCCESS


@workflow()
def run_workflow():
    pass


my_proc = MySpanProcessor()
my_export = MySpanExporter()
Traceloop.init(processor=my_proc, exporter=my_export)

run_workflow()

assert my_proc.call_count > 0, "Expected MySpanProcessor to be called"
assert my_export.call_count > 0, "Expected MySpanExporter to be called"
  1. Observe that the second assert fails:
AssertionError: Expected MySpanExporter to be called

👍 Expected behavior

  • Either support combining a custom processor and exporter by internally wiring them,

    or

  • Raise an error or warning when both are provided to avoid confusion.

👎 Actual Behavior with Screenshots

See Reproduction steps

🤖 Python Version

No response

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

Are you willing to submit PR?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions