Skip to content

Commit 7216ce0

Browse files
committed
Lint & format
1 parent 0ca08be commit 7216ce0

25 files changed

+1423
-989
lines changed

examples/log-and-detect/example_fast_api/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# Configure logging
66
logging.basicConfig(
77
level=logging.INFO,
8-
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
9-
handlers=[logging.StreamHandler()]
8+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
9+
handlers=[logging.StreamHandler()],
1010
)
1111

1212
app = FastAPI()

examples/tracing/quotient_trace_agno_agent.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,21 @@
1515
instruments=[AgnoInstrumentor()],
1616
)
1717

18-
@quotient.trace('agno-agent-ddgs-search')
18+
19+
@quotient.trace("agno-agent-ddgs-search")
1920
def run_agno():
2021
# add additional span attributes
2122
span = get_current_span()
2223
span.set_attribute("mycustom.attr", "customvalue")
2324

2425
agent = Agent(
25-
model=OpenAIChat(id="gpt-4o-mini"),
26+
model=OpenAIChat(id="gpt-4o-mini"),
2627
tools=[DuckDuckGoTools()],
27-
markdown=True,
28+
markdown=True,
2829
)
2930

3031
agent.print_response("What is currently trending on Twitter?")
3132

33+
3234
if __name__ == "__main__":
3335
run_agno()

examples/tracing/quotient_trace_chroma.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This example shows how to use the ChromaInstrumentor to automatically
55
trace ChromaDB operations with OpenTelemetry semantic conventions.
66
"""
7+
78
import chromadb
89

910
from quotientai import QuotientAI
@@ -24,67 +25,71 @@
2425
# Alternative: Manual instrumentation after initialization
2526
# quotient.tracer.instrument_vector_dbs("chroma")
2627

28+
2729
@quotient.trace()
2830
def run_chroma():
2931
"""Demonstrate ChromaDB operations with tracing."""
3032
with start_span("chroma_demo"):
31-
try:
33+
try:
3234
# Create client
3335
client = chromadb.Client()
34-
36+
3537
# Create collection
3638
collection = client.create_collection(name="test_collection")
37-
39+
3840
# Add documents
3941
collection.add(
4042
documents=["This is a test document", "Another test document"],
4143
metadatas=[{"source": "test"}, {"source": "test"}],
42-
ids=["id1", "id2"]
44+
ids=["id1", "id2"],
4345
)
44-
46+
4547
# Query documents
4648
results = collection.query(
4749
query_texts=["test document"],
4850
n_results=2,
49-
include=["metadatas", "documents", "distances"]
51+
include=["metadatas", "documents", "distances"],
5052
)
51-
53+
5254
print(f"ChromaDB query results: {results}")
53-
55+
5456
# Update documents
5557
collection.update(
5658
ids=["id1"],
5759
documents=["Updated test document"],
58-
metadatas=[{"source": "updated"}]
60+
metadatas=[{"source": "updated"}],
5961
)
60-
62+
6163
# Delete documents
6264
collection.delete(ids=["id2"])
63-
65+
6466
# Get collection info
6567
collection_info = collection.get()
6668
print(f"Collection info: {collection_info}")
67-
69+
6870
except ImportError:
6971
print("ChromaDB not installed. Install with: pip install chromadb")
7072
except Exception as e:
7173
print(f"Error in ChromaDB demo: {e}")
7274

75+
7376
if __name__ == "__main__":
7477
print("Starting ChromaDB Tracing Demo...")
7578
print("=" * 50)
76-
79+
7780
# Run demonstrations
7881
run_chroma()
79-
82+
8083
# Force flush to ensure spans are sent immediately
8184
quotient.tracer.force_flush()
82-
85+
8386
print("=" * 50)
8487
print("ChromaDB demo completed! Check your tracing dashboard for spans.")
8588
print("\nChromaDB spans will include these semantic conventions:")
8689
print("- db.system.name: 'chroma'")
87-
print("- db.operation: 'create_collection', 'add', 'query', 'update', 'delete', 'get'")
90+
print(
91+
"- db.operation: 'create_collection', 'add', 'query', 'update', 'delete', 'get'"
92+
)
8893
print("- db.collection.name: collection name")
8994
print("- db.ids_count: number of IDs processed")
9095
print("- db.vector_count: number of vectors processed")

examples/tracing/quotient_trace_openai.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
instruments=[OpenAIInstrumentor()],
1212
)
1313

14+
1415
@quotient.trace()
1516
def test_openai():
1617
client = openai.OpenAI()
@@ -23,8 +24,9 @@ def test_openai():
2324
)
2425

2526
for chunk in response:
26-
if chunk.choices and (content := chunk.choices[0].delta.content):
27-
print(content, end="")
27+
if chunk.choices and (content := chunk.choices[0].delta.content):
28+
print(content, end="")
29+
2830

2931
if __name__ == "__main__":
30-
test_openai()
32+
test_openai()

examples/tracing/quotient_trace_pinecone.py

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This example shows how to use the PineconeInstrumentor to automatically
55
trace Pinecone operations with OpenTelemetry semantic conventions.
66
"""
7+
78
import os
89

