You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example code doesn't work from the traceloop website doesn't work.
importgoogle.generativeaiasgenaifromtraceloop.sdkimportTraceloopfromtraceloop.sdk.decoratorsimportworkflowfromtraceloop.sdk.instrumentsimportInstrumentsimportosimportdotenvdotenv.load_dotenv(dotenv.find_dotenv())
Traceloop.init(app_name="joke_generation_service", instruments={Instruments.GOOGLE_GENERATIVEAI})
genai.configure(api_key=os.environ.get("GENAI_API_KEY"))
@workflow(name="joke_creation")defcreate_joke():
model=genai.GenerativeModel("gemini-1.0-pro-latest")
response=model.generate_content(
"Give me ten interview questions for the role of program manager.",
)
returnresponse.textprint(create_joke())
👍 Expected behavior
The instrumentation should automatically work instead of having to manually initialise it.
👎 Actual Behavior with Screenshots
The calls using the google_generativeai calls didn't show up in my Grafana Tempo until I started the instrumentor from opentelementry manually
🤖 Python Version
3.12
📃 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
The text was updated successfully, but these errors were encountered:
Hey there, @coffecup25! I'm here to help you out with any bugs, questions, or contributions you have in mind. Let's squash those bugs together! 🐞
The issue you're experiencing with the Traceloop SDK not automatically instrumenting the google_generativeai SDK can occur due to several reasons. Here are some steps and considerations to help address this:
Manual Instrumentation: As you've discovered, manually calling the instrumentation using GoogleGenerativeAiInstrumentor().instrument() works. This suggests that the automatic instrumentation might not be initializing correctly in your setup.
Initialization Order: Ensure that the Traceloop SDK is initialized before any calls to the google_generativeai SDK. This is crucial for the automatic instrumentation to hook into the library correctly.
Check for Errors: The Traceloop SDK provides logging features that can help identify issues with automatic instrumentation. Ensure that any exceptions during the initialization are logged. You can modify the init_google_generativeai_instrumentor function to log exceptions if it's not already doing so.
Environment Variables: Verify that all necessary environment variables, such as TRACELOOP_API_KEY, are correctly set and accessible in your environment.
Disable Batch Sending: If you're working locally, try disabling batch sending to see if traces are sent immediately:
Traceloop.init(disable_batch=True)
Console Exporter: Use the ConsoleExporter to verify if traces are being generated and output to the console:
If these steps do not resolve the issue, it might be necessary to continue using manual instrumentation as a workaround until the automatic instrumentation is fixed or updated in the SDK.
Which component is this bug for?
Traceloop SDK
📜 Description
The python sdk does not instrument the calls when using the google_generativeai sdk. However when manually calling the instrumentation like this:
The calls are correctly added to the trace.
👟 Reproduction steps
The example code doesn't work from the traceloop website doesn't work.
👍 Expected behavior
The instrumentation should automatically work instead of having to manually initialise it.
👎 Actual Behavior with Screenshots
The calls using the google_generativeai calls didn't show up in my Grafana Tempo until I started the instrumentor from opentelementry manually
🤖 Python Version
3.12
📃 Provide any additional context for the Bug.
No response
👀 Have you spent some time to check if this bug has been raised before?
Are you willing to submit PR?
None
The text was updated successfully, but these errors were encountered: