From a359cd2a870fe255ca8d4215e050f1fddfdc0658 Mon Sep 17 00:00:00 2001 From: Ryan Cartwright Date: Tue, 11 Apr 2023 11:35:59 +1000 Subject: [PATCH] check for local run if otel binary is missing --- docs/nitric/application.html | 30 +- docs/nitric/faas.html | 12 +- docs/nitric/proto/nitric/deploy/index.html | 88 + docs/nitric/proto/nitric/deploy/v1/index.html | 1550 +++++++++++++++++ .../proto/nitric/document/v1/index.html | 18 +- docs/nitric/proto/nitric/error/v1/index.html | 4 +- docs/nitric/proto/nitric/faas/v1/index.html | 90 +- docs/nitric/proto/nitric/index.html | 5 + docs/nitric/proto/nitric/queue/v1/index.html | 10 +- .../proto/nitric/resource/v1/index.html | 18 +- .../nitric/proto/nitric/storage/v1/index.html | 8 +- docs/nitric/resources/apis.html | 1 - nitric/application.py | 9 +- 13 files changed, 1777 insertions(+), 66 deletions(-) create mode 100644 docs/nitric/proto/nitric/deploy/index.html create mode 100644 docs/nitric/proto/nitric/deploy/v1/index.html diff --git a/docs/nitric/application.html b/docs/nitric/application.html index 6953e02..5c623cd 100644 --- a/docs/nitric/application.html +++ b/docs/nitric/application.html @@ -45,7 +45,7 @@

Module nitric.application

# limitations under the License. # import asyncio -import os +from os import getenv, environ from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider, sampling @@ -96,17 +96,18 @@

Module nitric.application

@classmethod def _create_tracer(cls) -> TracerProvider: - local_run = os.environ.OTELCOL_BIN is not None - samplePercent = os.environ.NITRIC_TRACE_SAMPLE_PERCENT - + local_run = "OTELCOL_BIN" not in environ + samplePercent = getenv("NITRIC_TRACE_SAMPLE_PERCENT") + samplePercent = float(samplePercent) / 100 if samplePercent is not None else 100 + # If its a local run use a console exporter, otherwise export using OTEL Protocol exporter = OTLPSpanExporter(endpoint="http://localhost:4317", insecure=True) if local_run: exporter = ConsoleSpanExporter() - + provider = TracerProvider( active_span_processor=BatchSpanProcessor(exporter), - sampler=sampling.TraceIdRatioBased(samplePercent/100 if samplePercent is not None else 100) + sampler=sampling.TraceIdRatioBased(samplePercent), ) trace.set_tracer_provider(provider) @@ -123,7 +124,7 @@

Module nitric.application

This will execute in an existing event loop if there is one, otherwise it will attempt to create its own. """ provider = cls._create_tracer() - try: + try: try: loop = asyncio.get_running_loop() except RuntimeError: @@ -192,17 +193,18 @@

Classes

@classmethod def _create_tracer(cls) -> TracerProvider: - local_run = os.environ.OTELCOL_BIN is not None - samplePercent = os.environ.NITRIC_TRACE_SAMPLE_PERCENT - + local_run = "OTELCOL_BIN" not in environ + samplePercent = getenv("NITRIC_TRACE_SAMPLE_PERCENT") + samplePercent = float(samplePercent) / 100 if samplePercent is not None else 100 + # If its a local run use a console exporter, otherwise export using OTEL Protocol exporter = OTLPSpanExporter(endpoint="http://localhost:4317", insecure=True) if local_run: exporter = ConsoleSpanExporter() - + provider = TracerProvider( active_span_processor=BatchSpanProcessor(exporter), - sampler=sampling.TraceIdRatioBased(samplePercent/100 if samplePercent is not None else 100) + sampler=sampling.TraceIdRatioBased(samplePercent), ) trace.set_tracer_provider(provider) @@ -219,7 +221,7 @@

Classes

This will execute in an existing event loop if there is one, otherwise it will attempt to create its own. """ provider = cls._create_tracer() - try: + try: try: loop = asyncio.get_running_loop() except RuntimeError: @@ -256,7 +258,7 @@

Static methods

