Skip to content

Commit

Permalink
add support for open telemetry (#92)
Browse files Browse the repository at this point in the history
Closes: #87
  • Loading branch information
HomelessDinosaur authored Apr 11, 2023
2 parents 6b6cf29 + 849a7ca commit 5caf046
Show file tree
Hide file tree
Showing 48 changed files with 22,602 additions and 353 deletions.
125 changes: 83 additions & 42 deletions docs/nitric/api/documents.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ <h1 class="title">Module <code>nitric.api.documents</code></h1>

from nitric.api.const import MAX_SUB_COLLECTION_DEPTH
from nitric.api.exception import exception_from_grpc_error
from proto.nitric.document.v1 import (
from nitric.proto.nitric.document.v1 import (
DocumentServiceStub,
Collection as CollectionMessage,
Key as KeyMessage,
Expression as ExpressionMessage,
ExpressionValue,
Document as DocumentMessage,
DocumentSetRequest,
DocumentGetRequest,
DocumentDeleteRequest,
DocumentQueryStreamRequest,
DocumentQueryRequest,
)

from nitric.utils import new_default_channel, _dict_from_struct, _struct_from_dict
Expand Down Expand Up @@ -102,7 +107,9 @@ <h1 class="title">Module <code>nitric.api.documents</code></h1>
async def get(self) -&gt; Document:
&#34;&#34;&#34;Retrieve the contents of this document, if it exists.&#34;&#34;&#34;
try:
response = await self._documents._stub.get(key=_doc_ref_to_wire(self))
response = await self._documents._stub.get(
document_get_request=DocumentGetRequest(key=_doc_ref_to_wire(self))
)
return _document_from_wire(documents=self._documents, message=response.document)
except GRPCError as grpc_err:
raise exception_from_grpc_error(grpc_err)
Expand All @@ -115,8 +122,10 @@ <h1 class="title">Module <code>nitric.api.documents</code></h1>
&#34;&#34;&#34;
try:
await self._documents._stub.set(
key=_doc_ref_to_wire(self),
content=_struct_from_dict(content),
document_set_request=DocumentSetRequest(
key=_doc_ref_to_wire(self),
content=_struct_from_dict(content),
)
)
except GRPCError as grpc_err:
raise exception_from_grpc_error(grpc_err)
Expand All @@ -125,7 +134,9 @@ <h1 class="title">Module <code>nitric.api.documents</code></h1>
&#34;&#34;&#34;Delete this document, if it exists.&#34;&#34;&#34;
try:
await self._documents._stub.delete(
key=_doc_ref_to_wire(self),
document_delete_request=DocumentDeleteRequest(
key=_doc_ref_to_wire(self),
)
)
except GRPCError as grpc_err:
raise exception_from_grpc_error(grpc_err)
Expand Down Expand Up @@ -525,9 +536,11 @@ <h1 class="title">Module <code>nitric.api.documents</code></h1>

try:
async for result in self._documents._stub.query_stream(
collection=_collection_to_wire(self._collection),
expressions=self._expressions_to_wire(),
limit=self._limit,
document_query_stream_request=DocumentQueryStreamRequest(
collection=_collection_to_wire(self._collection),
expressions=self._expressions_to_wire(),
limit=self._limit,
)
):
yield _document_from_wire(documents=self._documents, message=result.document)
except GRPCError as grpc_err:
Expand All @@ -541,10 +554,12 @@ <h1 class="title">Module <code>nitric.api.documents</code></h1>
&#34;&#34;&#34;
try:
results = await self._documents._stub.query(
collection=_collection_to_wire(self._collection),
expressions=self._expressions_to_wire(),
limit=self._limit,
paging_token=self._paging_token,
document_query_request=DocumentQueryRequest(
collection=_collection_to_wire(self._collection),
expressions=self._expressions_to_wire(),
limit=self._limit,
paging_token=self._paging_token,
)
)

return QueryResultsPage(
Expand Down Expand Up @@ -674,7 +689,8 @@ <h3>Ancestors</h3>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class CollectionGroupRef:
<pre><code class="python">@dataclass(frozen=True, order=True)
class CollectionGroupRef:
&#34;&#34;&#34;A reference to a collection group.&#34;&#34;&#34;

_documents: Documents
Expand Down Expand Up @@ -738,7 +754,7 @@ <h3>Class variables</h3>
<dd>
<div class="desc"></div>
</dd>
<dt id="nitric.api.documents.CollectionGroupRef.parent"><code class="name">var <span class="ident">parent</span>Union[<a title="nitric.api.documents.CollectionRef" href="#nitric.api.documents.CollectionRef">CollectionRef</a>, NoneType]</code></dt>
<dt id="nitric.api.documents.CollectionGroupRef.parent"><code class="name">var <span class="ident">parent</span>Optional[<a title="nitric.api.documents.CollectionRef" href="#nitric.api.documents.CollectionRef">CollectionRef</a>]</code></dt>
<dd>
<div class="desc"></div>
</dd>
Expand Down Expand Up @@ -861,7 +877,8 @@ <h3>Methods</h3>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class CollectionRef:
<pre><code class="python">@dataclass(frozen=True, order=True)
class CollectionRef:
&#34;&#34;&#34;A reference to a collection of documents.&#34;&#34;&#34;

_documents: Documents
Expand Down Expand Up @@ -921,7 +938,7 @@ <h3>Class variables</h3>
<dd>
<div class="desc"></div>
</dd>
<dt id="nitric.api.documents.CollectionRef.parent"><code class="name">var <span class="ident">parent</span>Union[<a title="nitric.api.documents.DocumentRef" href="#nitric.api.documents.DocumentRef">DocumentRef</a>, NoneType]</code></dt>
<dt id="nitric.api.documents.CollectionRef.parent"><code class="name">var <span class="ident">parent</span>Optional[<a title="nitric.api.documents.DocumentRef" href="#nitric.api.documents.DocumentRef">DocumentRef</a>]</code></dt>
<dd>
<div class="desc"></div>
</dd>
Expand Down Expand Up @@ -1040,7 +1057,8 @@ <h3>Methods</h3>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class Document:
<pre><code class="python">@dataclass(frozen=True, order=True)
class Document:
&#34;&#34;&#34;Represents a document and any associated metadata.&#34;&#34;&#34;

_ref: DocumentRef
Expand Down Expand Up @@ -1121,7 +1139,8 @@ <h3>Instance variables</h3>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class DocumentRef:
<pre><code class="python">@dataclass(frozen=True, order=True)
class DocumentRef:
&#34;&#34;&#34;A reference to a document in a collection.&#34;&#34;&#34;

_documents: Documents
Expand All @@ -1148,7 +1167,9 @@ <h3>Instance variables</h3>
async def get(self) -&gt; Document:
&#34;&#34;&#34;Retrieve the contents of this document, if it exists.&#34;&#34;&#34;
try:
response = await self._documents._stub.get(key=_doc_ref_to_wire(self))
response = await self._documents._stub.get(
document_get_request=DocumentGetRequest(key=_doc_ref_to_wire(self))
)
return _document_from_wire(documents=self._documents, message=response.document)
except GRPCError as grpc_err:
raise exception_from_grpc_error(grpc_err)
Expand All @@ -1161,8 +1182,10 @@ <h3>Instance variables</h3>
&#34;&#34;&#34;
try:
await self._documents._stub.set(
key=_doc_ref_to_wire(self),
content=_struct_from_dict(content),
document_set_request=DocumentSetRequest(
key=_doc_ref_to_wire(self),
content=_struct_from_dict(content),
)
)
except GRPCError as grpc_err:
raise exception_from_grpc_error(grpc_err)
Expand All @@ -1171,7 +1194,9 @@ <h3>Instance variables</h3>
&#34;&#34;&#34;Delete this document, if it exists.&#34;&#34;&#34;
try:
await self._documents._stub.delete(
key=_doc_ref_to_wire(self),
document_delete_request=DocumentDeleteRequest(
key=_doc_ref_to_wire(self),
)
)
except GRPCError as grpc_err:
raise exception_from_grpc_error(grpc_err)</code></pre>
Expand Down Expand Up @@ -1232,7 +1257,9 @@ <h3>Methods</h3>
&#34;&#34;&#34;Delete this document, if it exists.&#34;&#34;&#34;
try:
await self._documents._stub.delete(
key=_doc_ref_to_wire(self),
document_delete_request=DocumentDeleteRequest(
key=_doc_ref_to_wire(self),
)
)
except GRPCError as grpc_err:
raise exception_from_grpc_error(grpc_err)</code></pre>
Expand All @@ -1250,7 +1277,9 @@ <h3>Methods</h3>
<pre><code class="python">async def get(self) -&gt; Document:
&#34;&#34;&#34;Retrieve the contents of this document, if it exists.&#34;&#34;&#34;
try:
response = await self._documents._stub.get(key=_doc_ref_to_wire(self))
response = await self._documents._stub.get(
document_get_request=DocumentGetRequest(key=_doc_ref_to_wire(self))
)
return _document_from_wire(documents=self._documents, message=response.document)
except GRPCError as grpc_err:
raise exception_from_grpc_error(grpc_err)</code></pre>
Expand All @@ -1274,8 +1303,10 @@ <h3>Methods</h3>
&#34;&#34;&#34;
try:
await self._documents._stub.set(
key=_doc_ref_to_wire(self),
content=_struct_from_dict(content),
document_set_request=DocumentSetRequest(
key=_doc_ref_to_wire(self),
content=_struct_from_dict(content),
)
)
except GRPCError as grpc_err:
raise exception_from_grpc_error(grpc_err)</code></pre>
Expand Down Expand Up @@ -1345,7 +1376,8 @@ <h3>Methods</h3>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class Expression:
<pre><code class="python">@dataclass(order=True)
class Expression:
&#34;&#34;&#34;Query expressions, representing a boolean operation used for query filters.&#34;&#34;&#34;

operand: str
Expand Down Expand Up @@ -1566,9 +1598,11 @@ <h3>Class variables</h3>

try:
async for result in self._documents._stub.query_stream(
collection=_collection_to_wire(self._collection),
expressions=self._expressions_to_wire(),
limit=self._limit,
document_query_stream_request=DocumentQueryStreamRequest(
collection=_collection_to_wire(self._collection),
expressions=self._expressions_to_wire(),
limit=self._limit,
)
):
yield _document_from_wire(documents=self._documents, message=result.document)
except GRPCError as grpc_err:
Expand All @@ -1582,10 +1616,12 @@ <h3>Class variables</h3>
&#34;&#34;&#34;
try:
results = await self._documents._stub.query(
collection=_collection_to_wire(self._collection),
expressions=self._expressions_to_wire(),
limit=self._limit,
paging_token=self._paging_token,
document_query_request=DocumentQueryRequest(
collection=_collection_to_wire(self._collection),
expressions=self._expressions_to_wire(),
limit=self._limit,
paging_token=self._paging_token,
)
)

return QueryResultsPage(
Expand Down Expand Up @@ -1642,10 +1678,12 @@ <h3>Methods</h3>
&#34;&#34;&#34;
try:
results = await self._documents._stub.query(
collection=_collection_to_wire(self._collection),
expressions=self._expressions_to_wire(),
limit=self._limit,
paging_token=self._paging_token,
document_query_request=DocumentQueryRequest(
collection=_collection_to_wire(self._collection),
expressions=self._expressions_to_wire(),
limit=self._limit,
paging_token=self._paging_token,
)
)

return QueryResultsPage(
Expand Down Expand Up @@ -1712,9 +1750,11 @@ <h3>Methods</h3>

try:
async for result in self._documents._stub.query_stream(
collection=_collection_to_wire(self._collection),
expressions=self._expressions_to_wire(),
limit=self._limit,
document_query_stream_request=DocumentQueryStreamRequest(
collection=_collection_to_wire(self._collection),
expressions=self._expressions_to_wire(),
limit=self._limit,
)
):
yield _document_from_wire(documents=self._documents, message=result.document)
except GRPCError as grpc_err:
Expand Down Expand Up @@ -1799,7 +1839,8 @@ <h2 id="examples">Examples</h2>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class QueryResultsPage:
<pre><code class="python">@dataclass(frozen=True, order=True)
class QueryResultsPage:
&#34;&#34;&#34;Represents a page of results from a query.&#34;&#34;&#34;

paging_token: any = field(default_factory=lambda: None)
Expand Down
Loading

0 comments on commit 5caf046

Please sign in to comment.