-
Notifications
You must be signed in to change notification settings - Fork 837
Description
Which component is this bug for?
Traceloop SDK
π Description
When using traceloop-sdk with Instana and/or OpenTelemetry, the integration fails due to an AttributeError. The error appears when starting new spans and ending them with the BatchSpanProcessor from instana/opentelemetry-sdk. The relevant error message is:
AttributeError: 'BatchSpanProcessor' object has no attribute 'record_span'
This prevents spans from being properly recorded and exported, making tracing with Instana not possible using the provided setup.
π Reproduction steps
- Install the following packages:
- traceloop-sdk==0.47.3
- instana==3.9.0
- opentelemetry-api==1.38.0
- opentelemetry-sdk==1.38.0
- opentelemetry-exporter-otlp-proto-http==1.38.0
- Use the script below to initialize tracing and send traces to Instana (see 'Script used' section).
- Run the script.
- Observe the error in the logs:
AttributeError: 'BatchSpanProcessor' object has no attribute 'record_span'
π Expected behavior
Spans should be properly started and ended, and tracing data should be exported to Instana without error. Instana and OpenTelemetry should seamlessly work together with traceloop-sdk.
π Actual Behavior with Screenshots
The following error is thrown when attempting to end a span:
AttributeError: 'BatchSpanProcessor' object has no attribute 'record_span'
Full traceback:
WARNING:opentelemetry.trace:Overriding of current TracerProvider is not allowed
INFO:__main__:Auth operation completed
Traceback (most recent call last):
File "/tmp/.venv/lib/python3.12/site-packages/opentelemetry/trace/__init__.py", line 589, in use_span
yield span
File "/tmp/.venv/lib/python3.12/site-packages/instana/tracer.py", line 175, in start_as_current_span
yield span
File "/tmp/./traceloop_test.py", line 73, in main
with tracer.start_as_current_span("auth_operation") as auth_span:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/contextlib.py", line 144, in __exit__
next(self.gen)
File "/tmp/.venv/lib/python3.12/site-packages/instana/tracer.py", line 169, in start_as_current_span
with use_span(
^^^^^^^^^
File "/usr/local/lib/python3.12/contextlib.py", line 144, in __exit__
next(self.gen)
File "/tmp/.venv/lib/python3.12/site-packages/opentelemetry/trace/__init__.py", line 619, in use_span
span.end()
File "/tmp/.venv/lib/python3.12/site-packages/instana/span/span.py", line 200, in end
self._span_processor.record_span(self._readable_span())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'BatchSpanProcessor' object has no attribute 'record_span'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/./traceloop_test.py", line 93, in <module>
main()
File "/tmp/./traceloop_test.py", line 68, in main
with tracer.start_as_current_span("test_banking_workflow") as span:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
self.gen.throw(value)
File "/tmp/.venv/lib/python3.12/site-packages/instana/tracer.py", line 169, in start_as_current_span
with use_span(
^^^^^^^^^
File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
self.gen.throw(value)
File "/tmp/.venv/lib/python3.12/site-packages/opentelemetry/trace/__init__.py", line 619, in use_span
span.end()
File "/tmp/.venv/lib/python3.12/site-packages/instana/span/span.py", line 200, in end
self._span_processor.record_span(self._readable_span())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'BatchSpanProcessor' object has no attribute 'record_span'
π€ Python Version
3.12.0
π Provide any additional context for the Bug.
- All relevant packages were installed (see pip freeze output below):
aiohappyeyeballs==2.6.1
aiohttp==3.13.0
aiosignal==1.4.0
annotated-types==0.7.0
anthropic==0.71.0
anyio==4.11.0
attrs==25.4.0
autowrapt==1.0
backoff==2.2.1
certifi==2025.10.5
charset-normalizer==3.4.4
colorama==0.4.6
cuid==0.4
deprecated==1.2.18
distro==1.9.0
docstring-parser==0.17.0
filelock==3.20.0
frozenlist==1.8.0
fsspec==2025.9.0
fysom==2.1.6
googleapis-common-protos==1.70.0
grpcio==1.75.1
h11==0.16.0
hf-xet==1.1.10
httpcore==1.0.9
httpx==0.28.1
huggingface-hub==0.35.3
idna==3.11
importlib-metadata==8.7.0
inflection==0.5.1
instana==3.9.0
jinja2==3.1.6
jiter==0.11.0
markupsafe==3.0.3
monotonic==1.6
multidict==6.7.0
opentelemetry-api==1.38.0
opentelemetry-exporter-otlp==1.38.0
opentelemetry-exporter-otlp-proto-common==1.38.0
opentelemetry-exporter-otlp-proto-grpc==1.38.0
opentelemetry-exporter-otlp-proto-http==1.38.0
opentelemetry-instrumentation==0.59b0
opentelemetry-instrumentation-alephalpha==0.47.3
opentelemetry-instrumentation-anthropic==0.47.3
opentelemetry-instrumentation-bedrock==0.47.3
opentelemetry-instrumentation-chromadb==0.47.3
opentelemetry-instrumentation-cohere==0.47.3
opentelemetry-instrumentation-crewai==0.47.3
opentelemetry-instrumentation-google-generativeai==0.47.3
opentelemetry-instrumentation-groq==0.47.3
opentelemetry-instrumentation-haystack==0.47.3
opentelemetry-instrumentation-lancedb==0.47.3
opentelemetry-instrumentation-langchain==0.47.3
opentelemetry-instrumentation-llamaindex==0.47.3
opentelemetry-instrumentation-logging==0.59b0
opentelemetry-instrumentation-marqo==0.47.3
opentelemetry-instrumentation-mcp==0.47.3
opentelemetry-instrumentation-milvus==0.47.3
opentelemetry-instrumentation-mistralai==0.47.3
opentelemetry-instrumentation-ollama==0.47.3
opentelemetry-instrumentation-openai==0.47.3
opentelemetry-instrumentation-openai-agents==0.47.3
opentelemetry-instrumentation-pinecone==0.47.3
opentelemetry-instrumentation-qdrant==0.47.3
opentelemetry-instrumentation-redis==0.59b0
opentelemetry-instrumentation-replicate==0.47.3
opentelemetry-instrumentation-requests==0.59b0
opentelemetry-instrumentation-sagemaker==0.47.3
opentelemetry-instrumentation-sqlalchemy==0.59b0
opentelemetry-instrumentation-threading==0.59b0
opentelemetry-instrumentation-together==0.47.3
opentelemetry-instrumentation-transformers==0.47.3
opentelemetry-instrumentation-urllib3==0.59b0
opentelemetry-instrumentation-vertexai==0.47.3
opentelemetry-instrumentation-watsonx==0.47.3
opentelemetry-instrumentation-weaviate==0.47.3
opentelemetry-instrumentation-writer==0.47.3
opentelemetry-proto==1.38.0
opentelemetry-sdk==1.38.0
opentelemetry-semantic-conventions==0.59b0
opentelemetry-semantic-conventions-ai==0.4.13
opentelemetry-util-http==0.59b0
packaging==25.0
posthog==3.25.0
propcache==0.4.1
protobuf==6.33.0
pydantic==2.12.2
pydantic-core==2.41.4
python-dateutil==2.9.0.post0
pyyaml==6.0.3
regex==2025.9.18
requests==2.32.5
setuptools==80.9.0
six==1.17.0
sniffio==1.3.1
tenacity==9.1.2
tiktoken==0.12.0
tokenizers==0.22.1
tqdm==4.67.1
traceloop-sdk==0.47.3
typing-extensions==4.15.0
typing-inspection==0.4.2
urllib3==2.5.0
wrapt==1.17.3
yarl==1.22.0
zipp==3.23.0
Script used for reproduction:
#!/usr/bin/env python3
# traceloop_test.py - Minimalist Python script for sending traces to Instana
# Using direct OpenTelemetry APIs instead of Traceloop decorators
import time
import logging
import os
# import instana
from traceloop.sdk import Traceloop
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# os.environ["AUTOWRAPT_BOOTSTRAP"] = "instana"
os.environ["TRACELOOP_BASE_URL"] = "http://instana-agent.instana-agent.svc.cluster.local:4318"
def setup_minimal_tracing():
"""Setup minimal tracing configuration avoiding metrics issues."""
# Create resource
resource = Resource.create({
SERVICE_NAME: "llm-tracing",
"service.version": "0.1.0.556-develop"
})
# Setup tracer provider
provider = TracerProvider(resource=resource)
# Console exporter for local verification
console_processor = BatchSpanProcessor(ConsoleSpanExporter())
provider.add_span_processor(console_processor)
# OTLP gRPC exporter for traces only
try:
trace_exporter = OTLPSpanExporter(
endpoint="http://instana-agent.instana-agent.svc.cluster.local:4318",
insecure=True,
timeout=10
)
otlp_processor = BatchSpanProcessor(trace_exporter)
provider.add_span_processor(otlp_processor)
logger.info("OTLP trace exporter configured")
except Exception as e:
logger.warning(f" OTLP setup failed: {e}")
# Set tracer provider globally
trace.set_tracer_provider(provider)
# Initialize Traceloop (minimal configuration)
Traceloop.init(app_name="llm-tracing")
return trace.get_tracer(__name__)
def main():
"""Main execution with minimal configuration."""
logger.info("Starting minimal Traceloop + Instana integration")
tracer = setup_minimal_tracing()
# Simple test workflow
with tracer.start_as_current_span("test_banking_workflow") as span:
span.set_attribute("workflow.type", "minimal_test")
span.set_attribute("service.name", "yoda-agent-service")
# Simulate operations
with tracer.start_as_current_span("auth_operation") as auth_span:
auth_span.set_attribute("auth.method", "oauth2")
time.sleep(0.05)
logger.info("Auth operation completed")
with tracer.start_as_current_span("llm_operation") as llm_span:
llm_span.set_attribute("llm.model", "claude-v2")
llm_span.set_attribute("llm.tokens", 150)
time.sleep(0.1)
logger.info("LLM operation completed")
span.set_attribute("workflow.success", True)
logger.info("Test workflow completed")
# Allow trace export
time.sleep(3)
logger.info("Minimal integration test completed")
if __name__ == "__main__":
main()π 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?
No response