Learn how to use Langtrace with Neo4j for tracing graph database operations
Neo4j is a leading graph database platform that enables organizations to build intelligent applications that extract business value from connections in their data. Langtrace’s Neo4j integration lets you monitor and trace all your Neo4j database operations, including cypher queries, transaction processing, and GraphRAG operations.
Initialize Langtrace before creating your Phidata agent:
Python
Copy
from langtrace_python_sdk import langtrace # Must precede other importsfrom langtrace_python_sdk.utils.with_root_span import with_langtrace_root_spanfrom neo4j import GraphDatabase# Create a driver instancedriver = GraphDatabase.driver(NEO4J_URI, auth=(NEO4J_USERNAME, NEO4J_PASSWORD))# Execute a queryrecords, summary, keys = driver.execute_query( "MATCH (p:Person {age: $age}) RETURN p.name AS name", age=42, database_="neo4j",)# Access resultsfor person in records: print(person["name"])# Print summary informationprint("The query returned {} records in {} ms.".format( len(records), summary.result_available_after))# Don't forget to close the driverdriver.close()