Skip to content

Commit

Permalink
Merge pull request #1245 from tpmccallum/observability
Browse files Browse the repository at this point in the history
Add observability (OTEL)
  • Loading branch information
tpmccallum authored Apr 5, 2024
2 parents 73c5e59 + 3baaf42 commit f2e471c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 8 deletions.
10 changes: 2 additions & 8 deletions content/spin/v2/dynamic-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ date = "2023-11-04T00:00:01Z"
url = "https://github.com/fermyon/developer/blob/main/content/spin/v2/dynamic-configuration.md"

---

- [Application Variables Runtime Configuration](#application-variables-runtime-configuration)
- [Environment Variable Provider](#environment-variable-provider)
- [Vault Application Variable Provider](#vault-application-variable-provider)
Expand All @@ -15,7 +16,7 @@ url = "https://github.com/fermyon/developer/blob/main/content/spin/v2/dynamic-co
- [SQLite Storage Runtime Configuration](#sqlite-storage-runtime-configuration)
- [LibSQL Storage Provider](#libsql-storage-provider)
- [LLM Runtime Configuration](#llm-runtime-configuration)
- [Remote Compute Provider](#remote-compute-provider)
- [Remote Compute Provider](#remote-compute-provider)

Configuration for Spin application features such as [application variables](./variables),
[key value storage](./kv-store-api-guide), [SQL storage](./sqlite-api-guide)
Expand All @@ -25,13 +26,6 @@ requiring no changes to the application code itself.
This runtime configuration data is stored in the `runtime-config.toml` file and passed in via the `--runtime-config-file` flag
when invoking the `spin up` command.

The list of Spin features supporting runtime configuration includes:

- [Application Variables](#variables-runtime-configuration)
- [Key Value Storage](#key-value-store-runtime-configuration)
- [SQL storage](#sqlite-storage-runtime-configuration)
- [Serverless AI Compute](#llm-runtime-configuration)

Let's look at each configuration category in-depth below.

## Application Variables Runtime Configuration
Expand Down
39 changes: 39 additions & 0 deletions content/spin/v2/observing-apps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
title = "Observing Applications"
template = "spin_main"
date = "2023-11-04T00:00:01Z"
enable_shortcodes = true
[extra]
url = "https://github.com/fermyon/developer/blob/main/content/spin/v2/observing-apps.md"

---

- [Logs](#logs)
- [OpenTelemetry (OTEL)](#opentelemetry-otel)

## Logs

Spin handles application logs by default, storing output and error messages from file system-run applications in the `.spin/logs` directory alongside the manifest file's location. Users have the option to direct logs to a specific folder using the `--log-dir` flag of the `spin up` command. Additionally, if users wish to prevent `stdout` and `stderr` from being written to disk, they can specify an empty string for the `--log-dir` flag, i.e. `spin up --log-dir ""` - effectively disabling log storage. See the [persistent logs](./running-apps#persistent-logs) section for more details.

## OpenTelemetry (OTEL)

Spin now has experimental support for the [OpenTelemetry (OTEL)](https://opentelemetry.io/) observability standard. When configured, Spin will now emit traces of your Spin App as an OTEL [signal](https://opentelemetry.io/docs/concepts/signals/). Here is a brief overview of how to configure it.

First, run an OTEL compliant [collector](https://opentelemetry.io/docs/collector/) to collect the traces. [Jaeger](https://www.jaegertracing.io/) is an open source distributed tracing platform that can act as an OTEL collector and enables viewing taces. You can run Jaeger using Docker:

```bash
docker run -d -p16686:16686 -p4317:4317 -p4318:4318 -e COLLECTOR_OTLP_ENABLED=true jaegertracing/all-in-one:latest
```

Now, you can start your Spin app, setting the endpoint of the OTEL collector in the **`OTEL_EXPORTER_OTLP_ENDPOINT`** environment variable:

```bash
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 spin up
```

After sending some requests to your Spin app, navigate to Jaeger `http://localhost:16686` to view the traces.

![Traces from app](/static/image/jaeger-traces.png)

Spin supports both inbound and outbound [trace context propagation](https://opentelemetry.io/docs/concepts/context-propagation/). This allows you to include Spin in your distributed traces that span all your services.

This observability support in Spin is still experimental. Only the HTTP trigger, the LLM host component, and outbound HTTP requests are implemented at this time. Going forward, we will be adding tracing to the remainder of Spin triggers and host components. We also hope to add support for the OTEL metrics signal in the future. Try it out, let us know what you think and help us improve the observability experience in Spin!
Binary file added static/image/jaeger-traces.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions templates/spin_sidebar_v2.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
href="{{site.info.base_url}}/spin/v2/distributing-apps">Publishing and
Distribution</a>
</li>
<li><a {{#if (active_project request.spin-full-url "/spin/v2/observing-apps" )}}
class="active" {{/if}}
href="{{site.info.base_url}}/spin/v2/observing-apps">Observing
Applications</a>
</li>
<li><a {{#if (active_project request.spin-full-url "/spin/v2/troubleshooting-application-dev"
)}} class="active" {{/if}}
href="{{site.info.base_url}}/spin/v2/troubleshooting-application-dev">Troubleshooting
Expand Down

0 comments on commit f2e471c

Please sign in to comment.