Skip to content

fix(sdk): Ensure instrumentors don’t report successful init if package isn’t installed #3043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 23, 2025

Conversation

ronensc
Copy link
Contributor

@ronensc ronensc commented Jun 23, 2025

  • I have added tests that cover my changes.
  • If adding a new instrumentation or changing an existing one, I've added screenshots from some observability platform showing the change.
  • PR name follows conventional commits format: feat(instrumentation): ... or fix(instrumentation): ....
  • (If applicable) I have updated the documentation accordingly.

Fixes #3042


Important

Ensure instrumentors in tracing.py don't report successful initialization if the package isn't installed, updating init_*_instrumentor() functions accordingly.

  • Behavior:
    • Ensure instrumentors in tracing.py don't report successful initialization if the package isn't installed.
    • Modify init_instrumentations() to print a warning if no valid instruments are set.
  • Functions:
    • Update init_openai_instrumentor(), init_anthropic_instrumentor(), init_cohere_instrumentor(), and 20 other init_*_instrumentor() functions to return True only if the package is installed and instrumented.
    • Remove redundant instrument_set check in wrapped_on_end() in tracing.py.

This description was created by Ellipsis for 78aa8a7. You can customize this summary. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to 78aa8a7 in 1 minute and 27 seconds. Click for details.
  • Reviewed 469 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py:143
  • Draft comment:
    Notice removal of the instrument_set check and warning output. Without this feedback, users may not be alerted when no valid instrumentations are initialized. Confirm this is the intended behavior.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
2. packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py:507
  • Draft comment:
    The 'return True' has been moved inside the conditional block for instrumentation (e.g., in init_openai_instrumentor). This means if the instrumentor is already instrumented (or the package isn’t installed), the function returns False. Please verify that returning False in such cases is intended.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
3. packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py:625
  • Draft comment:
    Typographical notice: The error message references "Gemini instrumentor" but the function name is init_google_generativeai_instrumentor. If this is not intentional, please update the error message to match the instrumentor's name.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_E8Q7IeL8QibeY2mV

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

except Exception as e:
logging.error(f"Error initializing LanceDB instrumentor: {e}")
Telemetry().log_exception(e)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added missing Telemetry().log_exception(e)

Comment on lines -153 to -158
if not instrument_set:
print(
Fore.RED + "Warning: No valid instruments set. Remove 'instrument' "
"argument to use all instruments, or set a valid instrument."
)
print(Fore.RESET)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed as duplicate of the following:

if not instrument_set:
print(
Fore.RED
+ "Warning: No valid instruments set. "
+ "Ensure the instrumented libraries are installed, specify valid instruments, "
+ "or remove 'instruments' argument to use all instruments."
)
print(Fore.RESET)

@nirga nirga merged commit 45f4346 into traceloop:main Jun 23, 2025
9 checks passed
@ronensc ronensc deleted the fix-init-instruments branch June 23, 2025 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Bug Report: Missing warning message when no instrumentors are initialized
2 participants