diff --git a/daprdocs/content/en/developing-applications/building-blocks/state-management/state-store-ttl.md b/daprdocs/content/en/developing-applications/building-blocks/state-management/state-store-ttl.md index 49e00d79f..4717a1889 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/state-management/state-store-ttl.md +++ b/daprdocs/content/en/developing-applications/building-blocks/state-management/state-store-ttl.md @@ -28,7 +28,7 @@ Refer to the TTL column in the [state store components guide]({{< ref supported- You can set state TTL in the metadata as part of the state store set request: -{{< tabs ".NET" Python Go "HTTP API (Bash)" "HTTP API (PowerShell)">}} +{{< tabs Python ".NET" Go "HTTP API (Bash)" "HTTP API (PowerShell)">}} {{% codetab %}} diff --git a/daprdocs/content/en/operations/configuration/configuration-overview.md b/daprdocs/content/en/operations/configuration/configuration-overview.md index 40eb09427..1f04714d7 100644 --- a/daprdocs/content/en/operations/configuration/configuration-overview.md +++ b/daprdocs/content/en/operations/configuration/configuration-overview.md @@ -79,13 +79,22 @@ The following table lists the properties for tracing: | `samplingRate` | string | Set sampling rate for tracing to be enabled or disabled. | `stdout` | bool | True write more verbose information to the traces | `otel.endpointAddress` | string | Set the Open Telemetry (OTEL) server address to send traces to -| `otel.isSecure` | bool | Is the connection to the endpoint address encryped +| `otel.isSecure` | bool | Is the connection to the endpoint address encrypted | `otel.protocol` | string | Set to `http` or `grpc` protocol | `zipkin.endpointAddress` | string | Set the Zipkin server address to send traces to `samplingRate` is used to enable or disable the tracing. To disable the sampling rate , set `samplingRate : "0"` in the configuration. The valid range of samplingRate is between 0 and 1 inclusive. The sampling rate determines whether a trace span should be sampled or not based on value. `samplingRate : "1"` samples all traces. By default, the sampling rate is (0.0001) or 1 in 10,000 traces. +The OpenTelemetry (otel) endpoint can also be configured via an environment variables. The presence of the OTEL_EXPORTER_OTLP_ENDPOINT environment variable +turns on tracing for the sidecar. + +| Environment Variable | Description | +|----------------------|-------------| +| `OTEL_EXPORTER_OTLP_ENDPOINT` | Sets the Open Telemetry (OTEL) server address, turns on tracing | +| `OTEL_EXPORTER_OTLP_INSECURE` | Sets the connection to the endpoint as unencrypted (true/false) | +| `OTEL_EXPORTER_OTLP_PROTOCOL` | Transport protocol (`grpc`, `http/protobuf`, `http/json`) | + See [Observability distributed tracing]({{< ref "tracing-overview.md" >}}) for more information. #### Metrics diff --git a/daprdocs/content/en/operations/monitoring/tracing/setup-tracing.md b/daprdocs/content/en/operations/monitoring/tracing/setup-tracing.md index 5e5e7ce92..52147498c 100644 --- a/daprdocs/content/en/operations/monitoring/tracing/setup-tracing.md +++ b/daprdocs/content/en/operations/monitoring/tracing/setup-tracing.md @@ -33,7 +33,7 @@ The following table lists the properties for tracing: | `samplingRate` | string | Set sampling rate for tracing to be enabled or disabled. | `stdout` | bool | True write more verbose information to the traces | `otel.endpointAddress` | string | Set the Open Telemetry (OTEL) server address. -| `otel.isSecure` | bool | Is the connection to the endpoint address encryped. +| `otel.isSecure` | bool | Is the connection to the endpoint address encrypted. | `otel.protocol` | string | Set to `http` or `grpc` protocol. | `zipkin.endpointAddress` | string | Set the Zipkin server address. If this is used, you do not need to specify the `otel` section. @@ -58,3 +58,14 @@ spec: Dapr uses probabilistic sampling. The sample rate defines the probability a tracing span will be sampled and can have a value between 0 and 1 (inclusive). The default sample rate is 0.0001 (i.e. 1 in 10,000 spans is sampled). Changing `samplingRate` to 0 disables tracing altogether. + +## Environment variables + +The OpenTelemetry (otel) endpoint can also be configured via an environment variables. The presence of the OTEL_EXPORTER_OTLP_ENDPOINT environment variable +turns on tracing for the sidecar. + +| Environment Variable | Description | +|----------------------|-------------| +| `OTEL_EXPORTER_OTLP_ENDPOINT` | Sets the Open Telemetry (OTEL) server address, turns on tracing | +| `OTEL_EXPORTER_OTLP_INSECURE` | Sets the connection to the endpoint as unencrypted (true/false) | +| `OTEL_EXPORTER_OTLP_PROTOCOL` | Transport protocol (`grpc`, `http/protobuf`, `http/json`) | \ No newline at end of file diff --git a/daprdocs/content/en/reference/components-reference/supported-bindings/wasm.md b/daprdocs/content/en/reference/components-reference/supported-bindings/wasm.md new file mode 100644 index 000000000..0ca9a69d4 --- /dev/null +++ b/daprdocs/content/en/reference/components-reference/supported-bindings/wasm.md @@ -0,0 +1,103 @@ +--- +type: docs +title: "Wasm" +linkTitle: "Wasm" +description: "Detailed documentation on the WebAssembly binding component" +aliases: +- "/operations/components/setup-bindings/supported-bindings/wasm/" +--- + +## Overview + +With WebAssembly, you can safely run code compiled in other languages. Runtimes +execute WebAssembly Modules (Wasm), which are most often binaries with a `.wasm` +extension. + +The Wasm Binding allows you to invoke a program compiled to Wasm by passing +commandline args or environment variables to it, similar to how you would with +a normal subprocess. For example, you can satisfy an invocation using Python, +even though Dapr is written in Go and is running on a platform that doesn't have +Python installed! + +The Wasm binary must be a program compiled with the WebAssembly System +Interface (WASI). The binary can be a program you've written such as in Go, or +an interpreter you use to run inlined scripts, such as Python. + +Minimally, you must specify a Wasm binary compiled with the canonical WASI +version `wasi_snapshot_preview1` (a.k.a. `wasip1`), often abbreviated to `wasi`. + +> **Note:** If compiling in Go 1.21+, this is `GOOS=wasip1 GOARCH=wasm`. In TinyGo, Rust, and Zig, this is the target `wasm32-wasi`. + +You can also re-use an existing binary. For example, [Wasm Language Runtimes](https://github.com/vmware-labs/webassembly-language-runtimes) +distributes interpreters (including PHP, Python, and Ruby) already compiled to +WASI. + +Wasm binaries are loaded from a URL. For example, the URL `file://rewrite.wasm` +loads `rewrite.wasm` from the current directory of the process. On Kubernetes, +see [How to: Mount Pod volumes to the Dapr sidecar]({{< ref kubernetes-volume-mounts.md >}}) +to configure a filesystem mount that can contain Wasm binaries. + +Dapr uses [wazero](https://wazero.io) to run these binaries, because it has no +dependencies. This allows use of WebAssembly with no installation process +except Dapr itself. + +## Component format + +To configure a Wasm binding, create a component of type +`bindings.wasm`. See [this guide]({{< ref "howto-bindings.md#1-create-a-binding" >}}) +on how to create and apply a binding configuration. + +```yaml +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: wasm +spec: + type: bindings.wasm + version: v1 + metadata: + - name: url + value: "file://uppercase.wasm" +``` + +## Spec metadata fields + +| Field | Details | Required | Example | +|-------|----------------------------------------------------------------|----------|----------------| +| url | The URL of the resource including the Wasm binary to instantiate. The supported schemes include `file://`. The path of a `file://` URL is relative to the Dapr process unless it begins with `/`. | true | `file://hello.wasm` | + + +## Binding support + +This component supports **output binding** with the following operations: + +- `execute` + +## Example request + +The `data` field, if present will be the program's STDIN. You can optionally +pass metadata properties with each request: + +- `args` any CLI arguments, comma-separated. This excludes the program name. + +For example, if the binding `url` was a Ruby interpreter, such as from +[webassembly-language-runtimes](https://github.com/vmware-labs/webassembly-language-runtimes/releases/tag/ruby%2F3.2.0%2B20230215-1349da9), +the following request would respond back with "Hello, salaboy": + +```json +{ + "operation": "execute", + "metadata": { + "args": "-ne,'print \"Hello, \"; print'" + }, + "data": "salaboy" +} +``` + +## Related links + +- [Basic schema for a Dapr component]({{< ref component-schema >}}) +- [Bindings building block]({{< ref bindings >}}) +- [How-To: Trigger application with input binding]({{< ref howto-triggers.md >}}) +- [How-To: Use bindings to interface with external resources]({{< ref howto-bindings.md >}}) +- [Bindings API reference]({{< ref bindings_api.md >}}) diff --git a/daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md b/daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md index 8d19d0b19..d36ad948b 100644 --- a/daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md +++ b/daprdocs/content/en/reference/components-reference/supported-middleware/middleware-wasm.md @@ -1,8 +1,8 @@ --- type: docs -title: "WASM" -linkTitle: "WASM" -description: "Use WASM middleware in your HTTP pipeline" +title: "Wasm" +linkTitle: "Wasm" +description: "Use Wasm middleware in your HTTP pipeline" aliases: - /developing-applications/middleware/supported-middleware/middleware-wasm/ --- @@ -17,9 +17,10 @@ binary. In other words, you can extend Dapr using external files that are not pre-compiled into the `daprd` binary. Dapr embeds [wazero](https://wazero.io) to accomplish this without CGO. -Wasm modules are loaded from a filesystem path. On Kubernetes, see [mounting -volumes to the Dapr sidecar]({{< ref kubernetes-volume-mounts.md >}}) to configure -a filesystem mount that can contain Wasm modules. +Wasm binaries are loaded from a URL. For example, the URL `file://rewrite.wasm` +loads `rewrite.wasm` from the current directory of the process. On Kubernetes, +see [How to: Mount Pod volumes to the Dapr sidecar]({{< ref kubernetes-volume-mounts.md >}}) +to configure a filesystem mount that can contain Wasm modules. ## Component format @@ -32,8 +33,8 @@ spec: type: middleware.http.wasm version: v1 metadata: - - name: path - value: "./router.wasm" + - name: url + value: "file://router.wasm" ``` ## Spec metadata fields @@ -41,9 +42,9 @@ spec: Minimally, a user must specify a Wasm binary implements the [http-handler](https://http-wasm.io/http-handler/). How to compile this is described later. -| Field | Details | Required | Example | -|----------|----------------------------------------------------------------|----------|----------------| -| path | A relative or absolute path to the Wasm binary to instantiate. | true | "./hello.wasm" | +| Field | Details | Required | Example | +|-------|----------------------------------------------------------------|----------|----------------| +| url | The URL of the resource including the Wasm binary to instantiate. The supported schemes include `file://`. The path of a `file://` URL is relative to the Dapr process unless it begins with `/`. | true | `file://hello.wasm` | ## Dapr configuration @@ -109,7 +110,7 @@ func handleRequest(req api.Request, resp api.Response) (next bool, reqCtx uint32 ``` If using TinyGo, compile as shown below and set the spec metadata field named -"path" to the location of the output (ex "router.wasm"): +"url" to the location of the output (for example, `file://router.wasm`): ```bash tinygo build -o router.wasm -scheduler=none --no-debug -target=wasi router.go` @@ -145,7 +146,7 @@ func rewrite(requestURI []byte) ([]byte, error) { ``` If using TinyGo, compile as shown below and set the spec metadata field named -"path" to the location of the output (ex "example.wasm"): +"url" to the location of the output (for example, `file://example.wasm`): ```bash tinygo build -o example.wasm -scheduler=none --no-debug -target=wasi example.go diff --git a/daprdocs/content/en/reference/environment/_index.md b/daprdocs/content/en/reference/environment/_index.md index 3aba469ee..0f49b7510 100644 --- a/daprdocs/content/en/reference/environment/_index.md +++ b/daprdocs/content/en/reference/environment/_index.md @@ -24,3 +24,6 @@ The following table lists the environment variables used by the Dapr runtime, CL | DAPR_HELM_REPO_URL | Your private Dapr Helm chart url | Specifies a private Dapr Helm chart url, which defaults to the official Helm chart URL: `https://dapr.github.io/helm-charts`| | DAPR_HELM_REPO_USERNAME | A username for a private Helm chart | The username required to access the private Dapr Helm chart. If it can be accessed publicly, this env variable does not need to be set| | DAPR_HELM_REPO_PASSWORD | A password for a private Helm chart |The password required to access the private Dapr helm chart. If it can be accessed publicly, this env variable does not need to be set| +| OTEL_EXPORTER_OTLP_ENDPOINT | OpenTelemetry Tracing | Sets the Open Telemetry (OTEL) server address, turns on tracing. (Example: `http://localhost:4318`) | +| OTEL_EXPORTER_OTLP_INSECURE | OpenTelemetry Tracing | Sets the connection to the endpoint as unencrypted. (`true`, `false`) | +| OTEL_EXPORTER_OTLP_PROTOCOL | OpenTelemetry Tracing | The OTLP protocol to use Transport protocol. (`grpc`, `http/protobuf`, `http/json`) | \ No newline at end of file diff --git a/daprdocs/data/components/bindings/generic.yaml b/daprdocs/data/components/bindings/generic.yaml index 57ec9e19f..df07ddd27 100644 --- a/daprdocs/data/components/bindings/generic.yaml +++ b/daprdocs/data/components/bindings/generic.yaml @@ -142,3 +142,11 @@ features: input: true output: true +- component: Wasm + link: wasm + state: Alpha + version: v1 + since: "1.11" + features: + input: false + output: true diff --git a/daprdocs/data/components/middleware/http.yaml b/daprdocs/data/components/middleware/http.yaml index 5f06f016d..582c91270 100644 --- a/daprdocs/data/components/middleware/http.yaml +++ b/daprdocs/data/components/middleware/http.yaml @@ -44,8 +44,8 @@ state: Stable version: v1 description: Converts the body of the request to uppercase letters (demo) -- component: WASM +- component: Wasm link: /reference/components-reference/supported-middleware/middleware-wasm state: Alpha version: v1 - description: Use WASM middleware in your HTTP pipeline + description: Use Wasm middleware in your HTTP pipeline