traceAI-pinecone
OpenTelemetry instrumentation for Pinecone vector database.
Installation
pip install traceAI-pinecone
Quick Start
import os
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
from traceai_pinecone import PineconeInstrumentor
import pinecone
# Set up environment
os.environ["FI_API_KEY"] = "<your-api-key>"
os.environ["FI_SECRET_KEY"] = "<your-secret-key>"
# Register tracer
trace_provider = register(
project_type=ProjectType.OBSERVE,
project_name="my-rag-app"
)
# Instrument Pinecone
PineconeInstrumentor().instrument(tracer_provider=trace_provider)
# Use Pinecone as normal - all operations are traced!
pc = pinecone.Pinecone(api_key="your-pinecone-api-key")
index = pc.Index("my-index")
# Query vectors
results = index.query(
vector=[0.1] * 1536,
top_k=10,
include_metadata=True
)
# Upsert vectors
index.upsert(
vectors=[
{"id": "vec1", "values": [0.1] * 1536, "metadata": {"title": "Doc 1"}},
{"id": "vec2", "values": [0.2] * 1536, "metadata": {"title": "Doc 2"}},
]
)
Instrumented Operations
| Operation | Span Name | Description |
|---|---|---|
query |
pinecone query |
Vector similarity search |
upsert |
pinecone upsert |
Insert or update vectors |
delete |
pinecone delete |
Delete vectors by ID or filter |
fetch |
pinecone fetch |
Retrieve vectors by ID |
update |
pinecone update |
Update vector metadata |
describe_index_stats |
pinecone describe_index_stats |
Get index statistics |
Span Attributes
Common Attributes
| Attribute | Type | Description |
|---|---|---|
db.system |
string | Always "pinecone" |
db.operation.name |
string | Operation name (query, upsert, etc.) |
db.namespace |
string | Index name |
db.vector.namespace |
string | Pinecone namespace |
db.vector.index.name |
string | Index name |
db.vector.index.host |
string | Pinecone host URL |
Query Attributes
| Attribute | Type | Description |
|---|---|---|
db.vector.query.top_k |
int | Number of results requested |
db.vector.query.filter |
string | JSON filter expression |
db.vector.query.include_metadata |
bool | Whether metadata is included |
db.vector.query.include_vectors |
bool | Whether vectors are included |
db.vector.results.count |
int | Number of results returned |
db.vector.results.scores |
string | JSON array of top scores |
db.vector.results.ids |
string | JSON array of result IDs |
Upsert Attributes
| Attribute | Type | Description |
|---|---|---|
db.vector.upsert.count |
int | Number of vectors upserted |
db.vector.upsert.dimensions |
int | Vector dimensions |
Delete Attributes
| Attribute | Type | Description |
|---|---|---|
db.vector.delete.count |
int | Number of vectors deleted |
db.vector.delete.all |
bool | Whether all vectors deleted |
RAG Pipeline Example
from fi_instrumentation import register
from traceai_pinecone import PineconeInstrumentor
from traceai_openai import OpenAIInstrumentor
import pinecone
import openai
# Register tracer
trace_provider = register(project_name="rag-pipeline")
# Instrument both Pinecone and OpenAI
PineconeInstrumentor().instrument(tracer_provider=trace_provider)
OpenAIInstrumentor().instrument(tracer_provider=trace_provider)
# Initialize clients
pc = pinecone.Pinecone()
index = pc.Index("documents")
client = openai.OpenAI()
def rag_query(question: str) -> str:
# 1. Generate embedding for question
embedding_response = client.embeddings.create(
model="text-embedding-3-small",
input=question
)
query_embedding = embedding_response.data[0].embedding
# 2. Search Pinecone for relevant documents
results = index.query(
vector=query_embedding,
top_k=5,
include_metadata=True
)
# 3. Build context from results
context = "\n".join([
match.metadata.get("text", "")
for match in results.matches
])
# 4. Generate answer with context
response = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": f"Context:\n{context}"},
{"role": "user", "content": question}
]
)
return response.choices[0].message.content
# All steps are traced with correlated spans!
answer = rag_query("What is retrieval augmented generation?")
Testing
Unit Tests
cd python/frameworks/pinecone
pip install pytest
pytest tests/ -v
Integration Tests
Requires a Pinecone account and API key:
export PINECONE_API_KEY=your-api-key
pytest tests/ -v -m integration
Example
Run the example RAG pipeline:
cd examples
python basic_rag.py
Resources
License
Apache License 2.0
Metadata
Release files for traceAI-pinecone 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| traceai_pinecone-0.1.0.tar.gz | 8.0 kB | Without provenance | Details for traceai_pinecone-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| traceai_pinecone-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for traceai_pinecone-0.1.0-py3-none-any.whl |
Total release size: 16.5 kB
Release files / traceai_pinecone-0.1.0.tar.gz
| Download URL | traceai_pinecone-0.1.0.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be5a7e0672529bc9594065c283226430eb8e9292631716078b7639636339a62a
|
|
BLAKE2b-256 checksum How to use checksums |
2c1ee9b59fe504bb3d41082efc62597a88f4d53d96d3cdeb39493231a33875f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / traceai_pinecone-0.1.0-py3-none-any.whl
| Download URL | traceai_pinecone-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3ba0b4a2bf543bc2a854d9fad77cc4ece07ab9070cd99c3840af4d4ceb8c0692
|
|
BLAKE2b-256 checksum How to use checksums |
cee2d763fe96c14eee0dfc1fc09827b1625769f493344c21b56d8c87b6cd3df6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for traceAI-pinecone 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.