This will execute in an existing event loop if there is one, otherwise it will attempt to create its own. """ provider = cls._create_tracer() - try: + try: try: loop = asyncio.get_running_loop() except RuntimeError: diff --git a/docs/nitric/faas.html b/docs/nitric/faas.html index ed1be85..533e579 100644 --- a/docs/nitric/faas.html +++ b/docs/nitric/faas.html @@ -258,7 +258,7 @@

Module nitric.faas

path=trigger_request.http.path, params={k: v for (k, v) in trigger_request.http.path_params.items()}, headers=headers, - trace_context=trigger_request.trace_context, + trace_context=trigger_request.trace_context.values, ) ) @@ -306,7 +306,7 @@

Module nitric.faas

request=EventRequest( data=trigger_request.data, topic=trigger_request.topic.topic, - trace_context=trigger_request.trace_context, + trace_context=trigger_request.trace_context.values, ) ) @@ -779,7 +779,7 @@

Classes

request=EventRequest( data=trigger_request.data, topic=trigger_request.topic.topic, - trace_context=trigger_request.trace_context, + trace_context=trigger_request.trace_context.values, ) ) @@ -806,7 +806,7 @@

Static methods

request=EventRequest( data=trigger_request.data, topic=trigger_request.topic.topic, - trace_context=trigger_request.trace_context, + trace_context=trigger_request.trace_context.values, ) ) @@ -1259,7 +1259,7 @@

Methods

path=trigger_request.http.path, params={k: v for (k, v) in trigger_request.http.path_params.items()}, headers=headers, - trace_context=trigger_request.trace_context, + trace_context=trigger_request.trace_context.values, ) ) @@ -1300,7 +1300,7 @@

Static methods

path=trigger_request.http.path, params={k: v for (k, v) in trigger_request.http.path_params.items()}, headers=headers, - trace_context=trigger_request.trace_context, + trace_context=trigger_request.trace_context.values, ) ) diff --git a/docs/nitric/proto/nitric/deploy/index.html b/docs/nitric/proto/nitric/deploy/index.html new file mode 100644 index 0000000..f3022f1 --- /dev/null +++ b/docs/nitric/proto/nitric/deploy/index.html @@ -0,0 +1,88 @@ + + + + + + +nitric.proto.nitric.deploy API documentation + + + + + + + + + + + +
+
+
+

Module nitric.proto.nitric.deploy

+
+
+
+ +Expand source code + +
#
+# Copyright (c) 2021 Nitric Technologies Pty Ltd.
+#
+# This file is part of Nitric Python 3 SDK.
+# See https://github.com/nitrictech/python-sdk for further info.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+
+

Sub-modules

+
+
nitric.proto.nitric.deploy.v1
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+ + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/deploy/v1/index.html b/docs/nitric/proto/nitric/deploy/v1/index.html new file mode 100644 index 0000000..98512c9 --- /dev/null +++ b/docs/nitric/proto/nitric/deploy/v1/index.html @@ -0,0 +1,1550 @@ + + + + + + +nitric.proto.nitric.deploy.v1 API documentation + + + + + + + + + + + +
+
+
+

Module nitric.proto.nitric.deploy.v1

+
+
+
+ +Expand source code + +
#
+# Copyright (c) 2021 Nitric Technologies Pty Ltd.
+#
+# This file is part of Nitric Python 3 SDK.
+# See https://github.com/nitrictech/python-sdk for further info.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Generated by the protocol buffer compiler.  DO NOT EDIT!
+# sources: proto/deploy/v1/deploy.proto
+# plugin: python-betterproto
+import warnings
+from dataclasses import dataclass
+from typing import (
+    TYPE_CHECKING,
+    AsyncIterator,
+    Dict,
+    List,
+    Optional,
+)
+
+import betterproto
+import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf
+import grpclib
+from betterproto.grpc.grpclib_server import ServiceBase
+
+from ...resource import v1 as __resource_v1__
+
+
+if TYPE_CHECKING:
+    import grpclib.server
+    from betterproto.grpc.grpclib_client import MetadataLike
+    from grpclib.metadata import Deadline
+
+
+@dataclass(eq=False, repr=False)
+class DeployUpRequest(betterproto.Message):
+    spec: "Spec" = betterproto.message_field(1)
+    """The spec to deploy"""
+
+    attributes: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(2)
+    """
+    A map of attributes related to the deploy request this allows for adding
+    project identifiers etc.
+    """
+
+
+@dataclass(eq=False, repr=False)
+class DeployUpEvent(betterproto.Message):
+    message: "DeployEventMessage" = betterproto.message_field(1, group="content")
+    result: "DeployUpEventResult" = betterproto.message_field(2, group="content")
+
+
+@dataclass(eq=False, repr=False)
+class DeployEventMessage(betterproto.Message):
+    """Messages to provide status updates on the deployment"""
+
+    message: str = betterproto.string_field(1)
+
+
+@dataclass(eq=False, repr=False)
+class UpResult(betterproto.Message):
+    string_result: str = betterproto.string_field(1, group="content")
+    """Simple formatted string output as result"""
+
+
+@dataclass(eq=False, repr=False)
+class DeployUpEventResult(betterproto.Message):
+    """Terminal message indicating deployment success"""
+
+    success: bool = betterproto.bool_field(1)
+    """Indicate the success status"""
+
+    result: "UpResult" = betterproto.message_field(2)
+    """
+    Output state as a struct, this can be provided as an output file or pretty
+    printed for CLI output
+    """
+
+
+@dataclass(eq=False, repr=False)
+class DeployDownRequest(betterproto.Message):
+    attributes: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(1)
+    """
+    A map of attributes related to the deploy request this allows for adding
+    project identifiers etc.
+    """
+
+
+@dataclass(eq=False, repr=False)
+class DeployDownEvent(betterproto.Message):
+    message: "DeployEventMessage" = betterproto.message_field(1, group="content")
+    result: "DeployDownEventResult" = betterproto.message_field(2, group="content")
+
+
+@dataclass(eq=False, repr=False)
+class DeployDownEventResult(betterproto.Message):
+    """Terminal message indicating deployment success"""
+
+    pass
+
+
+@dataclass(eq=False, repr=False)
+class ImageSource(betterproto.Message):
+    """An image source to be used for execution unit deployment"""
+
+    uri: str = betterproto.string_field(1)
+    """
+    URI of the docker image TODO: May also need to provide auth information
+    (although this should just be configured on the running client already)
+    """
+
+
+@dataclass(eq=False, repr=False)
+class ExecutionUnit(betterproto.Message):
+    """A unit of execution (i.e. function/container)"""
+
+    image: "ImageSource" = betterproto.message_field(1, group="source")
+    """Container image as a execution unit"""
+
+    workers: int = betterproto.int32_field(10)
+    """Expected worker count for this execution unit"""
+
+    timeout: int = betterproto.int32_field(11)
+    """Configurable timeout for request handling"""
+
+    memory: int = betterproto.int32_field(12)
+    """Configurable memory size for this instance"""
+
+    type: str = betterproto.string_field(13)
+    """
+    A simple type property describes the requested type of execution unit that
+    this should be for this project, a provider can implement how this request
+    is satisfied in any way
+    """
+
+    env: Dict[str, str] = betterproto.map_field(
+        14, betterproto.TYPE_STRING, betterproto.TYPE_STRING
+    )
+    """Environment variables for this execution unit"""
+
+    def __post_init__(self) -> None:
+        super().__post_init__()
+        if self.is_set("timeout"):
+            warnings.warn("ExecutionUnit.timeout is deprecated", DeprecationWarning)
+        if self.is_set("memory"):
+            warnings.warn("ExecutionUnit.memory is deprecated", DeprecationWarning)
+
+
+@dataclass(eq=False, repr=False)
+class Bucket(betterproto.Message):
+    pass
+
+
+@dataclass(eq=False, repr=False)
+class Topic(betterproto.Message):
+    subscriptions: List["SubscriptionTarget"] = betterproto.message_field(1)
+    """TODO: Include topic specifications here"""
+
+
+@dataclass(eq=False, repr=False)
+class Queue(betterproto.Message):
+    pass
+
+
+@dataclass(eq=False, repr=False)
+class Collection(betterproto.Message):
+    pass
+
+
+@dataclass(eq=False, repr=False)
+class Secret(betterproto.Message):
+    pass
+
+
+@dataclass(eq=False, repr=False)
+class SubscriptionTarget(betterproto.Message):
+    execution_unit: str = betterproto.string_field(1, group="target")
+    """The name of an execution unit to target"""
+
+
+@dataclass(eq=False, repr=False)
+class TopicSubscription(betterproto.Message):
+    target: "SubscriptionTarget" = betterproto.message_field(1)
+
+
+@dataclass(eq=False, repr=False)
+class Api(betterproto.Message):
+    openapi: str = betterproto.string_field(1, group="document")
+    """
+    An OpenAPI document for deployment This document will contain extensions
+    that hint of execution units that should be targeted as part of the
+    deployment
+    """
+
+
+@dataclass(eq=False, repr=False)
+class ScheduleTarget(betterproto.Message):
+    execution_unit: str = betterproto.string_field(1, group="target")
+    """The name of an execution unit to target"""
+
+
+@dataclass(eq=False, repr=False)
+class Schedule(betterproto.Message):
+    cron: str = betterproto.string_field(1)
+    target: "ScheduleTarget" = betterproto.message_field(2)
+
+
+@dataclass(eq=False, repr=False)
+class Resource(betterproto.Message):
+    name: str = betterproto.string_field(1)
+    type: "__resource_v1__.ResourceType" = betterproto.enum_field(2)
+    execution_unit: "ExecutionUnit" = betterproto.message_field(10, group="config")
+    bucket: "Bucket" = betterproto.message_field(11, group="config")
+    topic: "Topic" = betterproto.message_field(12, group="config")
+    queue: "Queue" = betterproto.message_field(13, group="config")
+    api: "Api" = betterproto.message_field(14, group="config")
+    policy: "Policy" = betterproto.message_field(15, group="config")
+    schedule: "Schedule" = betterproto.message_field(16, group="config")
+    collection: "Collection" = betterproto.message_field(17, group="config")
+    secret: "Secret" = betterproto.message_field(18, group="config")
+
+
+@dataclass(eq=False, repr=False)
+class Policy(betterproto.Message):
+    """
+    TODO: This is already defined in our resource contracts... Need to
+    determine if it's worth re-using unfortunately there are parts we don't
+    want to duplicate, such as API config
+    """
+
+    principals: List["Resource"] = betterproto.message_field(1)
+    actions: List["__resource_v1__.Action"] = betterproto.enum_field(2)
+    """
+    TODO: Split out discrete action definitions from resources Also need to
+    allow custom action types as well Should incorporate action re-use here...
+    """
+
+    resources: List["Resource"] = betterproto.message_field(3)
+
+
+@dataclass(eq=False, repr=False)
+class Spec(betterproto.Message):
+    resources: List["Resource"] = betterproto.message_field(1)
+    """list of resources to deploy"""
+
+
+class DeployServiceStub(betterproto.ServiceStub):
+    async def up(
+        self,
+        deploy_up_request: "DeployUpRequest",
+        *,
+        timeout: Optional[float] = None,
+        deadline: Optional["Deadline"] = None,
+        metadata: Optional["MetadataLike"] = None
+    ) -> AsyncIterator["DeployUpEvent"]:
+        async for response in self._unary_stream(
+            "/nitric.deploy.v1.DeployService/Up",
+            deploy_up_request,
+            DeployUpEvent,
+            timeout=timeout,
+            deadline=deadline,
+            metadata=metadata,
+        ):
+            yield response
+
+    async def down(
+        self,
+        deploy_down_request: "DeployDownRequest",
+        *,
+        timeout: Optional[float] = None,
+        deadline: Optional["Deadline"] = None,
+        metadata: Optional["MetadataLike"] = None
+    ) -> AsyncIterator["DeployDownEvent"]:
+        async for response in self._unary_stream(
+            "/nitric.deploy.v1.DeployService/Down",
+            deploy_down_request,
+            DeployDownEvent,
+            timeout=timeout,
+            deadline=deadline,
+            metadata=metadata,
+        ):
+            yield response
+
+
+class DeployServiceBase(ServiceBase):
+    async def up(
+        self, deploy_up_request: "DeployUpRequest"
+    ) -> AsyncIterator["DeployUpEvent"]:
+        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
+
+    async def down(
+        self, deploy_down_request: "DeployDownRequest"
+    ) -> AsyncIterator["DeployDownEvent"]:
+        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
+
+    async def __rpc_up(
+        self, stream: "grpclib.server.Stream[DeployUpRequest, DeployUpEvent]"
+    ) -> None:
+        request = await stream.recv_message()
+        await self._call_rpc_handler_server_stream(
+            self.up,
+            stream,
+            request,
+        )
+
+    async def __rpc_down(
+        self, stream: "grpclib.server.Stream[DeployDownRequest, DeployDownEvent]"
+    ) -> None:
+        request = await stream.recv_message()
+        await self._call_rpc_handler_server_stream(
+            self.down,
+            stream,
+            request,
+        )
+
+    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
+        return {
+            "/nitric.deploy.v1.DeployService/Up": grpclib.const.Handler(
+                self.__rpc_up,
+                grpclib.const.Cardinality.UNARY_STREAM,
+                DeployUpRequest,
+                DeployUpEvent,
+            ),
+            "/nitric.deploy.v1.DeployService/Down": grpclib.const.Handler(
+                self.__rpc_down,
+                grpclib.const.Cardinality.UNARY_STREAM,
+                DeployDownRequest,
+                DeployDownEvent,
+            ),
+        }
+
+
+
+
+
+
+
+
+
+

Classes

+
+
+class Api +(openapi: str = <object object>) +
+
+

Api(openapi: str = )

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class Api(betterproto.Message):
+    openapi: str = betterproto.string_field(1, group="document")
+    """
+    An OpenAPI document for deployment This document will contain extensions
+    that hint of execution units that should be targeted as part of the
+    deployment
+    """
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var openapi : str
+
+

An OpenAPI document for deployment This document will contain extensions +that hint of execution units that should be targeted as part of the +deployment

+
+
+ +
+class Bucket +
+
+

Bucket()

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class Bucket(betterproto.Message):
+    pass
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+
+
+class Collection +
+
+

Collection()

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class Collection(betterproto.Message):
+    pass
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+
+
+class DeployDownEvent +(message: DeployEventMessage = <object object>, result: DeployDownEventResult = <object object>) +
+
+

DeployDownEvent(message: 'DeployEventMessage' = , result: 'DeployDownEventResult' = )

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class DeployDownEvent(betterproto.Message):
+    message: "DeployEventMessage" = betterproto.message_field(1, group="content")
+    result: "DeployDownEventResult" = betterproto.message_field(2, group="content")
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var messageDeployEventMessage
+
+
+
+
var resultDeployDownEventResult
+
+
+
+
+ +
+class DeployDownEventResult +
+
+

Terminal message indicating deployment success

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class DeployDownEventResult(betterproto.Message):
+    """Terminal message indicating deployment success"""
+
+    pass
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+
+
+class DeployDownRequest +(attributes: betterproto_lib_google_protobuf.Struct = <object object>) +
+
+

DeployDownRequest(attributes: 'betterproto_lib_google_protobuf.Struct' = )

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class DeployDownRequest(betterproto.Message):
+    attributes: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(1)
+    """
+    A map of attributes related to the deploy request this allows for adding
+    project identifiers etc.
+    """
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var attributes : betterproto.lib.google.protobuf.Struct
+
+

A map of attributes related to the deploy request this allows for adding +project identifiers etc.

+
+
+ +
+class DeployEventMessage +(message: str = <object object>) +
+
+

Messages to provide status updates on the deployment

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class DeployEventMessage(betterproto.Message):
+    """Messages to provide status updates on the deployment"""
+
+    message: str = betterproto.string_field(1)
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var message : str
+
+
+
+
+
+
+class DeployServiceBase +
+
+

Base class for async gRPC servers.

+
+ +Expand source code + +
class DeployServiceBase(ServiceBase):
+    async def up(
+        self, deploy_up_request: "DeployUpRequest"
+    ) -> AsyncIterator["DeployUpEvent"]:
+        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
+
+    async def down(
+        self, deploy_down_request: "DeployDownRequest"
+    ) -> AsyncIterator["DeployDownEvent"]:
+        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
+
+    async def __rpc_up(
+        self, stream: "grpclib.server.Stream[DeployUpRequest, DeployUpEvent]"
+    ) -> None:
+        request = await stream.recv_message()
+        await self._call_rpc_handler_server_stream(
+            self.up,
+            stream,
+            request,
+        )
+
+    async def __rpc_down(
+        self, stream: "grpclib.server.Stream[DeployDownRequest, DeployDownEvent]"
+    ) -> None:
+        request = await stream.recv_message()
+        await self._call_rpc_handler_server_stream(
+            self.down,
+            stream,
+            request,
+        )
+
+    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
+        return {
+            "/nitric.deploy.v1.DeployService/Up": grpclib.const.Handler(
+                self.__rpc_up,
+                grpclib.const.Cardinality.UNARY_STREAM,
+                DeployUpRequest,
+                DeployUpEvent,
+            ),
+            "/nitric.deploy.v1.DeployService/Down": grpclib.const.Handler(
+                self.__rpc_down,
+                grpclib.const.Cardinality.UNARY_STREAM,
+                DeployDownRequest,
+                DeployDownEvent,
+            ),
+        }
+
+

Ancestors

+
    +
  • betterproto.grpc.grpclib_server.ServiceBase
  • +
  • abc.ABC
  • +
+

Methods

+
+
+async def down(self, deploy_down_request: DeployDownRequest) ‑> AsyncIterator[DeployDownEvent] +
+
+
+
+ +Expand source code + +
async def down(
+    self, deploy_down_request: "DeployDownRequest"
+) -> AsyncIterator["DeployDownEvent"]:
+    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
+
+
+
+async def up(self, deploy_up_request: DeployUpRequest) ‑> AsyncIterator[DeployUpEvent] +
+
+
+
+ +Expand source code + +
async def up(
+    self, deploy_up_request: "DeployUpRequest"
+) -> AsyncIterator["DeployUpEvent"]:
+    raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
+
+
+
+
+
+class DeployServiceStub +(channel: Channel, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Union[Mapping[str, Union[str, bytes]], Collection[Tuple[str, Union[str, bytes]]], NoneType] = None) +
+
+

Base class for async gRPC clients.

+
+ +Expand source code + +
class DeployServiceStub(betterproto.ServiceStub):
+    async def up(
+        self,
+        deploy_up_request: "DeployUpRequest",
+        *,
+        timeout: Optional[float] = None,
+        deadline: Optional["Deadline"] = None,
+        metadata: Optional["MetadataLike"] = None
+    ) -> AsyncIterator["DeployUpEvent"]:
+        async for response in self._unary_stream(
+            "/nitric.deploy.v1.DeployService/Up",
+            deploy_up_request,
+            DeployUpEvent,
+            timeout=timeout,
+            deadline=deadline,
+            metadata=metadata,
+        ):
+            yield response
+
+    async def down(
+        self,
+        deploy_down_request: "DeployDownRequest",
+        *,
+        timeout: Optional[float] = None,
+        deadline: Optional["Deadline"] = None,
+        metadata: Optional["MetadataLike"] = None
+    ) -> AsyncIterator["DeployDownEvent"]:
+        async for response in self._unary_stream(
+            "/nitric.deploy.v1.DeployService/Down",
+            deploy_down_request,
+            DeployDownEvent,
+            timeout=timeout,
+            deadline=deadline,
+            metadata=metadata,
+        ):
+            yield response
+
+

Ancestors

+
    +
  • betterproto.grpc.grpclib_client.ServiceStub
  • +
  • abc.ABC
  • +
+

Methods

+
+
+async def down(self, deploy_down_request: DeployDownRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> AsyncIterator[DeployDownEvent] +
+
+
+
+ +Expand source code + +
async def down(
+    self,
+    deploy_down_request: "DeployDownRequest",
+    *,
+    timeout: Optional[float] = None,
+    deadline: Optional["Deadline"] = None,
+    metadata: Optional["MetadataLike"] = None
+) -> AsyncIterator["DeployDownEvent"]:
+    async for response in self._unary_stream(
+        "/nitric.deploy.v1.DeployService/Down",
+        deploy_down_request,
+        DeployDownEvent,
+        timeout=timeout,
+        deadline=deadline,
+        metadata=metadata,
+    ):
+        yield response
+
+
+
+async def up(self, deploy_up_request: DeployUpRequest, *, timeout: Optional[float] = None, deadline: Optional[ForwardRef('Deadline')] = None, metadata: Optional[ForwardRef('MetadataLike')] = None) ‑> AsyncIterator[DeployUpEvent] +
+
+
+
+ +Expand source code + +
async def up(
+    self,
+    deploy_up_request: "DeployUpRequest",
+    *,
+    timeout: Optional[float] = None,
+    deadline: Optional["Deadline"] = None,
+    metadata: Optional["MetadataLike"] = None
+) -> AsyncIterator["DeployUpEvent"]:
+    async for response in self._unary_stream(
+        "/nitric.deploy.v1.DeployService/Up",
+        deploy_up_request,
+        DeployUpEvent,
+        timeout=timeout,
+        deadline=deadline,
+        metadata=metadata,
+    ):
+        yield response
+
+
+
+
+
+class DeployUpEvent +(message: DeployEventMessage = <object object>, result: DeployUpEventResult = <object object>) +
+
+

DeployUpEvent(message: 'DeployEventMessage' = , result: 'DeployUpEventResult' = )

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class DeployUpEvent(betterproto.Message):
+    message: "DeployEventMessage" = betterproto.message_field(1, group="content")
+    result: "DeployUpEventResult" = betterproto.message_field(2, group="content")
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var messageDeployEventMessage
+
+
+
+
var resultDeployUpEventResult
+
+
+
+
+ +
+class DeployUpEventResult +(success: bool = <object object>, result: UpResult = <object object>) +
+
+

Terminal message indicating deployment success

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class DeployUpEventResult(betterproto.Message):
+    """Terminal message indicating deployment success"""
+
+    success: bool = betterproto.bool_field(1)
+    """Indicate the success status"""
+
+    result: "UpResult" = betterproto.message_field(2)
+    """
+    Output state as a struct, this can be provided as an output file or pretty
+    printed for CLI output
+    """
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var resultUpResult
+
+

Output state as a struct, this can be provided as an output file or pretty +printed for CLI output

+
+
var success : bool
+
+

Indicate the success status

+
+
+
+
+class DeployUpRequest +(spec: Spec = <object object>, attributes: betterproto_lib_google_protobuf.Struct = <object object>) +
+
+

DeployUpRequest(spec: 'Spec' = , attributes: 'betterproto_lib_google_protobuf.Struct' = )

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class DeployUpRequest(betterproto.Message):
+    spec: "Spec" = betterproto.message_field(1)
+    """The spec to deploy"""
+
+    attributes: "betterproto_lib_google_protobuf.Struct" = betterproto.message_field(2)
+    """
+    A map of attributes related to the deploy request this allows for adding
+    project identifiers etc.
+    """
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var attributes : betterproto.lib.google.protobuf.Struct
+
+

A map of attributes related to the deploy request this allows for adding +project identifiers etc.

+
+
var specSpec
+
+

The spec to deploy

+
+
+ +
+class ExecutionUnit +(image: ImageSource = <object object>, workers: int = <object object>, timeout: int = <object object>, memory: int = <object object>, type: str = <object object>, env: Dict[str, str] = <object object>) +
+
+

A unit of execution (i.e. function/container)

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class ExecutionUnit(betterproto.Message):
+    """A unit of execution (i.e. function/container)"""
+
+    image: "ImageSource" = betterproto.message_field(1, group="source")
+    """Container image as a execution unit"""
+
+    workers: int = betterproto.int32_field(10)
+    """Expected worker count for this execution unit"""
+
+    timeout: int = betterproto.int32_field(11)
+    """Configurable timeout for request handling"""
+
+    memory: int = betterproto.int32_field(12)
+    """Configurable memory size for this instance"""
+
+    type: str = betterproto.string_field(13)
+    """
+    A simple type property describes the requested type of execution unit that
+    this should be for this project, a provider can implement how this request
+    is satisfied in any way
+    """
+
+    env: Dict[str, str] = betterproto.map_field(
+        14, betterproto.TYPE_STRING, betterproto.TYPE_STRING
+    )
+    """Environment variables for this execution unit"""
+
+    def __post_init__(self) -> None:
+        super().__post_init__()
+        if self.is_set("timeout"):
+            warnings.warn("ExecutionUnit.timeout is deprecated", DeprecationWarning)
+        if self.is_set("memory"):
+            warnings.warn("ExecutionUnit.memory is deprecated", DeprecationWarning)
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var env : Dict[str, str]
+
+

Environment variables for this execution unit

+
+
var imageImageSource
+
+

Container image as a execution unit

+
+
var memory : int
+
+

Configurable memory size for this instance

+
+
var timeout : int
+
+

Configurable timeout for request handling

+
+
var type : str
+
+

A simple type property describes the requested type of execution unit that +this should be for this project, a provider can implement how this request +is satisfied in any way

+
+
var workers : int
+
+

Expected worker count for this execution unit

+
+
+
+
+class ImageSource +(uri: str = <object object>) +
+
+

An image source to be used for execution unit deployment

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class ImageSource(betterproto.Message):
+    """An image source to be used for execution unit deployment"""
+
+    uri: str = betterproto.string_field(1)
+    """
+    URI of the docker image TODO: May also need to provide auth information
+    (although this should just be configured on the running client already)
+    """
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var uri : str
+
+

URI of the docker image TODO: May also need to provide auth information +(although this should just be configured on the running client already)

+
+
+
+
+class Policy +(principals: List[ForwardRef('Resource')] = <object object>, actions: List[ForwardRef('__resource_v1__.Action')] = <object object>, resources: List[ForwardRef('Resource')] = <object object>) +
+
+

TODO: This is already defined in our resource contracts… Need to +determine if it's worth re-using unfortunately there are parts we don't +want to duplicate, such as API config

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class Policy(betterproto.Message):
+    """
+    TODO: This is already defined in our resource contracts... Need to
+    determine if it's worth re-using unfortunately there are parts we don't
+    want to duplicate, such as API config
+    """
+
+    principals: List["Resource"] = betterproto.message_field(1)
+    actions: List["__resource_v1__.Action"] = betterproto.enum_field(2)
+    """
+    TODO: Split out discrete action definitions from resources Also need to
+    allow custom action types as well Should incorporate action re-use here...
+    """
+
+    resources: List["Resource"] = betterproto.message_field(3)
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var actions : List[Action]
+
+

TODO: Split out discrete action definitions from resources Also need to +allow custom action types as well Should incorporate action re-use here…

+
+
var principals : List[Resource]
+
+
+
+
var resources : List[Resource]
+
+
+
+
+
+
+class Queue +
+
+

Queue()

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class Queue(betterproto.Message):
+    pass
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+
+
+class Resource +(name: str = <object object>, type: __resource_v1__.ResourceType = <object object>, execution_unit: ExecutionUnit = <object object>, bucket: Bucket = <object object>, topic: Topic = <object object>, queue: Queue = <object object>, api: Api = <object object>, policy: Policy = <object object>, schedule: Schedule = <object object>, collection: Collection = <object object>, secret: Secret = <object object>) +
+
+

Resource(name: str = , type: 'resource_v1.ResourceType' = , execution_unit: 'ExecutionUnit' = , bucket: 'Bucket' = , topic: 'Topic' = , queue: 'Queue' = , api: 'Api' = , policy: 'Policy' = , schedule: 'Schedule' = , collection: 'Collection' = , secret: 'Secret' = )

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class Resource(betterproto.Message):
+    name: str = betterproto.string_field(1)
+    type: "__resource_v1__.ResourceType" = betterproto.enum_field(2)
+    execution_unit: "ExecutionUnit" = betterproto.message_field(10, group="config")
+    bucket: "Bucket" = betterproto.message_field(11, group="config")
+    topic: "Topic" = betterproto.message_field(12, group="config")
+    queue: "Queue" = betterproto.message_field(13, group="config")
+    api: "Api" = betterproto.message_field(14, group="config")
+    policy: "Policy" = betterproto.message_field(15, group="config")
+    schedule: "Schedule" = betterproto.message_field(16, group="config")
+    collection: "Collection" = betterproto.message_field(17, group="config")
+    secret: "Secret" = betterproto.message_field(18, group="config")
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var apiApi
+
+
+
+
var bucketBucket
+
+
+
+
var collectionCollection
+
+
+
+
var execution_unitExecutionUnit
+
+
+
+
var name : str
+
+
+
+
var policyPolicy
+
+
+
+
var queueQueue
+
+
+
+
var scheduleSchedule
+
+
+
+
var secretSecret
+
+
+
+
var topicTopic
+
+
+
+
var typeResourceType
+
+
+
+
+ +
+class Schedule +(cron: str = <object object>, target: ScheduleTarget = <object object>) +
+
+

Schedule(cron: str = , target: 'ScheduleTarget' = )

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class Schedule(betterproto.Message):
+    cron: str = betterproto.string_field(1)
+    target: "ScheduleTarget" = betterproto.message_field(2)
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var cron : str
+
+
+
+
var targetScheduleTarget
+
+
+
+
+ +
+class ScheduleTarget +(execution_unit: str = <object object>) +
+
+

ScheduleTarget(execution_unit: str = )

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class ScheduleTarget(betterproto.Message):
+    execution_unit: str = betterproto.string_field(1, group="target")
+    """The name of an execution unit to target"""
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var execution_unit : str
+
+

The name of an execution unit to target

+
+
+ +
+class Secret +
+
+

Secret()

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class Secret(betterproto.Message):
+    pass
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+
+
+class Spec +(resources: List[ForwardRef('Resource')] = <object object>) +
+
+

Spec(resources: List[ForwardRef('Resource')] = )

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class Spec(betterproto.Message):
+    resources: List["Resource"] = betterproto.message_field(1)
+    """list of resources to deploy"""
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var resources : List[Resource]
+
+

list of resources to deploy

+
+
+ +
+class SubscriptionTarget +(execution_unit: str = <object object>) +
+
+

SubscriptionTarget(execution_unit: str = )

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class SubscriptionTarget(betterproto.Message):
+    execution_unit: str = betterproto.string_field(1, group="target")
+    """The name of an execution unit to target"""
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var execution_unit : str
+
+

The name of an execution unit to target

+
+
+ +
+class Topic +(subscriptions: List[ForwardRef('SubscriptionTarget')] = <object object>) +
+
+

Topic(subscriptions: List[ForwardRef('SubscriptionTarget')] = )

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class Topic(betterproto.Message):
+    subscriptions: List["SubscriptionTarget"] = betterproto.message_field(1)
+    """TODO: Include topic specifications here"""
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var subscriptions : List[SubscriptionTarget]
+
+

TODO: Include topic specifications here

+
+
+ +
+class TopicSubscription +(target: SubscriptionTarget = <object object>) +
+
+

TopicSubscription(target: 'SubscriptionTarget' = )

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class TopicSubscription(betterproto.Message):
+    target: "SubscriptionTarget" = betterproto.message_field(1)
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var targetSubscriptionTarget
+
+
+
+
+ +
+class UpResult +(string_result: str = <object object>) +
+
+

UpResult(string_result: str = )

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class UpResult(betterproto.Message):
+    string_result: str = betterproto.string_field(1, group="content")
+    """Simple formatted string output as result"""
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var string_result : str
+
+

Simple formatted string output as result

+
+
+ + + + + + + + + \ No newline at end of file diff --git a/docs/nitric/proto/nitric/document/v1/index.html b/docs/nitric/proto/nitric/document/v1/index.html index 870dd9b..df16f92 100644 --- a/docs/nitric/proto/nitric/document/v1/index.html +++ b/docs/nitric/proto/nitric/document/v1/index.html @@ -502,7 +502,7 @@

Class variables

(key: Key = <object object>)
-

DocumentDeleteRequest(key: 'Key' = )

+

DocumentDeleteRequest(key: 'Key' = )

Expand source code @@ -549,7 +549,7 @@

Ancestors

(key: Key = <object object>)
-

DocumentGetRequest(key: 'Key' = )

+

DocumentGetRequest(key: 'Key' = )

Expand source code @@ -577,7 +577,7 @@

Class variables

(document: Document = <object object>)
-

DocumentGetResponse(document: 'Document' = )

+

DocumentGetResponse(document: 'Document' = )

Expand source code @@ -605,7 +605,7 @@

Class variables

(collection: Collection = <object object>, expressions: List[ForwardRef('Expression')] = <object object>, limit: int = <object object>, paging_token: Dict[str, str] = <object object>)
-

DocumentQueryRequest(collection: 'Collection' = , expressions: List[ForwardRef('Expression')] = , limit: int = , paging_token: Dict[str, str] = )

+

DocumentQueryRequest(collection: 'Collection' = , expressions: List[ForwardRef('Expression')] = , limit: int = , paging_token: Dict[str, str] = )

Expand source code @@ -656,7 +656,7 @@

Class variables

(documents: List[ForwardRef('Document')] = <object object>, paging_token: Dict[str, str] = <object object>)
-

DocumentQueryResponse(documents: List[ForwardRef('Document')] = , paging_token: Dict[str, str] = )

+

DocumentQueryResponse(documents: List[ForwardRef('Document')] = , paging_token: Dict[str, str] = )

Expand source code @@ -697,7 +697,7 @@

Class variables

(collection: Collection = <object object>, expressions: List[ForwardRef('Expression')] = <object object>, limit: int = <object object>)
-

DocumentQueryStreamRequest(collection: 'Collection' = , expressions: List[ForwardRef('Expression')] = , limit: int = )

+

DocumentQueryStreamRequest(collection: 'Collection' = , expressions: List[ForwardRef('Expression')] = , limit: int = )

Expand source code @@ -739,7 +739,7 @@

Class variables

(document: Document = <object object>)
-

DocumentQueryStreamResponse(document: 'Document' = )

+

DocumentQueryStreamResponse(document: 'Document' = )

Expand source code @@ -1203,7 +1203,7 @@

Methods

(key: Key = <object object>, content: betterproto_lib_google_protobuf.Struct = <object object>)
-

DocumentSetRequest(key: 'Key' = , content: 'betterproto_lib_google_protobuf.Struct' = )

+

DocumentSetRequest(key: 'Key' = , content: 'betterproto_lib_google_protobuf.Struct' = )

Expand source code @@ -1301,7 +1301,7 @@

Class variables

(int_value: int = <object object>, double_value: float = <object object>, string_value: str = <object object>, bool_value: bool = <object object>)
-

ExpressionValue(int_value: int = , double_value: float = , string_value: str = , bool_value: bool = )

+

ExpressionValue(int_value: int = , double_value: float = , string_value: str = , bool_value: bool = )

Expand source code diff --git a/docs/nitric/proto/nitric/error/v1/index.html b/docs/nitric/proto/nitric/error/v1/index.html index 63b8344..42cf2cc 100644 --- a/docs/nitric/proto/nitric/error/v1/index.html +++ b/docs/nitric/proto/nitric/error/v1/index.html @@ -98,7 +98,7 @@

Classes

(message: str = <object object>, cause: str = <object object>, scope: ErrorScope = <object object>)
-

ErrorDetails(message: str = , cause: str = , scope: 'ErrorScope' = )

+

ErrorDetails(message: str = , cause: str = , scope: 'ErrorScope' = )

Expand source code @@ -142,7 +142,7 @@

Class variables

(service: str = <object object>, plugin: str = <object object>, args: Dict[str, str] = <object object>)
-

ErrorScope(service: str = , plugin: str = , args: Dict[str, str] = )

+

ErrorScope(service: str = , plugin: str = , args: Dict[str, str] = )

Expand source code diff --git a/docs/nitric/proto/nitric/faas/v1/index.html b/docs/nitric/proto/nitric/faas/v1/index.html index a76a29f..47fb4fb 100644 --- a/docs/nitric/proto/nitric/faas/v1/index.html +++ b/docs/nitric/proto/nitric/faas/v1/index.html @@ -175,6 +175,13 @@

Module nitric.proto.nitric.faas.v1

pass +@dataclass(eq=False, repr=False) +class TraceContext(betterproto.Message): + values: Dict[str, str] = betterproto.map_field( + 1, betterproto.TYPE_STRING, betterproto.TYPE_STRING + ) + + @dataclass(eq=False, repr=False) class TriggerRequest(betterproto.Message): """The server has a trigger for the client to handle""" @@ -185,6 +192,14 @@

Module nitric.proto.nitric.faas.v1

mime_type: str = betterproto.string_field(2) """Should we supply a mime type for the data? Or rely on context?""" + trace_context: "TraceContext" = betterproto.message_field(10) + """ + TraceInformation from the membrane Allows tying traces from external + triggers (e.g. HttpRequests) into each event request/response pair of the + Bidirectional stream. which cannot be facilitated by OOTB stream + interceptors from OTEL. + """ + http: "HttpTriggerContext" = betterproto.message_field(3, group="context") topic: "TopicTriggerContext" = betterproto.message_field(4, group="context") @@ -373,7 +388,7 @@

Classes

(api: str = <object object>, path: str = <object object>, methods: List[str] = <object object>, options: ApiWorkerOptions = <object object>)
-

ApiWorker(api: str = , path: str = , methods: List[str] = , options: 'ApiWorkerOptions' = )

+

ApiWorker(api: str = , path: str = , methods: List[str] = , options: 'ApiWorkerOptions' = )

Expand source code @@ -415,7 +430,7 @@

Class variables

(security: Dict[str, ForwardRef('ApiWorkerScopes')] = <object object>, security_disabled: bool = <object object>)
-

ApiWorkerOptions(security: Dict[str, ForwardRef('ApiWorkerScopes')] = , security_disabled: bool = )

+

ApiWorkerOptions(security: Dict[str, ForwardRef('ApiWorkerScopes')] = , security_disabled: bool = )

Expand source code @@ -458,7 +473,7 @@

Class variables

(scopes: List[str] = <object object>)
-

ApiWorkerScopes(scopes: List[str] = )

+

ApiWorkerScopes(scopes: List[str] = )

Expand source code @@ -664,7 +679,7 @@

Methods

(value: List[str] = <object object>)
-

HeaderValue(value: List[str] = )

+

HeaderValue(value: List[str] = )

Expand source code @@ -750,7 +765,7 @@

Class variables

(method: str = <object object>, path: str = <object object>, headers_old: Dict[str, str] = <object object>, query_params_old: Dict[str, str] = <object object>, headers: Dict[str, ForwardRef('HeaderValue')] = <object object>, query_params: Dict[str, ForwardRef('QueryValue')] = <object object>, path_params: Dict[str, str] = <object object>)
-

HttpTriggerContext(method: str = , path: str = , headers_old: Dict[str, str] = , query_params_old: Dict[str, str] = , headers: Dict[str, ForwardRef('HeaderValue')] = , query_params: Dict[str, ForwardRef('QueryValue')] = , path_params: Dict[str, str] = )

+

HttpTriggerContext(method: str = , path: str = , headers_old: Dict[str, str] = , query_params_old: Dict[str, str] = , headers: Dict[str, ForwardRef('HeaderValue')] = , query_params: Dict[str, ForwardRef('QueryValue')] = , path_params: Dict[str, str] = )

Expand source code @@ -915,7 +930,7 @@

Ancestors

(value: List[str] = <object object>)
-

QueryValue(value: List[str] = )

+

QueryValue(value: List[str] = )

Expand source code @@ -942,7 +957,7 @@

Class variables

(cron: str = <object object>)
-

ScheduleCron(cron: str = )

+

ScheduleCron(cron: str = )

Expand source code @@ -969,7 +984,7 @@

Class variables

(rate: str = <object object>)
-

ScheduleRate(rate: str = )

+

ScheduleRate(rate: str = )

Expand source code @@ -996,7 +1011,7 @@

Class variables

(key: str = <object object>, rate: ScheduleRate = <object object>, cron: ScheduleCron = <object object>)
-

ScheduleWorker(key: str = , rate: 'ScheduleRate' = , cron: 'ScheduleCron' = )

+

ScheduleWorker(key: str = , rate: 'ScheduleRate' = , cron: 'ScheduleCron' = )

Expand source code @@ -1079,7 +1094,7 @@

Class variables

(topic: str = <object object>)
-

SubscriptionWorker(topic: str = )

+

SubscriptionWorker(topic: str = )

Expand source code @@ -1140,7 +1155,7 @@

Class variables

(topic: str = <object object>)
-

TopicTriggerContext(topic: str = )

+

TopicTriggerContext(topic: str = )

Expand source code @@ -1163,9 +1178,38 @@

Class variables

+
+class TraceContext +(values: Dict[str, str] = <object object>) +
+
+

TraceContext(values: Dict[str, str] = )

+
+ +Expand source code + +
@dataclass(eq=False, repr=False)
+class TraceContext(betterproto.Message):
+    values: Dict[str, str] = betterproto.map_field(
+        1, betterproto.TYPE_STRING, betterproto.TYPE_STRING
+    )
+
+

Ancestors

+
    +
  • betterproto.Message
  • +
  • abc.ABC
  • +
+

Class variables

+
+
var values : Dict[str, str]
+
+
+
+
+
class TriggerRequest -(data: bytes = <object object>, mime_type: str = <object object>, http: HttpTriggerContext = <object object>, topic: TopicTriggerContext = <object object>) +(data: bytes = <object object>, mime_type: str = <object object>, trace_context: TraceContext = <object object>, http: HttpTriggerContext = <object object>, topic: TopicTriggerContext = <object object>)

The server has a trigger for the client to handle

@@ -1183,6 +1227,14 @@

Class variables

mime_type: str = betterproto.string_field(2) """Should we supply a mime type for the data? Or rely on context?""" + trace_context: "TraceContext" = betterproto.message_field(10) + """ + TraceInformation from the membrane Allows tying traces from external + triggers (e.g. HttpRequests) into each event request/response pair of the + Bidirectional stream. which cannot be facilitated by OOTB stream + interceptors from OTEL. + """ + http: "HttpTriggerContext" = betterproto.message_field(3, group="context") topic: "TopicTriggerContext" = betterproto.message_field(4, group="context") @@ -1209,6 +1261,13 @@

Class variables

+
var trace_contextTraceContext
+
+

TraceInformation from the membrane Allows tying traces from external +triggers (e.g. HttpRequests) into each event request/response pair of the +Bidirectional stream. which cannot be facilitated by OOTB stream +interceptors from OTEL.

+
@@ -1403,12 +1462,19 @@

TraceContext

+ + +
  • TriggerRequest

  • diff --git a/docs/nitric/proto/nitric/index.html b/docs/nitric/proto/nitric/index.html index 53be9a8..8c42e05 100644 --- a/docs/nitric/proto/nitric/index.html +++ b/docs/nitric/proto/nitric/index.html @@ -26,6 +26,10 @@

    Namespace nitric.proto.nitric

    Sub-modules

    +
    nitric.proto.nitric.deploy
    +
    +
    +
    nitric.proto.nitric.document
    @@ -80,6 +84,7 @@

    Index

  • Sub-modules

  • -

    FailedTask(task: 'NitricTask' = , message: str = )

    +

    FailedTask(task: 'NitricTask' = , message: str = )

    Expand source code @@ -428,7 +428,7 @@

    Class variables

    (queue: str = <object object>, lease_id: str = <object object>)
    -

    QueueCompleteRequest(queue: str = , lease_id: str = )

    +

    QueueCompleteRequest(queue: str = , lease_id: str = )

    Expand source code @@ -487,7 +487,7 @@

    Ancestors

    (queue: str = <object object>, depth: int = <object object>)
    -

    QueueReceiveRequest(queue: str = , depth: int = )

    +

    QueueReceiveRequest(queue: str = , depth: int = )

    Expand source code @@ -530,7 +530,7 @@

    Class variables

    (tasks: List[ForwardRef('NitricTask')] = <object object>)
    -

    QueueReceiveResponse(tasks: List[ForwardRef('NitricTask')] = )

    +

    QueueReceiveResponse(tasks: List[ForwardRef('NitricTask')] = )

    Expand source code @@ -558,7 +558,7 @@

    Class variables

    (queue: str = <object object>, tasks: List[ForwardRef('NitricTask')] = <object object>)
    -

    QueueSendBatchRequest(queue: str = , tasks: List[ForwardRef('NitricTask')] = )

    +

    QueueSendBatchRequest(queue: str = , tasks: List[ForwardRef('NitricTask')] = )

    Expand source code diff --git a/docs/nitric/proto/nitric/resource/v1/index.html b/docs/nitric/proto/nitric/resource/v1/index.html index d977ec0..08a4427 100644 --- a/docs/nitric/proto/nitric/resource/v1/index.html +++ b/docs/nitric/proto/nitric/resource/v1/index.html @@ -441,7 +441,7 @@

    Class variables

    (security_definitions: Dict[str, ForwardRef('ApiSecurityDefinition')] = <object object>, security: Dict[str, ForwardRef('ApiScopes')] = <object object>)
    -

    ApiResource(security_definitions: Dict[str, ForwardRef('ApiSecurityDefinition')] = , security: Dict[str, ForwardRef('ApiScopes')] = )

    +

    ApiResource(security_definitions: Dict[str, ForwardRef('ApiSecurityDefinition')] = , security: Dict[str, ForwardRef('ApiScopes')] = )

    Expand source code @@ -484,7 +484,7 @@

    Class variables

    (url: str = <object object>)
    -

    ApiResourceDetails(url: str = )

    +

    ApiResourceDetails(url: str = )

    Expand source code @@ -511,7 +511,7 @@

    Class variables

    (scopes: List[str] = <object object>)
    -

    ApiScopes(scopes: List[str] = )

    +

    ApiScopes(scopes: List[str] = )

    Expand source code @@ -538,7 +538,7 @@

    Class variables

    (jwt: ApiSecurityDefinitionJwt = <object object>)
    -

    ApiSecurityDefinition(jwt: 'ApiSecurityDefinitionJwt' = )

    +

    ApiSecurityDefinition(jwt: 'ApiSecurityDefinitionJwt' = )

    Expand source code @@ -637,7 +637,7 @@

    Ancestors

    (principals: List[ForwardRef('Resource')] = <object object>, actions: List[ForwardRef('Action')] = <object object>, resources: List[ForwardRef('Resource')] = <object object>)
    -

    PolicyResource(principals: List[ForwardRef('Resource')] = , actions: List[ForwardRef('Action')] = , resources: List[ForwardRef('Resource')] = )

    +

    PolicyResource(principals: List[ForwardRef('Resource')] = , actions: List[ForwardRef('Action')] = , resources: List[ForwardRef('Resource')] = )

    Expand source code @@ -693,7 +693,7 @@

    Ancestors

    (type: ResourceType = <object object>, name: str = <object object>)
    -

    Resource(type: 'ResourceType' = , name: str = )

    +

    Resource(type: 'ResourceType' = , name: str = )

    Expand source code @@ -725,7 +725,7 @@

    Class variables

    (resource: Resource = <object object>, policy: PolicyResource = <object object>, bucket: BucketResource = <object object>, queue: QueueResource = <object object>, topic: TopicResource = <object object>, collection: CollectionResource = <object object>, secret: SecretResource = <object object>, api: ApiResource = <object object>)
    -

    ResourceDeclareRequest(resource: 'Resource' = , policy: 'PolicyResource' = , bucket: 'BucketResource' = , queue: 'QueueResource' = , topic: 'TopicResource' = , collection: 'CollectionResource' = , secret: 'SecretResource' = , api: 'ApiResource' = )

    +

    ResourceDeclareRequest(resource: 'Resource' = , policy: 'PolicyResource' = , bucket: 'BucketResource' = , queue: 'QueueResource' = , topic: 'TopicResource' = , collection: 'CollectionResource' = , secret: 'SecretResource' = , api: 'ApiResource' = )

    Expand source code @@ -806,7 +806,7 @@

    Ancestors

    (resource: Resource = <object object>)
    -

    ResourceDetailsRequest(resource: 'Resource' = )

    +

    ResourceDetailsRequest(resource: 'Resource' = )

    Expand source code @@ -833,7 +833,7 @@

    Class variables

    (id: str = <object object>, provider: str = <object object>, service: str = <object object>, api: ApiResourceDetails = <object object>)
    -

    ResourceDetailsResponse(id: str = , provider: str = , service: str = , api: 'ApiResourceDetails' = )

    +

    ResourceDetailsResponse(id: str = , provider: str = , service: str = , api: 'ApiResourceDetails' = )

    Expand source code diff --git a/docs/nitric/proto/nitric/storage/v1/index.html b/docs/nitric/proto/nitric/storage/v1/index.html index a910859..efc9963 100644 --- a/docs/nitric/proto/nitric/storage/v1/index.html +++ b/docs/nitric/proto/nitric/storage/v1/index.html @@ -391,7 +391,7 @@

    Classes

    (key: str = <object object>)
    -

    File(key: str = )

    +

    File(key: str = )

    Expand source code @@ -476,7 +476,7 @@

    Ancestors

    (bucket_name: str = <object object>)
    -

    StorageListFilesRequest(bucket_name: str = )

    +

    StorageListFilesRequest(bucket_name: str = )

    Expand source code @@ -503,7 +503,7 @@

    Class variables

    (files: List[ForwardRef('File')] = <object object>)
    -

    StorageListFilesResponse(files: List[ForwardRef('File')] = )

    +

    StorageListFilesResponse(files: List[ForwardRef('File')] = )

    Expand source code @@ -636,7 +636,7 @@

    Class variables

    (url: str = <object object>)
    -

    StoragePreSignUrlResponse(url: str = )

    +

    StoragePreSignUrlResponse(url: str = )

    Expand source code diff --git a/docs/nitric/resources/apis.html b/docs/nitric/resources/apis.html index 5209d3b..2687123 100644 --- a/docs/nitric/resources/apis.html +++ b/docs/nitric/resources/apis.html @@ -63,7 +63,6 @@

    Module nitric.resources.apis

    from grpclib import GRPCError from nitric.api.exception import exception_from_grpc_error - @dataclass class ApiDetails: """Represents the APIs deployment details.""" diff --git a/nitric/application.py b/nitric/application.py index ee42a0d..f9244f8 100644 --- a/nitric/application.py +++ b/nitric/application.py @@ -17,7 +17,7 @@ # limitations under the License. # import asyncio -import os +from os import getenv, environ from opentelemetry import trace from opentelemetry.sdk.trace import TracerProvider, sampling @@ -68,8 +68,9 @@ def _create_resource(cls, resource: Type[BT], name: str, *args, **kwargs) -> BT: @classmethod def _create_tracer(cls) -> TracerProvider: - local_run = os.environ.OTELCOL_BIN is not None - samplePercent = os.environ.NITRIC_TRACE_SAMPLE_PERCENT + local_run = "OTELCOL_BIN" not in environ + samplePercent = getenv("NITRIC_TRACE_SAMPLE_PERCENT") + samplePercent = float(samplePercent) / 100 if samplePercent is not None else 100 # If its a local run use a console exporter, otherwise export using OTEL Protocol exporter = OTLPSpanExporter(endpoint="http://localhost:4317", insecure=True) @@ -78,7 +79,7 @@ def _create_tracer(cls) -> TracerProvider: provider = TracerProvider( active_span_processor=BatchSpanProcessor(exporter), - sampler=sampling.TraceIdRatioBased(samplePercent / 100 if samplePercent is not None else 100), + sampler=sampling.TraceIdRatioBased(samplePercent), ) trace.set_tracer_provider(provider)