Open coffecup25 opened 1 week ago
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:
from opentelemetry.sdk.trace.export import ConsoleSpanExporter
Traceloop.init(exporter=ConsoleSpanExporter())
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.
To continue talking to Dosu, mention @dosu.
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