Description
Which component is this bug for?
Traceloop SDK
📜 Description
When no instrumentors are initialized via Traceloop.init()
, no warning message is emitted.
This makes it harder to detect misconfiguration or missing dependencies.
👟 Reproduction steps
-
Create a fresh virtual environment.
-
Install the SDK (and no other LLM/framework package):
pip install traceloop-sdk==0.40.12
- Run the following code:
from traceloop.sdk import Traceloop
from traceloop.sdk.instruments import Instruments
Traceloop.init(instruments={Instruments.MCP})
- Observe that no warning is printed, even though no instrumentors are active.
👍 Expected behavior
A warning message should be emitted when no instrumentors are initialized, e.g.:
Warning: No valid instruments set.
👎 Actual Behavior with Screenshots
none
🤖 Python Version
No response
📃 Provide any additional context for the Bug.
It appears that the issue stems from the init_<x>_instrumentor()
functions returning True
even when no instrumentation actually occurs — for example, when the corresponding package is not installed.
Here’s an example from init_mcp_instrumentor()
:
openllmetry/packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py
Lines 1039 to 1054 in 20a4e4b
There's an easy fix to apply to all instrumentors - move the return True
statement inside the if is_package_installed()
block to avoid false positives:
def init_mcp_instrumentor():
try:
if is_package_installed("mcp"):
Telemetry().capture("instrumentation:mcp:init")
from opentelemetry.instrumentation.mcp import McpInstrumentor
instrumentor = McpInstrumentor(
exception_logger=lambda e: Telemetry().log_exception(e),
)
if not instrumentor.is_instrumented_by_opentelemetry:
instrumentor.instrument()
return True
except Exception as e:
logging.error(f"Error initializing MCP instrumentor: {e}")
Telemetry().log_exception(e)
return False
This pattern should be applied to all instrumentor init functions.
👀 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?
Yes I am willing to submit a PR!