Hey I'm currently using Phoenix to monitor my LangGraph Applcation. As it is a sql_agent, I keep getting a bunch of the BigQuery traces. I want to exclude these traces. The connection to BigQuery is a LangChain Toolkit. How do I exclude the BigQuery traces while using the LangChain Instrumentor.
To exclude specific traces, such as those from BigQuery, while using the LangChain Instrumentor in Phoenix, you can use the suppress_tracing context manager. This allows you to temporarily pause tracing for specific sections of your code. Here's a basic example: LBKSfrom phoenix.trace import suppress_tracingLBKSwith suppress_tracing(): # Code that connects to BigQuery or any other operations you want to exclude # For example, running BigQuery queries here won't generate traces ...LBKSThis method will prevent traces from being generated for the code block within the suppress_tracing context manager. Would you like more details on this process?Sources:
- Tracing Core Concepts
馃挕聽Hint: Mention RunLLM in the thread for followups.
Hey Harikrishna D., do you know where the Big Query traces are coming from? Do you have some other OTel instrumentation in addition to OpenInference?
{"db": {"name": "ai-projects-431207", "system": "BigQuery"}, "path": "/projects/ai-projects-431207/queries"}I've created a SQLDataBaseToolkit in my class. As I initiate the class, I'm guessing the traces are logging from here.
class DBAgent:
def __init__(self,creds,dataset_id):
self.dataset_id = dataset_id
self.credentials = service_account.Credentials.from_service_account_file(
creds
)
self.service_account_file = creds
self.project_id = self.credentials.project_id
self.client = bigquery.Client(
project=self.project_id, credentials=self.credentials
)
self.sqlalchemy_url = f'bigquery://{self.project_id}/{self.dataset_id}?credentials_path={self.service_account_file}'
self.db_manager = SQLDatabase.from_uri(self.sqlalchemy_url)
self.llm_manager = ChatGoogleGenerativeAI(
model="gemini-1.5-pro-002",
temperature=0,
max_tokens=None,
timeout=None,
max_retries=2,
)
self.toolkit = SQLDatabaseToolkit(db=self.db_manager,llm=self.llm_manager)
hey Harikrishna D., are you able to provide the full code snippet including imports
I don't believe the OTel instrumentation is configured inside LangChain. Do you import and configure opentelemetry inside your application code?
It looks like google-cloud-bigquery automatically creates OTel spans if it finds opentelemetry installed in the runtime. You can try disabling this with
import google.cloud.bigquery.opentelemetry_tracing
google.cloud.bigquery.opentelemetry_tracing.HAS_OPENTELEMETRY = FalseAlternatively, you can explore defining a custom OTel span processor to filter out the unwanted traces. Hope this helps!