910
from pinecone import Pinecone, ServerlessSpec
@@ -26,77 +27,70 @@
2627
# Alternative: Manual instrumentation after initialization
2728
# quotient.tracer.instrument_vector_dbs("pinecone")
2829

30+
2931
@quotient.trace()
3032
def demonstrate_pinecone_operations():
3133
"""Demonstrate Pinecone operations with tracing."""
3234
with start_span("pinecone_demo"):
33-
try:
35+
try:
3436
# Check for API key
3537
api_key = os.environ.get("PINECONE_API_KEY")
36-
38+
3739
if not api_key:
3840
print("Pinecone API key not set.")
3941
print("Set PINECONE_API_KEY environment variable.")
4042
print("You can get this from https://app.pinecone.io/")
4143
return
42-
44+
4345
pc = Pinecone(api_key=api_key)
44-
46+
4547
# List existing indexes
4648
indexes = pc.list_indexes()
4749
print(f"Existing indexes: {indexes}")
48-
50+
4951
# Create index (if it doesn't exist)
5052
index_name = "test-index"
5153
if index_name not in indexes:
52-
spec = ServerlessSpec(
53-
cloud="aws",
54-
region="us-east-1"
55-
)
54+
spec = ServerlessSpec(cloud="aws", region="us-east-1")
5655
pc.create_index(
5756
name=index_name,
5857
spec=spec,
5958
dimension=128,
6059
metric="cosine",
6160
)
6261
print(f"Created index: {index_name}")
63-
62+
6463
# Get index
6564
index = pc.Index(index_name)
66-
65+
6766
# Upsert vectors
6867
vectors = [
6968
("id1", [0.1] * 128, {"source": "test", "category": "demo"}),
7069
("id2", [0.2] * 128, {"source": "test", "category": "demo"}),
71-
("id3", [0.3] * 128, {"source": "test", "category": "demo"})
70+
("id3", [0.3] * 128, {"source": "test", "category": "demo"}),
7271
]
7372
index.upsert(vectors=vectors)
7473
print("Upserted vectors")
75-
74+
7675
# Query vectors
7776
query_vector = [0.1] * 128
78-
results = index.query(
79-
vector=query_vector,
80-
top_k=3,
81-
include_metadata=True
82-
)
77+
results = index.query(vector=query_vector, top_k=3, include_metadata=True)
8378
print(f"Query results: {results}")
84-
79+
8580
# Fetch specific vectors
8681
fetch_results = index.fetch(ids=["id1", "id2"])
8782
print(f"Fetch results: {fetch_results}")
88-
83+
8984
# Update metadata
9085
index.update(
91-
id="id1",
92-
set_metadata={"source": "updated", "category": "modified"}
86+
id="id1", set_metadata={"source": "updated", "category": "modified"}
9387
)
9488
print("Updated metadata")
95-
89+
9690
# Delete vectors
9791
index.delete(ids=["id3"])
9892
print("Deleted vector id3")
99-
93+
10094
except ImportError:
10195
print("Pinecone not installed. Install with: pip install pinecone")
10296
except Exception as e:
@@ -107,15 +101,17 @@ def demonstrate_pinecone_operations():
107101
if __name__ == "__main__":
108102
print("Starting Pinecone Tracing Demo...")
109103
print("=" * 50)
110-
104+
111105
# Run demonstrations
112106
demonstrate_pinecone_operations()
113-
107+
114108
print("=" * 50)
115109
print("Pinecone demo completed! Check your tracing dashboard for spans.")
116110
print("\nPinecone spans will include these semantic conventions:")
117111
print("- db.system.name: 'pinecone'")
118-
print("- db.operation: 'create_index', 'upsert', 'query', 'fetch', 'update', 'delete', 'describe_index_stats'")
112+
print(
113+
"- db.operation: 'create_index', 'upsert', 'query', 'fetch', 'update', 'delete', 'describe_index_stats'"
114+
)
119115
print("- db.collection.name: index name")
120116
print("- db.ids_count: number of IDs processed")
121117
print("- db.vector_count: number of vectors processed")

0 commit comments

Comments
 (0)