Skip to content

Commit

Permalink
Telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
atroyn committed Nov 6, 2023
1 parent 1c5cebd commit fde8454
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions chromadb/api/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ def _add(
add_amount=len(ids),
with_metadata=len(ids) if metadatas is not None else 0,
with_documents=len(ids) if documents is not None else 0,
with_uri=len(ids) if uris is not None else 0,
)
)
return True
Expand Down Expand Up @@ -405,6 +406,7 @@ def _update(
with_embeddings=len(embeddings) if embeddings else 0,
with_metadata=len(metadatas) if metadatas else 0,
with_documents=len(documents) if documents else 0,
with_uri=len(uris) if uris else 0,
)
)

Expand Down Expand Up @@ -514,6 +516,7 @@ def _get(
limit=limit if limit else 0,
include_metadata=ids_amount if "metadatas" in include else 0,
include_documents=ids_amount if "documents" in include else 0,
include_uris=ids_amount if "uris" in include else 0,
)
)

Expand Down Expand Up @@ -706,6 +709,7 @@ def _query(
with_document_filter=query_amount if where_document is not None else 0,
include_metadatas=query_amount if "metadatas" in include else 0,
include_documents=query_amount if "documents" in include else 0,
include_uris=query_amount if "uris" in include else 0,
include_distances=query_amount if "distances" in include else 0,
)
)
Expand Down
14 changes: 14 additions & 0 deletions chromadb/telemetry/product/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,23 @@ class CollectionAddEvent(ProductTelemetryEvent):
add_amount: int
with_documents: int
with_metadata: int
with_uri: int

def __init__(
self,
collection_uuid: str,
add_amount: int,
with_documents: int,
with_metadata: int,
with_uri: int,
batch_size: int = 1,
):
super().__init__()
self.collection_uuid = collection_uuid
self.add_amount = add_amount
self.with_documents = with_documents
self.with_metadata = with_metadata
self.with_uri = with_uri
self.batch_size = batch_size

@property
Expand All @@ -62,6 +65,7 @@ def batch(self, other: "ProductTelemetryEvent") -> "CollectionAddEvent":
add_amount=total_amount,
with_documents=self.with_documents + other.with_documents,
with_metadata=self.with_metadata + other.with_metadata,
with_uri=self.with_uri + other.with_uri,
batch_size=self.batch_size + other.batch_size,
)

Expand All @@ -72,6 +76,7 @@ class CollectionUpdateEvent(ProductTelemetryEvent):
with_embeddings: int
with_metadata: int
with_documents: int
with_uri: int

def __init__(
self,
Expand All @@ -80,13 +85,15 @@ def __init__(
with_embeddings: int,
with_metadata: int,
with_documents: int,
with_uri: int,
):
super().__init__()
self.collection_uuid = collection_uuid
self.update_amount = update_amount
self.with_embeddings = with_embeddings
self.with_metadata = with_metadata
self.with_documents = with_documents
self.with_uri = with_uri


class CollectionQueryEvent(ProductTelemetryEvent):
Expand All @@ -99,6 +106,7 @@ class CollectionQueryEvent(ProductTelemetryEvent):
n_results: int
include_metadatas: int
include_documents: int
include_uris: int
include_distances: int

def __init__(
Expand All @@ -110,6 +118,7 @@ def __init__(
n_results: int,
include_metadatas: int,
include_documents: int,
include_uris: int,
include_distances: int,
batch_size: int = 1,
):
Expand All @@ -121,6 +130,7 @@ def __init__(
self.n_results = n_results
self.include_metadatas = include_metadatas
self.include_documents = include_documents
self.include_uris = include_uris
self.include_distances = include_distances
self.batch_size = batch_size

Expand All @@ -141,6 +151,7 @@ def batch(self, other: "ProductTelemetryEvent") -> "CollectionQueryEvent":
n_results=self.n_results + other.n_results,
include_metadatas=self.include_metadatas + other.include_metadatas,
include_documents=self.include_documents + other.include_documents,
include_uris=self.include_uris + other.include_uris,
include_distances=self.include_distances + other.include_distances,
batch_size=self.batch_size + other.batch_size,
)
Expand All @@ -152,6 +163,7 @@ class CollectionGetEvent(ProductTelemetryEvent):
limit: int
include_metadata: int
include_documents: int
include_uris: int

def __init__(
self,
Expand All @@ -160,13 +172,15 @@ def __init__(
limit: int,
include_metadata: int,
include_documents: int,
include_uris: int,
):
super().__init__()
self.collection_uuid = collection_uuid
self.ids_count = ids_count
self.limit = limit
self.include_metadata = include_metadata
self.include_documents = include_documents
self.include_uris = include_uris


class CollectionDeleteEvent(ProductTelemetryEvent):
Expand Down

0 comments on commit fde8454

Please sign in to comment.