Skip to content
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

feat(smolagents): add entrypoint for use in opentelemetry-instrument #1276

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

codefromthecrypt
Copy link
Contributor

@codefromthecrypt codefromthecrypt commented Feb 7, 2025

I mentioned this to @mikeldking, that openinference can become automatically enabled with opentelemetry's zero code approach for python, by adding entrypoints into the pyproject.toml.

Specifically, after this, as long as you have the dependencies of your main code, plus openinference-instrumentation-smolagents, and env exported with standard variables, if you launch with opentelemetry-instrument, traces will magically appear.

opentelemetry-instrument python main.py

Before adding to all projects, I wanted to check with smolagents first, if this is ok with y'all. I would love to be able to showcase this with Elastic Distribution of OpenTelemetry (EDOT) and the diff makes it all perfectly invisible.

diff --git a/examples/python/openinference/smolagents/main.py b/examples/python/openinference/smolagents/main.py
index 7d54c87..697f7a5 100644
--- a/examples/python/openinference/smolagents/main.py
+++ b/examples/python/openinference/smolagents/main.py
@@ -1,11 +1,7 @@
 import os
 
-from openinference.instrumentation.smolagents import SmolagentsInstrumentor
 from smolagents import DuckDuckGoSearchTool, OpenAIServerModel, ToolCallingAgent
 
-SmolagentsInstrumentor().instrument()
-
-
 def main():
     model = OpenAIServerModel(model_id=os.getenv("CHAT_MODEL", "gpt-4o-mini"))
 
diff --git a/examples/python/openinference/smolagents/requirements.txt b/examples/python/openinference/smolagents/requirements.txt
index 8d8c23b..5220f5a 100644
--- a/examples/python/openinference/smolagents/requirements.txt
+++ b/examples/python/openinference/smolagents/requirements.txt
@@ -3,4 +3,5 @@ smolagents[openai]~=1.7.0
 opentelemetry-sdk~=1.30.0
 opentelemetry-exporter-otlp-proto-http~=1.30.0
 opentelemetry-distro~=0.51b0
-openinference-instrumentation-smolagents~=0.1.3
+# openinference-instrumentation-smolagents~=0.1.3
+-e /Users/adriancole/oss/openinference/python/instrumentation/openinference-instrumentation-smolagents

@codefromthecrypt codefromthecrypt requested a review from a team as a code owner February 7, 2025 02:31
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Feb 7, 2025
Copy link
Contributor

github-actions bot commented Feb 7, 2025

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@codefromthecrypt
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Feb 7, 2025
Copy link
Contributor

@nate-mar nate-mar left a comment

Choose a reason for hiding this comment

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

Cool! TIL! Thanks for the contribution. lgtm!

@nate-mar nate-mar merged commit 7d2af53 into Arize-ai:main Feb 7, 2025
9 checks passed
@github-actions github-actions bot mentioned this pull request Feb 7, 2025
@codefromthecrypt
Copy link
Contributor Author

Just verified this works like a champ with latest release. Should I raise PRs for the others? If so, same PR for all others, or one each like this?

@codefromthecrypt codefromthecrypt deleted the entrypoints branch February 7, 2025 03:28
@mikeldking
Copy link
Contributor

Just verified this works like a champ with latest release. Should I raise PRs for the others? If so, same PR for all others, or one each like this

Thanks so much for this @codefromthecrypt can do them all at once no problem. We have a single release please pipeline now. Should just work

@codefromthecrypt
Copy link
Contributor Author

ok I may be somewhat blind now, but all the rest are done in #1278 ;)

@aymeric-roucher
Copy link
Contributor

@codefromthecrypt maintainer of smolagents here: could you explain what this changes for instrumentation, and if we have actions to take to make it work?

@nate-mar
Copy link
Contributor

nate-mar commented Feb 14, 2025

Hi @aymeric-roucher ! As far as I understand, this doesn't change anything with the existing instrumentation for smolagents. It just gives users more optionality for setting up smolagents instrumentation with their apps, by allowing them to remove some boilerplate otel instrumentation code (via a run time arg instead) , if they so desire.

@codefromthecrypt
Copy link
Contributor Author

@aymeric-roucher I concur with @nate-mar and was going to propose an instruction change PR today for smolagents repo. You can then assess that to see if you prefer the before or after, but the existing instructions still work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants